//
// CRYPTO_secure_actual_size from 0xdb70a4 to 0xdb7238 (404 bytes)
//
// 1 xrefs:
// > ??> @ 0x357f0
//
// 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 __int64 __fastcall CRYPTO_secure_actual_size(unsigned __int64 a1)
{
unsigned __int64 v2; // x1
int v3; // w4
__int64 v4; // x5
unsigned __int64 v5; // x19
unsigned __int64 v6; // x20
unsigned __int64 v7; // x20
CRYPTO_THREAD_write_lock(qword_125F160);
if ( a1 < qword_125F118 || a1 >= qword_125F118 + qword_125F120 )
OPENSSL_die("assertion failed: WITHIN_ARENA(ptr)", "crypto/mem_sec.c", 574);
v2 = (a1 + qword_125F120 - qword_125F118) / qword_125F138;
v3 = qword_125F130 - 1;
if ( v2 )
{
v4 = qword_125F140;
if ( ((*(unsigned __int8 *)(qword_125F140 + (v2 >> 3)) >> (v2 & 7)) & 1) == 0 )
{
do
{
if ( (v2 & 1) != 0 )
OPENSSL_die("assertion failed: (bit & 1) == 0", "crypto/mem_sec.c", 259);
v2 >>= 1;
--v3;
}
while ( v2 && ((*(unsigned __int8 *)(qword_125F140 + (v2 >> 3)) >> (v2 & 7)) & 1) == 0 );
}
}
else
{
v4 = qword_125F140;
}
if ( v3 < 0 || qword_125F130 <= v3 )
OPENSSL_die("assertion failed: list >= 0 && list < sh.freelist_size", "crypto/mem_sec.c", 270);
v5 = (unsigned __int64)qword_125F120 >> v3;
v6 = a1 - qword_125F118;
if ( ((((unsigned __int64)qword_125F120 >> v3) - 1) & v6) != 0 )
sub_4DEEEC();
v7 = v6 / v5 + (1LL << v3);
if ( !v7 || v7 >= qword_125F150 )
OPENSSL_die("assertion failed: bit > 0 && bit < sh.bittable_size", "crypto/mem_sec.c", 273);
if ( (*(unsigned __int8 *)(v4 + (v7 >> 3)) & (unsigned int)(1LL << (v7 & 7))) == 0 )
OPENSSL_die("assertion failed: sh_testbit(ptr, list, sh.bittable)", "crypto/mem_sec.c", 578);
CRYPTO_THREAD_unlock(qword_125F160);
return v5;
}