//
// ENGINE_add from 0xd9da24 to 0xd9dbf0 (460 bytes)
//
// 4 xrefs:
// > sub_E5D098 @ 0xe5d52c
// > engine_load_dynamic_int @ 0xe5d8b0
// > engine_load_openssl_int @ 0xe5e0d8
// > ??> @ 0x971e8
//
// 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
//
__int64 __fastcall ENGINE_add(__int64 a1)
{
__int64 v2; // x19
const char *v3; // x20
int v4; // w0
__int64 v5; // x0
unsigned int v6; // w19
int v8; // w0
if ( !a1 )
{
ERR_put_error(38, 105, 67, "crypto/engine/eng_list.c", 219);
return 0;
}
if ( !*(_QWORD *)a1 || !*(_QWORD *)(a1 + 8) )
{
ERR_put_error(38, 105, 108, "crypto/engine/eng_list.c", 223);
return 0;
}
CRYPTO_THREAD_write_lock(global_engine_lock);
v2 = qword_125D600;
if ( !qword_125D600 )
{
if ( qword_125D608 )
{
ERR_put_error(38, 120, 110, "crypto/engine/eng_list.c", 74);
goto LABEL_11;
}
*(_QWORD *)(a1 + 176) = 0;
qword_125D600 = a1;
engine_cleanup_add_last((__int64)sub_D9DD30);
LABEL_17:
v8 = *(_DWORD *)(a1 + 156);
v6 = 1;
*(_QWORD *)(a1 + 184) = 0;
*(_DWORD *)(a1 + 156) = v8 + 1;
qword_125D608 = a1;
goto LABEL_12;
}
v3 = *(const char **)a1;
do
{
v4 = strcmp(*(const char **)v2, v3);
v2 = *(_QWORD *)(v2 + 184);
}
while ( (v2 != 0) > (unsigned int)(v4 == 0) );
if ( !v4 )
{
ERR_put_error(38, 120, 103, "crypto/engine/eng_list.c", 68);
goto LABEL_11;
}
v5 = qword_125D608;
if ( qword_125D608 && !*(_QWORD *)(qword_125D608 + 184) )
{
*(_QWORD *)(qword_125D608 + 184) = a1;
*(_QWORD *)(a1 + 176) = v5;
goto LABEL_17;
}
ERR_put_error(38, 120, 110, "crypto/engine/eng_list.c", 86);
LABEL_11:
v6 = 0;
ERR_put_error(38, 105, 110, "crypto/engine/eng_list.c", 228);
LABEL_12:
CRYPTO_THREAD_unlock(global_engine_lock);
return v6;
}