HalpSetResumeTime

void __fastcall HalpSetResumeTime(_QWORD *a1, int a2){
  __int64 v2; 
  NTSTATUS v3; 
  unsigned __int64 v4; 
  ULONGLONG v5; 
  LARGE_INTEGER CurrentTime[3]; 
  UINT8 RtcValid; 
  ULONGLONG pullResult; 
  unsigned __int64 v9; 
  CurrentTime[0].QuadPart = 0i64;
  v9 = 0i64;
  pullResult = 0i64;
  if( a2 )
  {
    if( HalpResumeFromHibernate )
    {
      if( a2 == 1 )
      {
        if( (HalpResumeFlags & 1) == 0 && HalpResumeTime.QuadPart )
        {
          if( (HalpResumeFlags & 2) == 0 && !ExpRealTimeIsUniversal )
            HalpResumeTime.QuadPart += *(_QWORD *)(PsGetCurrentServerSiloGlobals()[133] + 440);
          v2 = ((__int64(__fastcall *)(unsigned __int64 *))off_140C007F0)(&v9);
          v3 = RtlULongLongMult(v2 - HalpTimeStampAtResume, 0x989680ui64, &pullResult);
          v5 = pullResult / v9;
          if( v3 < 0 )
            v5 = 10000000 * (v4 / v9) + 10000000 * (v4 % v9) / v9;
          HalpResumeTime.QuadPart += v5;
        }
      }
      else if( a2 == 2 )
      {
        if( (HalpResumeFlags & 1) != 0
          || !HalpResumeTime.QuadPart
          || (unsigned __int8)HalpQueryVirtualRtc(CurrentTime, &RtcValid)
          && HalpResumeTime.QuadPart < CurrentTime[0].QuadPart )
        {
          HalpVrtcTimeStale = 1;
        }
        else
        {
          HalpSetVirtualRtc(&HalpResumeTime);
          HalpResumeTime.QuadPart = 0i64;
        }
      }
    }
  }
  else if( a1 )
  {
    HalpResumeTime = (LARGE_INTEGER)a1[15];
    HalpTimeStampAtResume = a1[16];
    HalpResumeFlags = a1[17];
  }
}

Referenced by:

HalpEfiInitializeOnResume
HalpPostSleepMP