RtlpHpVaMgrRangeCreate

UINT8 *__stdcall RtlpHpVaMgrRangeCreate(INT64 a1, INT64 a2, INT64 a3){
  unsigned __int64 v3; 
  unsigned __int64 v7; 
  UINT8 *v8; 
  UINT8 *v9; 
  INT64 v11; 
  __int64 v12; 

  v3 = 0i64;
  if( (*(_BYTE *)a3 & 4) != 0 )
    v7 = *(_QWORD *)(a3 + 24);
  else
    v7 = *(unsigned __int16 *)(a3 + 24);
  v8 = RtlSparseArrayElementAllocate(
         *(_QWORD *)(a1 + 24) + 16i64,
         (unsigned __int64)(a2 - *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8i64)) >> 20,
         (const VOID *)a3);
  v9 = v8;
  if( v8 )
  {
    if( (*v8 & 4) != 0 )
      return v9;
    *(_BYTE *)a3 |= 2u;
    v3 = 1i64;
    v11 = a2 + 0x100000;
    *(_BYTE *)(a3 + 1) = *(_BYTE *)(a1 + 44);
    *(_OWORD *)(a3 + 8) = 0i64;
    *(_QWORD *)(a3 + 24) = 2309737967i64;
    if( v7 <= 1 )
      return v9;
    do
    {
      if( !RtlSparseArrayElementAllocate(
              *(_QWORD *)(a1 + 24) + 16i64,
              (unsigned __int64)(v11 - *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8i64)) >> 20,
              (const VOID *)a3) )
        break;
      ++v3;
      v11 += 0x100000i64;
    }
    while( v3 < v7 );
  }
  else
  {
    v9 = 0i64;
  }
  if( v3 < v7 )
  {
    for( ; v3; --v3 )
    {
      v12 = *(_QWORD *)(a1 + 24);
      RtlCSparseBitmapBitsClear(
        v12 + 32,
        8 * ((unsigned __int64)&v9[-*(_QWORD *)(v12 + 40)] >> *(_DWORD *)(v12 + 24) << *(_DWORD *)(v12 + 24)),
        8 * (1i64 << *(_DWORD *)(v12 + 24)));
      v9 += 32;
    }
    return 0i64;
  }
  return v9;
}

Referenced by:

RtlpHpVaMgrAlloc
RtlpHpVaMgrRegionAllocate