RtlpHpSegContextReserve

NTSTATUS __stdcall RtlpHpSegContextReserve(INT64 a1, INT64 a2, INT64 a3){
  unsigned __int64 v3; 
  NTSTATUS v5; 
  unsigned __int64 v6; 
  unsigned int v7; 
  unsigned int v9; 
  INT64 v10; 
  UINT64 v11; 

  v3 = (unsigned __int64)(a3 + 4095) >> 12;
  v5 = 0;
  v6 = ((unsigned __int64)(unsigned int)-*(_DWORD *)a1 + a2 - 1) / (unsigned int)-*(_DWORD *)a1;
  v7 = (256 - *(unsigned __int8 *)(a1 + 10)) << *(_BYTE *)(a1 + 9);
  if( v6 )
  {
    while( 1 )
    {
      v9 = v3;
      if( v3 > v7 )
        v9 = v7;
      v3 = (v3 - v7) & -(__int64)(v7 < v3);
      LODWORD(v10) = RtlpHpSegSegmentAllocate(a1, v9, 0i64);
      v11 = v10;
      if( !v10 )
        break;
      RtlpHpSegSegmentInitialize(a1, v10, v9);
      RtlpHpSegFreeRangeInsert(a1, v11 + 32i64 * *(unsigned __int8 *)(a1 + 10), 1i64);
      RtlpHpSegHeapAddSegment(a1, v11);
      if( !--v6 )
        return v5;
    }
    return -1073741670;
  }
  return v5;
}

Referenced by:

RtlpHpHeapCreate