//
// sub_80EAF0 from 0x80eaf0 to 0x80ec64 (372 bytes)
//
// 2 xrefs:
// > CRYPTO_secure_malloc @ 0x80f634
// > CRYPTO_secure_free @ 0x80f918
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
unsigned int __fastcall sub_80EAF0(unsigned int a1)
{
unsigned int v2; // r0
int i; // r4
unsigned int v4; // r0
if ( dword_AD44D0 > a1 || a1 >= dword_AD44D0 + dword_AD44D4 )
OPENSSL_die("assertion failed: WITHIN_ARENA(ptr)", "crypto/mem_sec.c", 574);
v2 = (a1 + dword_AD44D4 - dword_AD44D0) / dword_AD44E0;
for ( i = dword_AD44DC - 1; v2 && ((*(unsigned __int8 *)(dword_AD44E4 + (v2 >> 3)) >> (v2 & 7)) & 1) == 0; --i )
{
if ( (v2 & 1) != 0 )
OPENSSL_die("assertion failed: (bit & 1) == 0", "crypto/mem_sec.c", 259);
v2 >>= 1;
}
if ( (dword_AD44DC <= i) | ((unsigned int)i >> 31) )
OPENSSL_die("assertion failed: list >= 0 && list < sh.freelist_size", "crypto/mem_sec.c", 270);
if ( ((((unsigned int)dword_AD44D4 >> i) - 1) & (a1 - dword_AD44D0)) != 0 )
sub_2B44A0();
v4 = (a1 - dword_AD44D0) / ((unsigned int)dword_AD44D4 >> i) + (1 << i);
if ( !v4 || v4 >= dword_AD44EC )
OPENSSL_die("assertion failed: bit > 0 && bit < sh.bittable_size", "crypto/mem_sec.c", 273);
if ( (*(unsigned __int8 *)(dword_AD44E4 + (v4 >> 3)) & (1 << (v4 & 7))) == 0 )
OPENSSL_die("assertion failed: sh_testbit(ptr, list, sh.bittable)", "crypto/mem_sec.c", 578);
return (unsigned int)dword_AD44D4 >> i;
}