HalpShutdown

VOID __stdcall HalpShutdown(){
  __int16 v0; 
  __int16 Input; 
  __int16 Output; 

  Output = 0;
  v0 = 0;
  Input = 0;
  if( _InterlockedCompareExchange(&dword_140C4AD18, 1, 0) )
  {
    while( 1 )
      ;
  }
  (*(void(__fastcall **)(_QWORD))(qword_140C507B0 + 8))(0i64);
  if( *(&CmpDummyThreadEvent + 4992) )
  {
    HalpAcpiPmRegisterRead(PM1A_EVT_REGISTER, 0i64, &Output, 2ui64, 0i64);
    Input = Output;
    if( *(&CmpDummyThreadEvent + 5136) )
    {
      HalpAcpiPmRegisterRead(PM1B_EVT_REGISTER, 0i64, &Output, 2ui64, 0i64);
      Input |= Output;
    }
    HalpAcpiPmRegisterWrite(PM1A_EVT_REGISTER, 0i64, &Input, 2ui64, 0i64);
    if( *(&CmpDummyThreadEvent + 5136) )
      HalpAcpiPmRegisterWrite(PM1B_EVT_REGISTER, 0i64, &Input, 2ui64, 0i64);
  }
  if( dword_140C4AD1C && *(&CmpDummyThreadEvent + 5040) )
  {
    if( byte_140C4A0F9 )
      HalpHvEnterSleepState();
    HalpAcpiPmRegisterRead(PM1A_CTRL_REGISTER, 0i64, &v0, 2ui64, 0i64);
    v0 = v0 & 0x203 | ((dword_140C4AD1C & 7 | 8) << 10);
    HalpAcpiPmRegisterWrite(PM1A_CTRL_REGISTER, 0i64, &v0, 2ui64, 0i64);
    if( *(&CmpDummyThreadEvent + 5184) )
    {
      HalpAcpiPmRegisterRead(PM1B_CTRL_REGISTER, 0i64, &v0, 2ui64, 0i64);
      v0 = v0 & 0x203 | (((dword_140C4AD1C >> 4) & 7 | 8) << 10);
      HalpAcpiPmRegisterWrite(PM1B_CTRL_REGISTER, 0i64, &v0, 2ui64, 0i64);
    }
  }
  if( byte_140C49D08 )
    HalEfiResetSystem(2i64);
}

Referenced by:

HalReturnToFirmware
HaliHaltSystem
HalpCheckPowerButton