HalpGetNumaProcMemoryCount

NTSTATUS __stdcall HalpGetNumaProcMemoryCount(
        UINT64 *NodeCount,
        UINT64 *ProcCount,
        UINT64 *MemoryRangeCount,
        UINT64 *ChannelCount){
  unsigned __int64 Length; 
  __int64 v5; 
  int v6; 
  _ACPI_SRAT_ENTRY *v10; 
  unsigned __int64 v12; 
  __int64 v13; 
  unsigned __int8 *v14; 
  int v15; 
  unsigned int v16; 
  unsigned int i; 
  unsigned int v18; 
  UINT64 *v19; 
  __int64 v20; 
  unsigned int v21; 
  UINT64 NodeCapacity[32]; 
  UINT64 ProximityId[32]; 

  v5 = *(&CmpDummyThreadEvent + 869);
  v6 = 0;
  *(_DWORD *)NodeCount = 0;
  *(_DWORD *)MemoryRangeCount = 0;
  *(_DWORD *)ProcCount = 0;
  *(_DWORD *)ChannelCount = 0;
  v10 = (_ACPI_SRAT_ENTRY *)(v5 + 48);
  v12 = v5 + *(unsigned int *)(v5 + 4);
  while( (unsigned __int64)&v10->ApicAffinity <= v12 )
  {
    Length = v10->Length;
    if( (unsigned __int8)Length < 2u )
      break;
    Length += (unsigned __int64)v10;
    if( Length > v12 )
      break;
    LODWORD(Length) = HalpVerifySratEntryLengthAndFlag(v10);
    if( !(_BYTE)Length )
      goto LABEL_22;
    if( *(_BYTE *)(v5 + 8) == 1 )
    {
      v15 = *v14;
    }
    else if( *(_BYTE *)v13 )
    {
      if( *(_BYTE *)v13 == 2 )
        v15 = *(_DWORD *)(v13 + 4);
      else
        v15 = *(_DWORD *)v14;
    }
    else
    {
      LODWORD(Length) = *v14;
      v15 = Length
          + ((*(unsigned __int8 *)(v13 + 9)
            + ((*(unsigned __int8 *)(v13 + 10) + (*(unsigned __int8 *)(v13 + 11) << 8)) << 8)) << 8);
    }
    v16 = *(_DWORD *)NodeCount;
    for( i = 0; i < v16; ++i )
    {
      LODWORD(Length) = i;
      if( v15 == *((_DWORD *)ProximityId + i) )
        break;
    }
    if( i == v16 )
    {
      if( i == 64 )
        goto LABEL_36;
      *((_DWORD *)ProximityId + i) = v15;
      *((_DWORD *)NodeCapacity + i) = 0;
      *(_DWORD *)NodeCount = v16 + 1;
    }
    if( !*(_BYTE *)v13 )
      goto LABEL_21;
    if( *(_BYTE *)v13 != 1 )
    {
      if( *(_BYTE *)v13 != 2 )
        goto LABEL_22;
LABEL_21:
      ++*(_DWORD *)ProcCount;
      ++*((_DWORD *)NodeCapacity + i);
      goto LABEL_22;
    }
    ++*(_DWORD *)MemoryRangeCount;
LABEL_22:
    Length = *(unsigned __int8 *)(v13 + 1);
    v10 = (_ACPI_SRAT_ENTRY *)(Length + v13);
  }
  if( *(_DWORD *)MemoryRangeCount && *(_DWORD *)ProcCount )
  {
    if( *(&CmpDummyThreadEvent + 877) )
      HalpUpdateConfigurationFromMsct(NodeCount, 0x40ui64, ProcCount, 0i64, 0i64, ProximityId, NodeCapacity, 0i64);
    v18 = *(_DWORD *)NodeCount;
    if( *(_DWORD *)NodeCount )
    {
      v19 = NodeCapacity;
      v20 = v18;
      do
      {
        LODWORD(Length) = *(_DWORD *)v19;
        if( *(_DWORD *)v19 > (unsigned int)HalpMaximumGroupSize )
        {
          LODWORD(Length) = (HalpMaximumGroupSize + (int)Length - 1) / (unsigned int)HalpMaximumGroupSize;
          v6 = Length + v6 - 1;
        }
        v19 = (UINT64 *)((char *)v19 + 4);
        --v20;
      }
      while( v20 );
    }
    v21 = v6 + v18;
    *(_DWORD *)NodeCount = v21;
    if( v21 <= 0x40 )
    {
      LODWORD(Length) = HalpParseChannelCount();
      *(_DWORD *)ChannelCount = Length;
      LOBYTE(Length) = 1;
      return Length;
    }
  }
LABEL_36:
  LOBYTE(Length) = 0;
  return Length;
}

Referenced by:

HalpNumaInitializeStaticConfiguration
HalpNumaSwapP0NodeToFront