RtlpTimeToTimeFields

INT16 __stdcall RtlpTimeToTimeFields(_LARGE_INTEGER *a1, _WORD *a2, _LARGE_INTEGER a3){
  __int64 v3; 
  unsigned int v5; 
  __int64 QuadPart; 
  int v7; 
  unsigned int v8; 
  int v9; 
  _LARGE_INTEGER v10; 
  INT16 result; 
  __int64 *v12; 
  __int64 v13; 
  int v14[8]; 
  _WORD v15[8]; 
  _LARGE_INTEGER v16; 

  v16 = a3;
  v3 = *(&ExBootDevicesRemovedEvent + 103);
  *(_OWORD *)v15 = 0i64;
  if( !*(&ExBootDevicesRemovedEvent + 103) || !**(&ExBootDevicesRemovedEvent + 103) )
    return RtlpTimeToTimeFieldsNoLeapSeconds(a1, a2);
  v5 = *(_DWORD *)(*(&ExBootDevicesRemovedEvent + 103) + 4i64);
  _InterlockedOr(v14, 0);
  QuadPart = a1->QuadPart;
  v7 = 0;
  v8 = 0;
  v9 = 0;
  if( v5 )
  {
    v12 = (__int64 *)(v3 + 8);
    do
    {
      v13 = *v12;
      if( *v12 < 0 )
      {
        if( QuadPart < (v13 & 0x7FFFFFFFFFFFFFFFi64) )
          break;
        --v7;
      }
      else if( QuadPart < v13 + 20000000 )
      {
        if( QuadPart < v13 + 10000000 )
        {
          if( QuadPart < v13 )
            break;
          v9 |= 4u;
        }
        else
        {
          v9 |= 2u;
        }
      }
      else
      {
        ++v7;
      }
      ++v8;
      ++v12;
    }
    while( v8 < v5 );
  }
  v10.QuadPart = QuadPart - 10000000i64 * v7;
  v16 = v10;
  if( (v9 & 2) != 0 )
    v16.QuadPart = v10.QuadPart - 10000000;
  result = RtlpTimeToTimeFieldsNoLeapSeconds(&v16, v15);
  if( (v9 & 1) != 0 )
  {
    if( (v9 & 2) != 0 )
      ++v15[5];
  }
  else
  {
    if( (v9 & 4) != 0 )
    {
      result = v15[6] / 2;
      v15[6] /= 2;
    }
    else
    {
      result = v15[6];
    }
    if( (v9 & 2) != 0 )
    {
      result = result / 2 + 500;
      v15[6] = result;
    }
  }
  *(_OWORD *)a2 = *(_OWORD *)v15;
  return result;
}

Referenced by:

GetBootSystemTime
HalEfiSetTime
HalQueryRealTimeClock
HalpCheckWakeupTimeAndAdjust
HalpQueryVirtualRtc
HalpSetVirtualRtc
RtlTimeToTimeFields
WheapGetTimestamp