ExInitializePoolHeapManagement

int __fastcall ExInitializePoolHeapManagement(unsigned int a1){
  int result; 
  unsigned int v3; 
  __int128 v4; 
  INT64 v5; 
  __int64 *v6; 
  bool v7; 
  __int64 v8; 
  __int64 v9; 
  __int64 v10; 
  __int64 v11; 
  __int128 v12; 
  __int128 v13; 
  __int128 v14; 
  __int128 v15; 
  __int128 v16; 
  __int128 v17; 
  INT64 v18[2]; 
  __int64 v19; 
  __int64 v20; 

  v20 = 0i64;
  v19 = 0i64;
  *(_OWORD *)v18 = 0i64;
  result = RtlHpKInitializeHeapManager();
  if( result >= 0 )
  {
    RtlpHpLfhPerfFlags = 1279;
    ExpDetermineLargePagePolicy((INT64)v18);
    v3 = 0;
    if( dword_140C57DD0 )
    {
      v4 = *(_OWORD *)v18;
      while( 1 )
      {
        v5 = 0i64;
        v12 = 0i64;
        LOWORD(v12) = 259;
        v6 = &qword_140C57E00[1048 * v3];
        BYTE2(v12) = v3;
        v14 = v12;
        if( v18[1] )
          v5 = 0x4000000i64;
        result = ExCreateHeap((__int64)&v14, v5, &v20);
        if( result < 0 )
          break;
        v7 = v18[1] == 0;
        v8 = v20;
        v6[1] = v20;
        if( !v7 )
        {
          v9 = v19;
          *(_OWORD *)(v8 + 192) = v4;
          *(_QWORD *)(v8 + 208) = v9;
          *(_BYTE *)(v8 + 269) = *(_BYTE *)(v8 + 269) & 0xF8 | 1;
          *(_BYTE *)(v8 + 461) = *(_BYTE *)(v8 + 461) & 0xF8 | 1;
        }
        RtlpDynamicLookasideInitialize((char *)v6 + 4224);
        *(_QWORD *)(v8 + 40) = v6 + 528;
        v15 = v12;
        result = ExCreateHeap((__int64)&v15, 0x40000000i64, &v20);
        if( result < 0 )
          break;
        ++v3;
        *v6 = v20;
        if( v3 >= dword_140C57DD0 )
          goto LABEL_11;
      }
    }
    else
    {
LABEL_11:
      v13 = 0i64;
      *(_WORD *)((char *)&v13 + 1) = 1;
      LOBYTE(v13) = 3;
      v16 = v13;
      result = ExCreateHeap((__int64)&v16, 0i64, &v20);
      if( result >= 0 )
      {
        v10 = v20;
        v17 = v13;
        *(_DWORD *)(v20 + 816) |= 2u;
        *(_BYTE *)(v10 + 269) |= 8u;
        *(_BYTE *)(v10 + 461) |= 8u;
        qword_140CDAE08 = v10;
        result = ExCreateHeap((__int64)&v17, 0x40000000i64, &v20);
        if( result >= 0 )
        {
          v11 = v20;
          *(_DWORD *)(v20 + 816) |= 2u;
          *(_BYTE *)(v11 + 269) |= 8u;
          *(_BYTE *)(v11 + 461) |= 8u;
          qword_140CDAE00[0] = v11;
          result = ExInitializePoolTracker();
          if( result >= 0 )
            _InterlockedOr(&ExpPoolFlags, a1);
        }
      }
    }
  }
  return result;
}

Referenced by:

MiInitNucleus