//
// TXT_DB_read from 0xa4db34 to 0xa4de34 (768 bytes)
//
// 2 xrefs:
// > SRP_VBASE_init @ 0xa4c6a0
// > ??> @ 0x801fc
//
// 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:21 +0000
//
_DWORD *__fastcall TXT_DB_read(_DWORD *a1, int a2)
{
size_t *v4; // r0
int v5; // r4
_DWORD *v7; // r0
_DWORD *v8; // r5
_DWORD *v9; // r0
void *v10; // r0
void *v11; // r0
int v12; // r3
int v13; // r11
int v14; // r6
int v15; // r10
_BYTE *v16; // r5
const char *v17; // r0
_DWORD *v18; // r0
int v19; // r1
_BYTE *v20; // r12
int v21; // r0
unsigned __int8 *v22; // r2
_BOOL4 v23; // lr
unsigned __int8 *v24; // r11
int v25; // r3
int v26; // t1
_BYTE *v27; // r12
_DWORD *v28; // [sp+8h] [bp-Ch]
v4 = (size_t *)BUF_MEM_new();
v5 = (int)v4;
if ( !v4
|| !BUF_MEM_grow(v4, 0x200u)
|| (v7 = CRYPTO_malloc(&dword_20, (int)"crypto/txt_db/txt_db.c", 37), (v8 = v7) == nullptr) )
{
BUF_MEM_free(v5);
return nullptr;
}
*v7 = a2;
v7[2] = 0;
v7[3] = 0;
v9 = OPENSSL_sk_new_null();
v8[1] = v9;
if ( !v9 )
goto LABEL_33;
v10 = CRYPTO_malloc((void *)(4 * a2), (int)"crypto/txt_db/txt_db.c", 44);
v8[2] = v10;
if ( !v10 )
goto LABEL_33;
v11 = CRYPTO_malloc((void *)(4 * a2), (int)"crypto/txt_db/txt_db.c", 46);
v8[3] = v11;
if ( !v11 )
goto LABEL_33;
if ( a2 > 0 )
{
v12 = 0;
do
{
*(_DWORD *)(v8[2] + 4 * v12) = 0;
*(_DWORD *)(v8[3] + 4 * v12++) = 0;
}
while ( v12 != a2 );
}
*(_BYTE *)(*(_DWORD *)(v5 + 4) + 511) = 0;
v13 = 0;
v14 = 512;
v15 = 4 * a2 + 4;
v28 = v8;
do
{
if ( !v13 )
goto LABEL_29;
v14 += 512;
if ( !BUF_MEM_grow_clean((size_t *)v5, v14) )
goto LABEL_32;
*(_BYTE *)(*(_DWORD *)(v5 + 4) + v13) = 0;
BIO_gets(a1, *(_DWORD *)(v5 + 4) + v13, v14 - v13);
v16 = *(_BYTE **)(v5 + 4);
v17 = &v16[v13];
if ( !v16[v13] )
goto LABEL_34;
LABEL_16:
v13 += strlen(v17);
}
while ( v16[v13 - 1] != 10 );
v16[v13 - 1] = 0;
v18 = CRYPTO_malloc((void *)(v15 + v13), (int)"crypto/txt_db/txt_db.c", 75);
v19 = (int)v18;
if ( !v18 )
goto LABEL_32;
v20 = (char *)v18 + v15;
*v18 = (char *)v18 + v15;
v21 = 1;
v22 = *(unsigned __int8 **)(v5 + 4);
v23 = 0;
while ( 1 )
{
v24 = v22;
v26 = *v22++;
v25 = v26;
if ( !v26 )
break;
if ( v25 != 9 )
goto LABEL_19;
if ( v23 )
{
--v20;
LABEL_19:
*v20++ = v25;
v23 = v25 == 92;
}
else
{
*v20 = 0;
v24 = v22;
++v20;
if ( v21 >= a2 )
break;
*(_DWORD *)(v19 + 4 * v21++) = v20;
}
}
*v20 = 0;
v27 = v20 + 1;
if ( v21 != a2 || (v13 = *v24) != 0 )
{
v8 = v28;
v28[4] = 6;
goto LABEL_33;
}
*(_DWORD *)(v19 + 4 * a2) = v27;
if ( !OPENSSL_sk_push((int *)v28[1], v19) )
{
LABEL_32:
v8 = v28;
LABEL_33:
BUF_MEM_free(v5);
OPENSSL_sk_free((void **)v8[1]);
CRYPTO_free((void *)v8[2], (int)"crypto/txt_db/txt_db.c", 120);
CRYPTO_free((void *)v8[3], (int)"crypto/txt_db/txt_db.c", 121);
CRYPTO_free(v8, (int)"crypto/txt_db/txt_db.c", 122);
return nullptr;
}
LABEL_29:
while ( 1 )
{
**(_BYTE **)(v5 + 4) = v13;
BIO_gets(a1, *(_DWORD *)(v5 + 4), v14);
v16 = *(_BYTE **)(v5 + 4);
if ( !*v16 )
break;
if ( *v16 != 35 )
{
v17 = *(const char **)(v5 + 4);
goto LABEL_16;
}
}
LABEL_34:
BUF_MEM_free(v5);
return v28;
}