//
// a2i_ASN1_STRING from 0x108d5b4 to 0x108d8b4 (768 bytes)
//
// 1 xrefs:
// > ??> @ 0xde4a8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:17:16 +0000
//
__int64 __fastcall a2i_ASN1_STRING(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
int v8; // w0
char *v9; // x6
int v10; // w22
int v11; // w28
char *v12; // x20
int v13; // w1
int v14; // w2
_BOOL4 v15; // w24
char *v16; // x1
char v17; // w4
char *v18; // x3
int v19; // w2
int v20; // w23
int v21; // w27
char *v22; // x25
__int64 v23; // x19
__int64 v24; // x26
__int64 v25; // x28
int v26; // w0
char *v27; // x1
char *v29; // x0
v8 = BIO_gets(a1, a3, a4);
if ( v8 > 0 )
{
v9 = (char *)(a3 + v8);
v10 = 0;
v11 = 0;
v12 = nullptr;
v13 = (unsigned __int8)*(v9 - 1);
if ( v13 == 10 )
goto LABEL_19;
while ( 1 )
{
if ( v13 == 13 )
goto LABEL_21;
while ( 1 )
{
v14 = v8 - 1;
v15 = v13 == 92;
v16 = (char *)(a3 + v8 - 1);
if ( v8 == 1 )
{
LABEL_25:
v18 = v9;
v14 = v8;
}
else
{
while ( 1 )
{
v17 = *v16;
v18 = v16--;
if ( (unsigned __int8)(v17 - 48) > 9u && (unsigned __int8)((v17 & 0xDF) - 65) > 5u )
break;
if ( !--v14 )
goto LABEL_25;
}
}
*v18 = 0;
if ( v14 == 1 )
{
LABEL_28:
ERR_put_error(13, 103, 150, (__int64)"crypto/asn1/f_string.c", 145);
CRYPTO_free(v12, (__int64)"crypto/asn1/f_string.c", 146);
return 0;
}
v19 = v14 - v15;
if ( (v19 & 1) != 0 )
{
ERR_put_error(13, 103, 145, (__int64)"crypto/asn1/f_string.c", 106);
CRYPTO_free(v12, (__int64)"crypto/asn1/f_string.c", 107);
return 0;
}
v20 = v19 >> 1;
v21 = v11 + (v19 >> 1);
if ( v21 > v10 )
{
v29 = (char *)CRYPTO_realloc(
v12,
(void *)(unsigned int)(v11 + 2 * v20),
(__int64)"crypto/asn1/f_string.c",
112);
if ( !v29 )
{
ERR_put_error(13, 103, 65, (__int64)"crypto/asn1/f_string.c", 114);
CRYPTO_free(v12, (__int64)"crypto/asn1/f_string.c", 115);
return 0;
}
v10 = v21 + v20;
v12 = v29;
}
v22 = (char *)a3;
v23 = 0;
v24 = v11;
if ( v20 )
{
while ( 1 )
{
v25 = 0;
v26 = OPENSSL_hexchar2int(*v22);
v27 = &v12[v24];
if ( v26 < 0 )
break;
while ( 1 )
{
v27[v23] = v26 | (16 * v27[v23]);
if ( v25 )
break;
v25 = 1;
v26 = OPENSSL_hexchar2int(v22[1]);
v27 = &v12[v24];
if ( v26 < 0 )
goto LABEL_24;
}
++v23;
v22 += 2;
if ( v20 <= (int)v23 )
goto LABEL_16;
}
LABEL_24:
ERR_put_error(13, 103, 141, (__int64)"crypto/asn1/f_string.c", 126);
CRYPTO_free(v12, (__int64)"crypto/asn1/f_string.c", 127);
return 0;
}
LABEL_16:
if ( !v15 )
goto LABEL_31;
v8 = BIO_gets(a1, a3, a4);
if ( v8 <= 0 )
goto LABEL_28;
v9 = (char *)(a3 + v8);
v13 = (unsigned __int8)*(v9 - 1);
v11 = v21;
if ( v13 != 10 )
break;
LABEL_19:
*(_BYTE *)(a3 + --v8) = 0;
if ( !v8 )
goto LABEL_28;
v9 = (char *)(a3 + v8);
v13 = (unsigned __int8)*(v9 - 1);
if ( v13 == 13 )
{
LABEL_21:
*(_BYTE *)(a3 + --v8) = 0;
if ( !v8 )
goto LABEL_28;
v9 = (char *)(a3 + v8);
v13 = (unsigned __int8)*(v9 - 1);
}
}
}
}
v21 = 0;
v12 = nullptr;
LABEL_31:
*(_DWORD *)a2 = v21;
*(_QWORD *)(a2 + 8) = v12;
return 1;
}