HalpNumaParseHmat

INT64 __fastcall HalpNumaParseHmat(INT64 a1, _QWORD *a2, UINT64 a3, UINT64 *a4){
  __int64 v4; 
  unsigned int v6; 
  _QWORD *v8; 
  unsigned int v9; 
  unsigned int v10; 
  unsigned int v11; 
  unsigned __int64 v12; 
  INT64 v13; 
  _DWORD *v14; 
  __int64 v15; 
  _QWORD *v17; 
  WCHAR *Base; 
  int v19; 
  UINT16 Node; 
  v4 = HalpAcpiHmat;
  v6 = a3;
  Node = 0;
  Base = 0i64;
  v8 = 0i64;
  v9 = 8;
  v19 = 8;
  if( (_DWORD)a3 )
  {
    if( (unsigned int)a3 < 8 )
    {
LABEL_3:
      v10 = -1073741789;
LABEL_25:
      if( v6 )
      {
        memset((INT64)a2, 0i64);
        if( a4 )
          *(_DWORD *)a4 = v6;
      }
      return v10;
    }
    *a2 = 0i64;
    v8 = a2 + 1;
    Base = (WCHAR *)(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 = v19 + 40;
        v19 += 40;
        if( v6 )
        {
          if( v6 < 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 = v19;
      }
      v13 += (unsigned int)v15;
      v14 = (_DWORD *)(v13 + 8);
    }
    while( v13 + 8 <= v12 );
  }
  if( a4 )
    *(_DWORD *)a4 = v9;
  if( v6 )
  {
    *(_DWORD *)a2 = v11;
    if( v11 > 1 )
      qsort(Base, v11, (const WCHAR *)0x28, HalpNumaCompareMemorySideCacheEntries);
  }
  return 0;
}

Referenced by:

HalpSetupAcpiPhase0