//
// sub_839918 from 0x839918 to 0x839bd8 (704 bytes)
//
// 2 xrefs:
// > UI_add_input_boolean @ 0x83a540
// > UI_dup_input_boolean @ 0x83a634
//
// 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 sub_839918(int a1, int a2, int a3, _BYTE *a4, char *a5, int a6, int a7, int a8)
{
int v10; // r1
_BYTE *v13; // r4
int v14; // t1
_DWORD *v15; // r0
int v16; // r4
int *v17; // r0
int v18; // r0
int v19; // r5
int v21; // r5
if ( !a4 )
{
ERR_put_error(40, 108, 67, (int)"crypto/ui/ui_lib.c", 154);
return -1;
}
if ( !a5 )
{
ERR_put_error(40, 108, 67, (int)"crypto/ui/ui_lib.c", 156);
return -1;
}
v10 = (unsigned __int8)*a4;
v13 = a4;
if ( *a4 )
{
do
{
if ( strchr(a5, v10) )
ERR_put_error(40, 108, 104, (int)"crypto/ui/ui_lib.c", 161);
v14 = (unsigned __int8)*++v13;
v10 = v14;
}
while ( v14 );
}
if ( !a2 )
{
ERR_put_error(40, 109, 67, (int)"crypto/ui/ui_lib.c", 99);
return -1;
}
if ( !a8 )
{
ERR_put_error(40, 109, 105, (int)"crypto/ui/ui_lib.c", 102);
return -1;
}
v15 = CRYPTO_malloc(&dword_20, (int)"crypto/ui/ui_lib.c", 103);
v16 = (int)v15;
if ( !v15 )
return -1;
v15[3] = a8;
v15[1] = a2;
v17 = *(int **)(a1 + 4);
*(_DWORD *)(v16 + 8) = a7;
*(_DWORD *)(v16 + 28) = a6 != 0;
*(_DWORD *)v16 = 3;
if ( !v17 )
{
v17 = OPENSSL_sk_new_null();
*(_DWORD *)(a1 + 4) = v17;
if ( !v17 )
{
if ( (*(_DWORD *)(v16 + 28) & 1) != 0 )
{
CRYPTO_free(*(void **)(v16 + 4), (int)"crypto/ui/ui_lib.c", 56);
if ( *(_DWORD *)v16 == 3 )
{
CRYPTO_free(*(void **)(v16 + 16), (int)"crypto/ui/ui_lib.c", 59);
CRYPTO_free(*(void **)(v16 + 20), (int)"crypto/ui/ui_lib.c", 60);
CRYPTO_free(*(void **)(v16 + 24), (int)"crypto/ui/ui_lib.c", 61);
}
}
CRYPTO_free((void *)v16, (int)"crypto/ui/ui_lib.c", 67);
return -1;
}
}
*(_DWORD *)(v16 + 24) = a5;
*(_DWORD *)(v16 + 16) = a3;
*(_DWORD *)(v16 + 20) = a4;
v18 = OPENSSL_sk_push(v17, v16);
v19 = v18;
if ( v18 > 0 )
return v19;
v21 = v18 - 1;
if ( (*(_DWORD *)(v16 + 28) & 1) != 0 )
{
CRYPTO_free(*(void **)(v16 + 4), (int)"crypto/ui/ui_lib.c", 56);
if ( *(_DWORD *)v16 == 3 )
{
CRYPTO_free(*(void **)(v16 + 16), (int)"crypto/ui/ui_lib.c", 59);
CRYPTO_free(*(void **)(v16 + 20), (int)"crypto/ui/ui_lib.c", 60);
CRYPTO_free(*(void **)(v16 + 24), (int)"crypto/ui/ui_lib.c", 61);
}
}
CRYPTO_free((void *)v16, (int)"crypto/ui/ui_lib.c", 67);
return v21;
}