PopFxIdleComponent

void __fastcall PopFxIdleComponent(ULONG_PTR BugCheckParameter2, ULONG_PTR BugCheckParameter3, char a3, int *a4){
  UINT64 v4; 
  unsigned int v5; 
  UINT64 v9; 
  UINT64 v10; 
  __int64 v11; 
  UINT64 v12; 
  __int64 CurrentQpc[2]; 
  UINT64 PreviousTime; 
  v4 = 0i64;
  v5 = BugCheckParameter3;
  PreviousTime = 0i64;
  if( (a3 & 3) == 3 )
    PopFxBugCheck(0x614ui64, BugCheckParameter2, (unsigned int)BugCheckParameter3, 1ui64);
  if( (unsigned int)BugCheckParameter3 >= *(_DWORD *)(BugCheckParameter2 + 828) )
    PopFxBugCheck(0x614ui64, BugCheckParameter2, (unsigned int)BugCheckParameter3, 2ui64);
  _mm_lfence();
  v9 = *(_QWORD *)(*(_QWORD *)(BugCheckParameter2 + 832) + 8i64 * (unsigned int)BugCheckParameter3);
  if( PopFxActiveIdleLevel == 2 )
  {
    LODWORD(v12) = RtlGetInterruptTimePrecise(CurrentQpc);
    PpmInterlockedUpdateTimeNoFence((UINT64 *)(v9 + 144), v12, &PreviousTime);
  }
  else
  {
    PreviousTime = *(_QWORD *)(v9 + 144);
  }
  if( (*(_DWORD *)(v9 + 88) & 0x3FFFFFFF) == 0 )
    PopFxBugCheck(0x608ui64, v9, *(int *)(v9 + 88), 0i64);
  if( _InterlockedDecrement((volatile signed __int32 *)(v9 + 88)) == 0x80000000 )
  {
    if( !v4 )
    {
      LODWORD(v10) = RtlGetInterruptTimePrecise(CurrentQpc);
      v4 = v10;
    }
    v11 = *(unsigned int *)(v9 + 92);
    if( (v11 & 2) == 0 && !*(_BYTE *)PopFxLowPowerEpoch )
    {
      v11 = (unsigned int)PopFxActiveIdleThreshold;
      if( v4 - PreviousTime < (unsigned int)PopFxActiveIdleThreshold )
      {
        v11 = 2147483649i64;
        if( _InterlockedCompareExchange((volatile signed __int32 *)(v9 + 88), -2147483647, 0x80000000) != 0x80000000 )
          return;
        if( _InterlockedIncrement((volatile signed __int32 *)(v9 + 96)) == 1 )
        {
          if( _InterlockedIncrement(&PopFxResidentComponentCount) == 1 )
            PopFxArmResidentTimer(0);
          return;
        }
        _InterlockedDecrement((volatile signed __int32 *)(v9 + 96));
        _InterlockedDecrement((volatile signed __int32 *)(v9 + 88));
      }
    }
    if( PopFxActiveIdleLevel == 1 )
      PpmInterlockedUpdateTimeNoFence((UINT64 *)(v9 + 144), v4, 0i64);
    if( (a3 & 2) != 0 )
      PopFxQueueWorkOrder(v11, v9 + 24, BugCheckParameter2);
    else
      PopFxIdleWorker((__int64 *)BugCheckParameter2, v5, a4);
  }
}

Referenced by:

PoFxIdleComponent
PopFxCompleteComponentActivation
PopFxResidentTimeoutRoutine