//
// OPENSSL_LH_insert from 0xa21004 to 0xa2127c (632 bytes)
//
// 17 xrefs:
// > SSL_load_client_CA_file @ 0x9a6a00
// > SSL_CTX_add_session @ 0x9b2c48
// > ERR_load_ERR_strings @ 0xa0e3f0
// > ERR_load_ERR_strings @ 0xa0e450
// > ERR_load_ERR_strings @ 0xa0e4b8
// > ERR_load_ERR_strings @ 0xa0e5b8
// > ERR_load_strings @ 0xa0e75c
// > ERR_load_strings @ 0xa0e79c
// > OBJ_NAME_add @ 0xa30778
// > OBJ_add_object @ 0xa30ef0
// > TXT_DB_create_index @ 0xa4df18
// > TXT_DB_create_index @ 0xa4df7c
// > TXT_DB_insert @ 0xa4e240
// > _CONF_add_string @ 0xa8d420
// > _CONF_new_section @ 0xa8d67c
// > engine_table_register @ 0xac9534
// > ??> @ 0x74ebc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:07:55 +0000
//
int __fastcall OPENSSL_LH_insert(int *a1, int a2)
{
unsigned int v3; // r4
unsigned int v5; // r0
int v6; // r8
unsigned int v7; // r10
int v8; // r6
int v9; // r2
int v10; // r4
_DWORD *v11; // r9
int *v12; // r6
unsigned int v13; // r11
int v14; // r1
unsigned int v15; // r0
unsigned int v16; // r1
unsigned int v17; // r9
unsigned int v18; // r1
int (__fastcall *v19)(int, int); // r8
_DWORD *v20; // r4
int **v21; // r6
int v22; // r2
int v23; // r0
int *v24; // r2
int result; // r0
int v26; // r3
int v27; // r0
unsigned int v28; // r11
int v29; // r4
unsigned int v30; // r6
int v31; // r3
int *v32; // r3
int v33; // r1
int v34; // r2
int v35; // r2
int v36; // r3
v3 = a1[3];
v5 = a1[9] << 8;
a1[23] = 0;
if ( a1[7] <= v5 / v3 )
{
v6 = a1[5];
v7 = a1[6];
v8 = *a1;
v9 = a1[10] + 1;
a1[3] = v3 + 1;
a1[10] = v9;
a1[5] = v6 + 1;
*(_DWORD *)(v8 + 4 * (v7 + v6)) = 0;
v10 = *(_DWORD *)(v8 + 4 * v6);
v11 = (_DWORD *)(v8 + 4 * (v7 + v6));
v12 = (int *)(v8 + 4 * v6);
v13 = a1[4];
if ( v10 )
{
do
{
v14 = *(_DWORD *)(v10 + 8) % v13;
if ( v6 == v14 )
v12 = (int *)(v10 + 4);
else
*v12 = *(_DWORD *)(v10 + 4);
if ( v6 != v14 )
{
*(_DWORD *)(v10 + 4) = *v11;
*v11 = v10;
}
v10 = *v12;
}
while ( *v12 );
}
if ( v6 + 1 >= v7 )
{
v27 = CRYPTO_realloc(*a1, 8 * v13, "crypto/lhash/lhash.c", 214);
v28 = 2 * v13;
v29 = v27;
if ( !v27 )
{
v35 = a1[23] + 1;
v36 = a1[3] - 1;
a1[5] = 0;
a1[23] = v35;
a1[3] = v36;
return 0;
}
v30 = a1[4];
if ( v28 > v30 )
memset((void *)(v27 + 4 * v30), 0, 4 * (v28 - v30));
v31 = a1[11] + 1;
a1[6] = v30;
a1[4] = v28;
*a1 = v29;
a1[11] = v31;
a1[5] = 0;
}
}
v15 = ((int (__fastcall *)(int))a1[2])(a2);
v16 = a1[6];
++a1[14];
v17 = v15;
v18 = v15 % v16;
if ( v18 < a1[5] )
v18 = v15 % a1[4];
v19 = (int (__fastcall *)(int, int))a1[1];
v20 = *(_DWORD **)(*a1 + 4 * v18);
v21 = (int **)(*a1 + 4 * v18);
if ( !v20 )
goto LABEL_23;
while ( 1 )
{
v22 = v20[2];
++a1[22];
if ( v17 == v22 )
{
v23 = *v20;
++a1[15];
if ( !v19(v23, a2) )
break;
}
v21 = (int **)(v20 + 1);
v20 = (_DWORD *)v20[1];
if ( !v20 )
goto LABEL_23;
}
v24 = *v21;
if ( *v21 )
{
result = *v24;
v26 = a1[17] + 1;
*v24 = a2;
a1[17] = v26;
}
else
{
LABEL_23:
v32 = (int *)CRYPTO_malloc(12, "crypto/lhash/lhash.c", 83);
if ( v32 )
{
v33 = a1[16] + 1;
v34 = a1[9] + 1;
*v32 = a2;
v32[1] = 0;
v32[2] = v17;
*v21 = v32;
a1[16] = v33;
a1[9] = v34;
}
else
{
++a1[23];
}
return 0;
}
return result;
}