RtlpHpSegDescriptorValidate

UINT64 __stdcall RtlpHpSegDescriptorValidate(INT64 a1, UINT64 a2){
  UINT64 v3; 
  char v4; 
  UINT64 result; 
  char v6; 
  char v7; 

  v3 = a2 & *(_QWORD *)a1;
  if( (a1 ^ v3 ^ (unsigned __int64)RtlpHpHeapGlobals ^ *(_QWORD *)(v3 + 0x10)) != 0xA2E64EADA2E64EADui64 )
    return 0i64;
  v4 = *(_BYTE *)(a1 + 8);
  result = v3 + 32 * ((unsigned __int64)(unsigned int)(a2 - v3) >> v4);
  if( !result )
    return 0i64;
  v6 = *(_BYTE *)(result + 24);
  if( (v6 & 1) == 0 )
    return 0i64;
  if( (v6 & 2) == 0 )
  {
    result -= 32i64 * *(unsigned __int8 *)(result + 31);
    v7 = *(_BYTE *)(result + 24);
    if( (v7 & 3) == 3 && (v7 & 0xCu) >= 8 )
      return result;
    return 0i64;
  }
  if( (v6 & 0xCu) < 8 && (((1 << v4) - 1) & a2) != 0 )
    return 0i64;
  return result;
}

Referenced by:

RtlpHpMetadataCommit
RtlpHpSegFree
RtlpHpSegLfhVsDecommit
RtlpHpSegSetExtraPresent
RtlpHpSizeHeapInternal