PopDeepSleepResiliencyPhaseAccountingUpdate

INT64 __fastcall PopDeepSleepResiliencyPhaseAccountingUpdate(INT64 a1, CHAR a2){
  __int64 v2; 
  unsigned int v3; 
  unsigned int v5; 
  int v6; 
  __int16 v7; 
  unsigned __int8 v8; 
  unsigned __int64 v9; 
  INT64 result; 
  LARGE_INTEGER PerformanceCounter; 
  LARGE_INTEGER v12; 
  INT64 *v13; 
  v2 = (int)a1;
  v3 = 0;
  v5 = 0;
  v6 = 1 << a1;
  KeAcquireSpinLockRaiseToDpc(&PopCsResiliencyStatsLock, a2);
  v7 = dword_140C22FDC;
  v9 = v8;
  if( (v6 & dword_140C22FDC) != 0 )
  {
    PerformanceCounter = KeQueryPerformanceCounter(0i64);
    v13 = &PopCsResiliencyStats + v2;
    if( !a2 )
    {
      *(&PopCsResiliencyStats + v2 + 30) += PerformanceCounter.QuadPart - v13[20];
      PerformanceCounter.QuadPart = 0i64;
    }
    v13[20] = PerformanceCounter.QuadPart;
    if( a2 )
    {
      if( (v6 & 3) != 0 )
      {
        if( (v7 & 0x40) != 0 )
          v5 = 64;
        if( (v7 & 0x3BC) != 0 )
          v5 |= 0x3BCu;
      }
      else if( (v6 & 0x40) != 0 && (v7 & 0x3BC) != 0 )
      {
        v5 = 956;
      }
      PopDeepSleepResiliencyPhaseAccountingEnd(v5, 1);
    }
    else
    {
      if( (v6 & 3) != 0 )
      {
        if( (PopDeepSleepDisengageReasonMask & 3) == 0 )
        {
          v3 = 64;
          if( (PopDeepSleepDisengageReasonMask & 0x40) == 0 )
            v3 = 1020;
        }
      }
      else if( (v6 & 0x40) != 0 && (PopDeepSleepDisengageReasonMask & 0x40) == 0 )
      {
        v3 = 956;
      }
      LOBYTE(v12.LowPart) = 1;
      PopDeepSleepResiliencyPhaseAccountingBegin((_TOKEN *)v3, (_TOKEN *)v12.QuadPart);
    }
  }
  KxReleaseSpinLock(&PopCsResiliencyStatsLock);
  result = (unsigned int)KiIrqlFlags;
  __writecr8(v9);
  return result;
}

Referenced by:

PopDeepSleepClearDisengageReason
PopDeepSleepSetDisengageReason