PopStatsNotifyPowerRequestCsState

VOID __fastcall PopStatsNotifyPowerRequestCsState(INT64 a1, CHAR a2){
  INT8 *v2; 
  unsigned int v3; 
  unsigned __int64 v4; 
  INT64 *v5; 
  INT64 *v6; 
  char v7; 
  UINT8 i; 
  void *v9; 
  unsigned int v10; 
  char *v11; 
  INT64 *v12; 
  char v13[8]; 
  v2 = "CS Entry";
  if( !a2 )
    v2 = (INT8 *)"CS Exit";
  PopLogPowerRequestAction(v2, 0i64);
  PopAcquireRwLockExclusive(&PowerReqestStatsLock);
  v3 = 0;
  v4 = 0i64;
  do
  {
    v5 = &ExecutionRequiredStopWatchCollection;
    if( v3 != 3 )
      v5 = 0i64;
    if( v5 && PoIsArmedStopWatchCollection((INT64)v5) )
    {
      PoUnarmStopWatchCollection(v6);
      v7 = 1;
    }
    else
    {
      if( v4 >= 4 )
        _report_rangecheckfailure();
      v7 = 0;
    }
    v13[v4] = v7;
    ++v3;
    ++v4;
  }
  while( v3 <= 3 );
  for( i = 1; ; i = 0 )
  {
    LODWORD(v9) = RtlEnumerateGenericTableAvl(&PowerRequestStatsDatabase, i);
    if( !v9 )
      break;
    PopPublishAndPurgePowerRequestStats(v9);
  }
  v10 = 0;
  v11 = v13;
  do
  {
    if( *v11 )
    {
      v12 = &ExecutionRequiredStopWatchCollection;
      if( v10 != 3 )
        v12 = 0i64;
      PoArmStopWatchCollection(v12);
    }
    ++v10;
    ++v11;
  }
  while( v10 <= 3 );
  PopReleaseRwLock((UINT64)&PowerReqestStatsLock);
}

Referenced by:

PopCaptureSleepStudyStatistics