//
// sub_A8D7E4 from 0xa8d7e4 to 0xa8dce4 (1280 bytes)
//
// 2 xrefs:
// > sub_A8DDC0 @ 0xa8e42c
// > sub_A8DDC0 @ 0xa8e648
//
// 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:08:56 +0000
//
int __fastcall sub_A8D7E4(int a1, const char *a2, void **a3, char *a4)
{
_DWORD *v6; // r6
size_t v7; // r0
int v8; // r1
int v9; // r2
__int16 v10; // r3
int v11; // r5
int v12; // lr
int v13; // r3
__int16 v14; // r0
unsigned __int8 *v15; // r12
int v16; // r12
unsigned __int8 *v17; // r0
int v18; // r3
int v19; // r3
int v20; // r8
char *v21; // r1
char *v22; // r9
int v23; // t1
char *v24; // r10
char *v25; // r11
char *string; // r2
size_t v27; // r0
char *v28; // r2
char v29; // r1
int v30; // t1
char *v31; // r2
int v32; // lr
int v33; // t1
char *v35; // [sp+Ch] [bp-10h]
v6 = (_DWORD *)BUF_MEM_new();
if ( !v6 )
return 0;
v7 = strlen(a4);
if ( BUF_MEM_grow(v6, v7 + 1) )
{
v8 = (unsigned __int8)*a4;
v9 = *(_DWORD *)(a1 + 4);
v10 = *(_WORD *)(v9 + 2 * v8);
v11 = 0;
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
while ( (v10 & 0x40) != 0 )
{
while ( 1 )
{
v12 = v8;
v8 = (unsigned __int8)*++a4;
v13 = 2 * v8;
v14 = *(_WORD *)(v9 + 2 * v8);
if ( (v14 & 8) == 0 )
{
while ( v8 != v12 )
{
v15 = (unsigned __int8 *)a4;
if ( (v14 & 0x20) != 0 )
{
v8 = (unsigned __int8)a4[1];
v15 = (unsigned __int8 *)(a4 + 1);
v13 = 2 * v8;
if ( (*(_WORD *)(v9 + 2 * v8) & 8) != 0 )
{
++a4;
goto LABEL_20;
}
}
++v11;
*(_BYTE *)(v6[1] + v11 - 1) = v8;
v8 = v15[1];
v9 = *(_DWORD *)(a1 + 4);
v13 = 2 * v8;
v14 = *(_WORD *)(v9 + 2 * v8);
a4 = (char *)(v15 + 1);
if ( (v14 & 8) != 0 )
goto LABEL_20;
}
goto LABEL_11;
}
LABEL_20:
if ( v8 != v12 )
break;
LABEL_11:
v8 = (unsigned __int8)*++a4;
v10 = *(_WORD *)(v9 + 2 * v8);
if ( (v10 & 0x40) == 0 )
goto LABEL_12;
}
v10 = *(_WORD *)(v9 + v13);
}
LABEL_12:
if ( (v10 & 0x400) == 0 )
break;
v16 = v8;
v8 = (unsigned __int8)*++a4;
v10 = *(_WORD *)(v9 + 2 * v8);
if ( (v10 & 8) != 0 )
{
LABEL_34:
if ( v8 == v16 )
{
v8 = (unsigned __int8)*++a4;
v10 = *(_WORD *)(v9 + 2 * v8);
}
}
else
{
while ( 1 )
{
v17 = (unsigned __int8 *)a4;
if ( v8 == v16 )
{
v8 = (unsigned __int8)a4[1];
v17 = (unsigned __int8 *)(a4 + 1);
if ( v8 != v16 )
break;
}
++v11;
*(_BYTE *)(v6[1] + v11 - 1) = v8;
v8 = v17[1];
v9 = *(_DWORD *)(a1 + 4);
v10 = *(_WORD *)(v9 + 2 * v8);
a4 = (char *)(v17 + 1);
if ( (v10 & 8) != 0 )
goto LABEL_34;
}
++a4;
v10 = *(_WORD *)(v9 + 2 * v8);
}
}
if ( (v10 & 0x20) == 0 )
break;
v18 = (unsigned __int8)a4[1];
if ( (*(_WORD *)(v9 + 2 * v18) & 8) != 0 )
goto LABEL_67;
switch ( v18 )
{
case 'r':
LOBYTE(v18) = 13;
break;
case 'n':
LOBYTE(v18) = 10;
break;
case 'b':
LOBYTE(v18) = 8;
break;
case 't':
LOBYTE(v18) = 9;
break;
}
*(_BYTE *)(v6[1] + v11) = v18;
v8 = (unsigned __int8)a4[2];
v9 = *(_DWORD *)(a1 + 4);
++v11;
a4 += 2;
v10 = *(_WORD *)(v9 + 2 * v8);
}
v19 = v10 & 8;
if ( v19 )
{
LABEL_67:
*(_BYTE *)(v6[1] + v11) = 0;
CRYPTO_free(*a3, (int)"crypto/conf/conf_def.c", 539);
*a3 = (void *)v6[1];
CRYPTO_free(v6, (int)"crypto/conf/conf_def.c", 541);
return 1;
}
if ( v8 == 36 )
break;
++a4;
*(_BYTE *)(v6[1] + v11) = v8;
v8 = (unsigned __int8)*a4;
v9 = *(_DWORD *)(a1 + 4);
++v11;
v10 = *(_WORD *)(v9 + 2 * v8);
}
v20 = (unsigned __int8)a4[1];
if ( v20 == 123 )
{
v19 = 125;
}
else
{
if ( v20 != 40 )
{
v21 = a4 + 1;
goto LABEL_43;
}
v19 = 41;
}
v21 = a4 + 2;
v20 = (unsigned __int8)a4[2];
LABEL_43:
v22 = v21;
if ( (*(_WORD *)(v9 + 2 * v20) & 0x107) != 0 )
{
do
{
v23 = (unsigned __int8)*++v22;
v20 = v23;
}
while ( (*(_WORD *)(v9 + 2 * v23) & 0x107) != 0 );
}
if ( v20 == 58 && v22[1] == 58 )
{
*v22 = 0;
v31 = v22 + 2;
v20 = (unsigned __int8)v22[2];
v32 = *(_DWORD *)(a1 + 4);
v25 = v22 + 2;
if ( (*(_WORD *)(v32 + 2 * v20) & 0x107) != 0 )
{
do
{
v33 = (unsigned __int8)*++v25;
v20 = v33;
}
while ( (*(_WORD *)(v32 + 2 * v33) & 0x107) != 0 );
}
*v25 = 0;
if ( v19 )
{
if ( v19 != v20 )
{
LABEL_68:
ERR_put_error(14, 101, 102, (int)"crypto/conf/conf_def.c", 491);
BUF_MEM_free((int)v6);
return 0;
}
v24 = v25 + 1;
string = CONF_get_string(a1, v21, v31);
}
else
{
v24 = v25;
string = CONF_get_string(a1, v21, v31);
}
*v22 = 58;
*v25 = v20;
if ( !string )
goto LABEL_61;
}
else
{
*v22 = 0;
if ( v19 )
{
if ( v19 != v20 )
goto LABEL_68;
v24 = v22 + 1;
v25 = v22;
string = CONF_get_string(a1, a2, v21);
}
else
{
v24 = v22;
v25 = v22;
string = CONF_get_string(a1, a2, v21);
}
*v25 = v20;
if ( !string )
{
LABEL_61:
ERR_put_error(14, 101, 104, (int)"crypto/conf/conf_def.c", 511);
break;
}
}
v35 = string;
v27 = strlen(string);
if ( !BUF_MEM_grow_clean(v6, a4 - v24 + *v6 + v27) )
{
ERR_put_error(14, 101, 65, (int)"crypto/conf/conf_def.c", 516);
BUF_MEM_free((int)v6);
return 0;
}
v28 = v35;
v29 = *v35;
if ( *v35 )
{
do
{
++v11;
*(_BYTE *)(v6[1] + v11 - 1) = v29;
v30 = (unsigned __int8)*++v28;
v29 = v30;
}
while ( v30 );
}
*v25 = v20;
v8 = (unsigned __int8)*v24;
v9 = *(_DWORD *)(a1 + 4);
a4 = v24;
v10 = *(_WORD *)(v9 + 2 * v8);
}
}
BUF_MEM_free((int)v6);
return 0;
}