//
// OPENSSL_sk_insert from 0x8386cc to 0x8387b0 (228 bytes)
//
// 10 xrefs:
// > SSL_dane_tlsa_add @ 0x7961ac
// > engine_cleanup_add_first @ 0x7f75f0
// > sub_837808 @ 0x837878
// > SRP_VBASE_init @ 0x837bb0
// > SRP_VBASE_init @ 0x837d08
// > OPENSSL_sk_push @ 0x838890
// > OPENSSL_sk_unshift @ 0x838898
// > X509v3_add_ext @ 0x841954
// > X509_NAME_add_entry @ 0x8478b4
// > ??> @ 0x5b9cc
//
// 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
//
int __fastcall OPENSSL_sk_insert(int *a1, int a2, unsigned int a3)
{
int v4; // r3
unsigned int v6; // r1
_DWORD *v8; // r1
int v9; // r0
int v10; // r2
int v11; // r6
unsigned int v13; // r7
char v14; // cc
_DWORD *v15; // r0
if ( !a1 )
return 0;
v4 = *a1;
if ( (*a1 == 0x7FFFFFFF) | ((unsigned int)*a1 >> 31) )
return 0;
v6 = a1[3];
if ( v6 <= v4 + 1 )
{
v13 = 2 * v6;
v14 = (2 * v6 != 0x3FFFFFFF) & __CFADD__(2 * v6, -1073741823);
if ( 2 * v6 <= 0x3FFFFFFF )
v14 = v6 > v13;
if ( !v14 )
{
v15 = CRYPTO_realloc((void *)a1[1], (void *)(8 * v6), (int)"crypto/stack/stack.c", 140);
if ( v15 )
{
v4 = *a1;
v8 = v15;
a1[1] = (int)v15;
a1[3] = v13;
goto LABEL_5;
}
}
return 0;
}
v8 = (_DWORD *)a1[1];
LABEL_5:
if ( ((int)a3 >= v4) | (a3 >> 31) )
{
v8[v4] = a2;
}
else
{
v9 = a3 + 1;
v10 = v4 - a3;
v11 = v9 * 4 - 4;
memmove(&v8[v9], &v8[v9 - 1], 4 * v10);
v4 = *a1;
*(_DWORD *)(a1[1] + v11) = a2;
}
*a1 = v4 + 1;
a1[2] = 0;
return v4 + 1;
}