//
// sub_80E9E8 from 0x80e9e8 to 0x80eac0 (216 bytes)
//
// 4 xrefs:
// > CRYPTO_secure_malloc @ 0x80f4d4
// > CRYPTO_secure_free @ 0x80f9f8
// > CRYPTO_secure_free @ 0x80fb48
// > CRYPTO_secure_free @ 0x80fc2c
//
// 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_80E9E8(int a1, int a2, int a3)
{
char v3; // r4
unsigned int v4; // r1
unsigned int v5; // r0
unsigned int result; // r0
unsigned int v7; // r3
v3 = a2;
if ( a2 < 0 || a2 >= dword_AD44DC )
OPENSSL_die("assertion failed: list >= 0 && list < sh.freelist_size", "crypto/mem_sec.c", 281);
v4 = (unsigned int)dword_AD44D4 >> a2;
v5 = a1 - dword_AD44D0;
if ( ((v4 - 1) & v5) != 0 )
OPENSSL_die("assertion failed: ((ptr - sh.arena) & ((sh.arena_size >> list) - 1)) == 0", "crypto/mem_sec.c", 282);
result = v5 / v4 + (1 << v3);
if ( !result || result >= dword_AD44EC )
OPENSSL_die("assertion failed: bit > 0 && bit < sh.bittable_size", "crypto/mem_sec.c", 284);
v7 = *(unsigned __int8 *)(a3 + (result >> 3));
if ( ((v7 >> (result & 7)) & 1) == 0 )
OPENSSL_die("assertion failed: TESTBIT(table, bit)", "crypto/mem_sec.c", 285);
*(_BYTE *)(a3 + (result >> 3)) = v7 & ~(1 << (result & 7));
return result;
}