HalpNumaParseHmat

__int64 __fastcall HalpNumaParseHmat(__int64 a1, _QWORD *a2, size_t a3, size_t *a4){
  __int64 v4; 
  _QWORD *v8; 
  size_t v9; 
  unsigned int v10; 
  unsigned int v11; 
  unsigned __int64 v12; 
  INT64 v13; 
  _DWORD *v14; 
  __int64 v15; 
  INT64 *v17; 
  _QWORD *Base; 
  UINT64 v19; 
  int v20; 
  UINT16 Node; 

  v4 = *(&CmpDummyThreadEvent + 873);
  Node = 0;
  Base = 0i64;
  v8 = 0i64;
  v9 = 8;
  v20 = 8;
  if( a3 )
  {
    if( a3 < 8 )
    {
LABEL_3:
      v10 = -1073741789;
LABEL_25:
      if( a3 )
      {
        memset(a2, 0i64, a3);
        if( a4 )
          *a4 = a3;
      }
      return v10;
    }
    *a2 = 0i64;
    v8 = a2 + 1;
    Base = a2 + 1;
  }
  v11 = 0;
  v12 = v4 + *(unsigned int *)(v4 + 4);
  v13 = v4 + 40;
  v14 = (_DWORD *)(v13 + 8);
  if( v13 + 8 <= v12 )
  {
    v17 = v8 + 1;
    do
    {
      v15 = *(unsigned int *)(v13 + 4);
      if( (unsigned int)v15 < 8 || v13 + v15 > v12 )
        break;
      if( !HalpVerifyHmatEntryValidity(v13) )
        goto LABEL_24;
      if( *(_WORD *)v13 == 2 )
      {
        if( HalpNumaQueryProximityNode((unsigned int)*v14, &Node) < 0 )
        {
LABEL_24:
          v10 = -1073741216;
          goto LABEL_25;
        }
        v9 = v20 + 40;
        v20 += 40;
        if( a3 )
        {
          if( a3 < v9 )
            goto LABEL_3;
          ++v11;
          *(_OWORD *)(v17 - 1) = 0i64;
          *(_OWORD *)(v17 + 1) = 0i64;
          v17[3] = 0i64;
          *((_DWORD *)v17 - 2) = Node;
          *((_DWORD *)v17 - 1) = *v14;
          *v17 = *(_QWORD *)(v13 + 16);
          *((_DWORD *)v17 + 2) = *(_DWORD *)(v13 + 24) & 0xF;
          *((_DWORD *)v17 + 3) = (*(_DWORD *)(v13 + 24) >> 4) & 0xF;
          *((_DWORD *)v17 + 4) = (*(_DWORD *)(v13 + 24) >> 8) & 0xF;
          *((_DWORD *)v17 + 5) = (unsigned __int8)HIBYTE(*(_WORD *)(v13 + 24)) >> 4;
          *((_DWORD *)v17 + 6) = *(unsigned __int16 *)(v13 + 26);
          LODWORD(v15) = *(_DWORD *)(v13 + 4);
          v17 += 5;
        }
      }
      else
      {
        v9 = v20;
      }
      v13 += (unsigned int)v15;
      v14 = (_DWORD *)(v13 + 8);
    }
    while( v13 + 8 <= v12 );
  }
  if( a4 )
    *a4 = v9;
  if( a3 )
  {
    *(_DWORD *)a2 = v11;
    if( v11 > 1 )
      qsort((UINT64)Base, v11, 0x28ui64, (INT64)HalpNumaCompareMemorySideCacheEntries, v17, (UINT64)Base, v19);
  }
  return 0;
}

Referenced by:

HalpSetupAcpiPhase0