PpmUpdatePerformanceFeedback

CHAR __fastcall PpmUpdatePerformanceFeedback(INT64 a1, UINT8 a2, CHAR a3, CHAR a4, INT64 *a5){
  unsigned int v5; 
  bool v7; 
  char v11; 
  __int64 v12; 
  volatile signed __int32 *v13; 
  int v14; 
  INT64 v15; 
  char v16; 
  unsigned int i; 
  char v18; 
  __int16 v19; 
  bool v20; 
  __int64 v21; 
  _QWORD *v22; 
  __int64 v23; 
  __int64 v24; 
  void(__fastcall *v25)(__int64, unsigned int *); 
  __int64 v26; 
  __int64 v27; 
  unsigned __int64 v28; 
  __int64 v29; 
  unsigned __int64 v30; 
  unsigned int v31; 
  __int64 v32; 
  int v33; 
  int v34; 
  unsigned int v35; 
  unsigned int v36; 
  INT64 *v37; 
  __int64 v39; 
  INT64 v40; 
  __int64 v41; 
  __int64 v42; 
  INT64 v43; 
  __int64 v44; 
  __int64 v45; 
  INT64 PpmStatsForProcessor; 
  __int64 v47; 
  __int64 v48; 
  int v49; 
  unsigned __int64 v50; 
  unsigned int v51; 
  v5 = 0;
  v7 = *(_DWORD *)(a1 + 32984) == 3;
  v51 = 0;
  PpmStatsForProcessor = 0i64;
  v43 = 0i64;
  v48 = 0i64;
  if( v7 )
  {
    v11 = 1;
    v12 = *(_QWORD *)(*(_QWORD *)(a1 + 33616) + 8i64 * DWORD2(xmmword_140CED0E0)) >> 1;
  }
  else
  {
    v11 = 0;
    v12 = 0i64;
  }
  v45 = v12;
  v13 = (volatile signed __int32 *)(a1 + 32840);
  if( a2
    || *(_QWORD *)(a1 + 32896)
    || *(_QWORD *)(a1 + 32920)
    && (*(_DWORD *)(a1 + 32392) != *(_DWORD *)(a1 + 32936) || *(_DWORD *)(a1 + 32388) != *(_DWORD *)(a1 + 32940))
    || a3 && v12 != *(_QWORD *)(a1 + 32944) )
  {
    v14 = 2;
    v15 = a1 + 32864;
    v16 = 0;
    for( i = 0; i < 2; ++i )
    {
      if( *(_QWORD *)v15 )
      {
        v18 = *(_BYTE *)(*(_QWORD *)v15 + 32i64);
        if( v18 && a3 )
          return 0;
        if( v18 )
          v16 = 1;
        if( v14 == 2 )
          v14 = i;
      }
      v15 += 8i64;
    }
    if( v16 || a2 || !a4 )
    {
      v19 = v49;
      _disable();
      v20 = (v19 & 0x200) != 0;
      if( _interlockedbittestandset64(v13, 0i64) )
        KxWaitForSpinLockAndAcquire((UINT64 *)(a1 + 32840));
      v21 = _InterlockedExchange64((volatile __int64 *)(a1 + 32896), 0i64);
      if( v11 )
      {
        v44 = 0i64;
        PpmStatsForProcessor = HvlGetPpmStatsForProcessor(a1, &v44, &v43);
        v48 = v44;
        v21 = PpmStatsForProcessor - v44 - *(_QWORD *)(a1 + 32952);
        *(_QWORD *)(a1 + 32952) = PpmStatsForProcessor - v44;
      }
      *(_QWORD *)(a1 + 32888) += v21;
      v22 = (_QWORD *)(a1 + 32904);
      do
      {
        v23 = *(v22 - 5);
        if( v23 )
        {
          v24 = *(_QWORD *)(v23 + 40);
          v7 = *(_BYTE *)(v23 + 33) == 0;
          v42 = 0i64;
          v50 = 0i64;
          v25 = *(void(__fastcall **)(__int64, unsigned int *))v23;
          if( v7 )
          {
            v25(v24, &v51);
            v31 = v51;
          }
          else
          {
            ((void(__fastcall *)(__int64, _QWORD, unsigned __int64 *, __int64 *))v25)(v24, a2, &v50, &v42);
            v26 = *(_QWORD *)(v23 + 16);
            if( v50 != v26 )
            {
              v27 = *(_QWORD *)(v23 + 8);
              v28 = v50 - v26;
              v30 = (v42 - v27) * *(unsigned __int8 *)(v23 + 35);
              v50 = v28;
              v42 -= v27;
              v29 = v42;
              *(_DWORD *)(v23 + 24) = v30 / v28;
              *(_QWORD *)(v23 + 16) = v28 + v26;
              *(_QWORD *)(v23 + 8) = v27 + v29;
            }
            v31 = *(_DWORD *)(v23 + 24);
            v51 = v31;
          }
          v32 = v21 * v31;
          *v22 += v32;
          if( v5 == *(unsigned __int8 *)(a1 + 32976) )
            *(_QWORD *)(a1 + 32920) += v32;
        }
        ++v5;
        ++v22;
      }
      while( v5 < 2 );
      if( *(_BYTE *)(a1 + 32976) == 2 )
        *(_QWORD *)(a1 + 32920) += 100 * v21;
      v33 = *(_DWORD *)(a1 + 32392);
      v34 = *(_DWORD *)(a1 + 32388);
      v35 = v34 - *(_DWORD *)(a1 + 32940);
      v36 = v35 + v33 - *(_DWORD *)(a1 + 32936);
      if( v36 )
      {
        v39 = *(_QWORD *)(a1 + 32920);
        *(_QWORD *)(a1 + 32920) = 0i64;
        *(_DWORD *)(a1 + 32936) = v33;
        *(_DWORD *)(a1 + 32940) = v34;
        if( v35 )
        {
          if( v36 != 1 )
            v35 /= v36;
          v51 = v35;
          *(_QWORD *)(a1 + 32928) += v39 * v35;
        }
      }
      *(_QWORD *)(a1 + 32944) = v45;
      _InterlockedAnd64((volatile signed __int64 *)v13, 0i64);
      if( v20 )
        _enable();
    }
  }
  v37 = a5;
  if( a5 )
  {
    v40 = PpmStatsForProcessor;
    if( PpmStatsForProcessor )
    {
      v41 = v48;
    }
    else
    {
      v47 = 0i64;
      v40 = HvlGetPpmStatsForProcessor(a1, &v47, &v43);
      v41 = v47;
    }
    *v37 = v40;
    v37[2] = v43;
    v37[1] = v41;
  }
  return 1;
}

Referenced by:

PpmContinueActiveTimeAccumulation
PpmIdleExecuteTransition
PpmPerfApplyProcessorState
PpmSnapPerformanceAccumulation