RtlpHpVaMgrCtxStart

void __fastcall RtlpHpVaMgrCtxStart(INT64 a1, int a2, __int64 a3, unsigned __int64 a4){
  unsigned int v7; 
  unsigned __int64 v8; 
  unsigned int v9; 
  NTSTATUS v10; 
  int v11; 
  UINT64 v12; 
  INT64 v13; 
  __int128 v14; 
  UINT64 pullResult; 

  pullResult = 0i64;
  _BitScanForward(&v7, 0x20u);
  *(_DWORD *)(a1 + 24) = v7;
  v8 = (a4 >> 20) + 1;
  if( (a4 & 0xFFFFF) == 0 )
    v8 = a4 >> 20;
  if( RtlULongLongMult(v8, 8ui64, &pullResult) >= 0 && RtlULongLongMult(pullResult, v9, &pullResult) >= 0 )
  {
    v10 = RtlCSparseBitmapStart(a1 + 32, pullResult, a2, 1i64);
    if( v10 >= 0 )
      v10 = 0;
    if( v10 >= 0 )
    {
      LODWORD(v13) = -1;
      *(_DWORD *)a1 = a2;
      v11 = 0;
      *(_QWORD *)(a1 + 8) = a3;
      v14 = 0i64;
      do
      {
        HIDWORD(v13) = v11;
        v12 = 0x200000i64;
        if( v11 != 2 && v11 == 3 )
          v12 = 0x40000000i64;
        if( RtlpHpVaMgrCtxAllocatorReference(a1, (INT64)&v13, v12) < 0 )
          break;
        ++v11;
      }
      while( v11 < 4 );
    }
  }
}

Referenced by:

RtlHpHeapManagerStart