//
// sub_80E7B4 from 0x80e7b4 to 0x80e88c (216 bytes)
//
// 5 xrefs:
// > CRYPTO_secure_malloc_init @ 0x80ee64
// > CRYPTO_secure_malloc @ 0x80f314
// > CRYPTO_secure_malloc @ 0x80f3a4
// > CRYPTO_secure_malloc @ 0x80f5a4
// > CRYPTO_secure_free @ 0x80fd20
//
// 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_80E7B4(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", 293);
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", 294);
result = v5 / v4 + (1 << v3);
if ( !result || result >= dword_AD44EC )
OPENSSL_die("assertion failed: bit > 0 && bit < sh.bittable_size", "crypto/mem_sec.c", 296);
v7 = *(unsigned __int8 *)(a3 + (result >> 3));
if ( ((v7 >> (result & 7)) & 1) != 0 )
OPENSSL_die("assertion failed: !TESTBIT(table, bit)", "crypto/mem_sec.c", 297);
*(_BYTE *)(a3 + (result >> 3)) = v7 | (1 << (result & 7));
return result;
}