//
// a2i_ASN1_STRING from 0xa7bd7c to 0xa7c064 (744 bytes)
//
// 1 xrefs:
// > ??> @ 0x8347c
//
// 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:46 +0000
//
int __fastcall a2i_ASN1_STRING(_DWORD *a1, _DWORD *a2, int a3, int a4)
{
int v5; // r0
unsigned __int8 *v6; // r12
_BYTE *v7; // r4
int v8; // r6
int v9; // r5
char *v10; // r9
int v11; // r2
unsigned int v12; // r6
unsigned int v13; // r6
_BYTE *v14; // lr
int v15; // t1
unsigned int v16; // r1
int v17; // r4
int v18; // r10
char *v19; // r8
char *v20; // r4
char *v21; // r11
char *v22; // r5
char v23; // t1
int v24; // r0
char *v26; // r0
int v27; // [sp+Ch] [bp-18h]
v5 = BIO_gets(a1, a3, a4);
if ( v5 > 0 )
{
v7 = (_BYTE *)(a3 + v5);
v8 = *(unsigned __int8 *)(a3 + v5 - 1);
v9 = 0;
v10 = nullptr;
v27 = 0;
if ( v8 == 10 )
goto LABEL_26;
while ( 1 )
{
if ( v8 == 13 )
goto LABEL_28;
while ( 1 )
{
v11 = v5 - 1;
v12 = __clz(v8 - 92);
if ( v5 != 1 )
v6 = (unsigned __int8 *)(a3 + v11);
v13 = v12 >> 5;
if ( v5 == 1 )
{
LABEL_22:
v14 = v7;
v11 = v5;
}
else
{
while ( 1 )
{
v14 = v6;
v15 = *v6--;
v16 = (v15 & 0xFFFFFFDF) - 65;
if ( (unsigned int)(v15 - 48) > 9 && v16 > 5 )
break;
if ( !--v11 )
goto LABEL_22;
}
}
*v14 = 0;
if ( v11 == 1 )
{
LABEL_32:
ERR_put_error(13, 103, 150, (int)"crypto/asn1/f_string.c", 145);
CRYPTO_free(v10, (int)"crypto/asn1/f_string.c", 146);
return 0;
}
if ( ((v11 - v13) & 1) != 0 )
{
ERR_put_error(13, 103, 145, (int)"crypto/asn1/f_string.c", 106);
CRYPTO_free(v10, (int)"crypto/asn1/f_string.c", 107);
return 0;
}
v17 = (int)(v11 - v13) >> 1;
v18 = v9 + v17;
if ( v9 + v17 > v27 )
{
v26 = (char *)CRYPTO_realloc(v10, (void *)(v9 + 2 * v17), (int)"crypto/asn1/f_string.c", 112);
if ( !v26 )
{
ERR_put_error(13, 103, 65, (int)"crypto/asn1/f_string.c", 114);
CRYPTO_free(v10, (int)"crypto/asn1/f_string.c", 115);
return 0;
}
v10 = v26;
v27 = v18 + v17;
}
if ( v17 )
{
v19 = &v10[v9];
v20 = (char *)(a3 + 2 * v17);
v21 = (char *)a3;
LABEL_19:
v22 = v21 + 2;
while ( 1 )
{
v23 = *v21++;
v24 = OPENSSL_hexchar2int(v23);
if ( v24 < 0 )
break;
*v19 = v24 | (16 * *v19);
if ( v22 == v21 )
{
++v19;
if ( v20 == v21 )
goto LABEL_23;
goto LABEL_19;
}
}
ERR_put_error(13, 103, 141, (int)"crypto/asn1/f_string.c", 126);
CRYPTO_free(v10, (int)"crypto/asn1/f_string.c", 127);
return 0;
}
LABEL_23:
if ( !v13 )
goto LABEL_35;
v5 = BIO_gets(a1, a3, a4);
if ( v5 <= 0 )
goto LABEL_32;
v7 = (_BYTE *)(a3 + v5);
v8 = *(unsigned __int8 *)(a3 + v5 - 1);
v9 = v18;
if ( v8 != 10 )
break;
LABEL_26:
--v5;
*(_BYTE *)(a3 + v5) = 0;
if ( !v5 )
goto LABEL_32;
v7 = (_BYTE *)(a3 + v5);
v8 = *(unsigned __int8 *)(a3 + v5 - 1);
if ( v8 == 13 )
{
LABEL_28:
--v5;
*(_BYTE *)(a3 + v5) = 0;
if ( !v5 )
goto LABEL_32;
v7 = (_BYTE *)(a3 + v5);
v8 = *(unsigned __int8 *)(a3 + v5 - 1);
}
}
}
}
v18 = 0;
v10 = nullptr;
LABEL_35:
*a2 = v18;
a2[2] = v10;
return 1;
}