KiEnumerateNextProcessorNumber

NTSTATUS __stdcall KiEnumerateNextProcessorNumber(INT64 a1, UINT16 **a2){
  unsigned int v3; 
  UINT16 *v4; 
  unsigned __int64 v5; 
  NTSTATUS result; 

  if( *a2 )
    v3 = **a2;
  else
    v3 = *((unsigned __int16 *)a2 + 8) + 1;
  v4 = a2[1];
  if( v4 )
  {
LABEL_4:
    _BitScanForward64(&v5, (unsigned __int64)v4);
    *(_BYTE *)(a1 + 2) = v5;
    *(_WORD *)a1 = *((_WORD *)a2 + 8);
    result = 0;
    a2[1] = (UINT16 *)((unsigned __int64)v4 & ~(1i64 << v5));
  }
  else
  {
    while( (unsigned __int16)++*((_WORD *)a2 + 8) < v3 )
    {
      v4 = *(UINT16 **)&(*a2)[4 * *((unsigned __int16 *)a2 + 8) + 4];
      a2[1] = v4;
      if( v4 )
        goto LABEL_4;
    }
    return -1073741275;
  }
  return result;
}

Referenced by:

KeGenericProcessorCallback
PoExecuteIdleCheck
PpmIdleSelectStates