PpmCheckComputeHeteroResponse

UINT8 __stdcall PpmCheckComputeHeteroResponse(){
  __int64 v0; 
  unsigned int v1; 
  int v2; 
  __int64 v3; 
  int Affinity; 
  __int16 v5; 
  __int64 v6; 
  __int64 v7; 
  unsigned int v8; 
  int v9; 
  __int64 v10; 
  _KPRCB *Prcb; 
  UINT64 Utility; 
  unsigned int v13; 
  __int64 v14; 
  UINT64 v15; 
  __int64 v16; 
  __int64 v17; 
  __int64 v18; 
  _QWORD *v19; 
  __int64 v20; 
  __int64 v21; 
  unsigned int v22; 
  unsigned int v23; 
  int v24; 
  int v25; 
  unsigned int v26; 
  char v27; 
  bool v28; 
  INT64 *v30; 
  __int64 v31; 
  UINT64 v32; 
  UINT64 ProcIndex; 
  _KAFFINITY_ENUMERATION_CONTEXT Context; 
  __int64 v35; 
  int Base[64]; 
  __int64 ConcurrentUtilityTime[64]; 

  v35 = 0i64;
  *(_OWORD *)&Context.CurrentMask = 0i64;
  v0 = *(&stru_140C00F40 + 365) + 2736i64 * *(&stru_140C23628 + 441);
  if( PpmHeteroPolicy != 4 )
  {
LABEL_43:
    PpmParkCalculateUnparkCount();
    return 1;
  }
  v1 = 0;
  LODWORD(Context.Affinity) = 0;
  if( (_DWORD)PpmParkNumNodes )
  {
    while( 1 )
    {
      v2 = 0;
      v3 = PpmParkNodes + 272i64 * v1;
      if( *(_BYTE *)(v3 + 129) )
        break;
      Affinity = 1;
      LODWORD(Context.Affinity) = 1;
LABEL_41:
      if( ++v1 >= (unsigned int)PpmParkNumNodes )
      {
        if( Affinity )
          goto LABEL_43;
        return 1;
      }
    }
    v5 = *(_WORD *)(v3 + 4);
    v6 = 0i64;
    v7 = *(_QWORD *)(v3 + 8);
    LODWORD(ProcIndex) = 0;
    Context.CurrentMask = 0i64;
    v8 = *(unsigned __int8 *)(v3 + 139);
    LOWORD(v35) = v5;
    *(_QWORD *)&Context.CurrentIndex = v7;
    while( 1 )
    {
      KeEnumerateNextProcessor(&ProcIndex, (_KAFFINITY_ENUMERATION_CONTEXT *)&Context.CurrentMask);
      if( v9 )
        break;
      v10 = (unsigned int)ProcIndex;
      Prcb = KeGetPrcb((unsigned int)ProcIndex);
      Utility = Prcb->PowerState.CheckContext.Utility;
      if( *(&PopIrpWorkerControlEvent + 313) != 5 )
        Utility = (unsigned int)(Utility - Prcb->PowerState.CheckContext.MediaUtility);
      v13 = PpmHeteroUtilityToNormalizedUtility((INT64)&Prcb->PowerState.CheckContext, Utility);
      v6 += v13;
      Base[v10] = v13;
      LODWORD(ProcIndex) = v10 + 1;
    }
    qsort((UINT64)Base, (unsigned int)ProcIndex, 4ui64, (INT64)PpmUtilityComparer, v30, v32, ProcIndex);
    v14 = *(unsigned __int8 *)(v3 + 6);
    v15 = 0i64;
    v16 = *(_QWORD *)(v3 + 96);
    v17 = 0i64;
    ProcIndex = 0i64;
    if( (_DWORD)v14 )
    {
      v18 = (unsigned int)v14;
      v19 = (_QWORD *)(v16 + 8 * v14);
      do
      {
        v17 += v6 * *v19;
        v20 = v18;
        v14 = (unsigned int)(v14 - 1);
        --v18;
        ConcurrentUtilityTime[v14] = v17;
        v21 = *v19-- * v20;
        v15 += v21;
      }
      while( (_DWORD)v14 );
      ProcIndex = v15;
    }
    v22 = *(unsigned __int8 *)(v3 + 129);
    v23 = v8;
    if( v8 >= v22 )
      goto LABEL_21;
    do
    {
      if( !(unsigned int)PpmHeteroUtilityGreaterThanOrEqualThreshold(
                            v15,
                            (unsigned int)Base[v23],
                            ConcurrentUtilityTime[v23],
                            *(unsigned __int8 *)(v23 + v0 + 1481)) )
        break;
      v15 = ProcIndex;
      ++v23;
    }
    while( v23 < v22 );
    if( v23 <= v8 )
    {
      do
      {
        v15 = ProcIndex;
LABEL_21:
        if( !v23 )
          goto LABEL_24;
        v25 = v23--;
      }
      while( !(unsigned int)PpmHeteroUtilityGreaterThanOrEqualThreshold(
                               v15,
                               (unsigned int)Base[v23],
                               ConcurrentUtilityTime[v23],
                               *(unsigned __int8 *)(v23 + v0 + 201)) );
      v23 = v25;
LABEL_24:
      v24 = v23 < v8;
    }
    else
    {
      v24 = 2;
    }
    if( *(char *)(v3 + 148) == v24 )
    {
      v26 = (unsigned __int8)++*(_BYTE *)(v3 + 147);
    }
    else
    {
      v26 = 1;
      *(_BYTE *)(v3 + 148) = v24;
      *(_BYTE *)(v3 + 147) = 1;
      v2 = 4;
    }
    if( *(&PopIrpWorkerControlEvent + 313) == 5 )
    {
      v2 |= 0x10u;
LABEL_36:
      *(_BYTE *)(v3 + 139) = v23;
      goto LABEL_37;
    }
    if( v24 == 2 )
    {
      if( v26 >= *(unsigned __int8 *)(v0 + 200) )
      {
        v2 |= 0x20u;
        goto LABEL_36;
      }
    }
    else if( v24 == 1 && v26 >= *(unsigned __int8 *)(v0 + 199) )
    {
      v2 |= 0x40u;
      goto LABEL_36;
    }
LABEL_37:
    v27 = *(_BYTE *)(v3 + 146) | 6;
    v28 = *(_BYTE *)(v3 + 139) == 0;
    *(_BYTE *)(v3 + 146) = v27;
    if( v28 )
    {
      Affinity = 1;
      *(_BYTE *)(v3 + 146) = v27 & 0xFD;
      LODWORD(Context.Affinity) = 1;
    }
    else
    {
      Affinity = (int)Context.Affinity;
    }
    LODWORD(v32) = v2 | (2 - (Affinity != 0));
    LOBYTE(v31) = v23;
    PpmEventTraceHeteroResponse(v3, (__int64)Base, (__int64)ConcurrentUtilityTime, ProcIndex, v31);
    goto LABEL_41;
  }
  return 1;
}

Referenced by:

No references.