//
// a2i_ASN1_INTEGER from 0x866d00 to 0x867010 (784 bytes)
//
// 2 xrefs:
// > a2i_ASN1_ENUMERATED @ 0x86702c
// > ??> @ 0x699cc
//
// 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 a2i_ASN1_INTEGER(_DWORD *a1, _DWORD *a2, char *a3, int a4)
{
int v5; // r0
unsigned __int8 *v6; // r4
int v7; // r6
signed int v8; // r9
int v9; // r5
char *v10; // r10
int v11; // r12
unsigned __int8 *v12; // r7
int v13; // r1
int v14; // r3
unsigned __int8 *v15; // lr
char *v16; // r7
int v17; // r4
int v18; // r11
char *v19; // r4
char *v20; // r6
char *v21; // r5
char v22; // t1
int v23; // r0
unsigned int v25; // r1
char *v26; // r0
_BOOL4 v27; // [sp+Ch] [bp-18h]
a2[1] = 2;
v5 = BIO_gets(a1, (int)a3, a4);
if ( v5 > 0 )
{
v6 = (unsigned __int8 *)&a3[v5];
v7 = (unsigned __int8)a3[v5 - 1];
v8 = 0;
v9 = 0;
v10 = nullptr;
v11 = 1;
if ( v7 == 10 )
goto LABEL_27;
while ( 1 )
{
if ( v7 == 13 )
goto LABEL_29;
while ( 1 )
{
v12 = (unsigned __int8 *)a3;
v13 = 0;
v27 = v7 == 92;
while ( 1 )
{
v14 = *v12;
v15 = v12++;
if ( (unsigned int)(v14 - 48) > 9 && (v14 & 0xFFFFFFDF) - 65 > 5 )
break;
if ( ++v13 >= v5 )
{
v15 = v6;
goto LABEL_9;
}
}
v5 = v13;
LABEL_9:
*v15 = 0;
if ( v5 <= 1 )
goto LABEL_23;
if ( v11 && *a3 == 48 && a3[1] == 48 )
{
v5 -= 2;
v16 = a3 + 2;
}
else
{
v16 = a3;
}
if ( ((v5 - v27) & 1) != 0 )
{
ERR_put_error(13, 102, 145, (int)"crypto/asn1/f_int.c", 114);
CRYPTO_free(v10, (int)"crypto/asn1/f_int.c", 115);
return 0;
}
v17 = (v5 - v27) >> 1;
v18 = v9 + v17;
if ( v9 + v17 > v8 )
{
v25 = v8;
v8 = v18 + v17;
v26 = (char *)CRYPTO_clear_realloc(v10, v25, (void *)(v18 + v17), (int)"crypto/asn1/f_int.c", 120);
if ( !v26 )
{
ERR_put_error(13, 102, 65, (int)"crypto/asn1/f_int.c", 122);
CRYPTO_free(v10, (int)"crypto/asn1/f_int.c", 123);
return 0;
}
v10 = v26;
}
if ( v17 )
{
v19 = &v16[2 * v17];
v20 = &v10[v9];
LABEL_20:
v21 = v16 + 2;
while ( 1 )
{
v22 = *v16++;
v23 = OPENSSL_hexchar2int(v22);
if ( v23 < 0 )
break;
*v20 = v23 | (16 * *v20);
if ( v21 == v16 )
{
++v20;
if ( v19 == v16 )
goto LABEL_24;
goto LABEL_20;
}
}
ERR_put_error(13, 102, 141, (int)"crypto/asn1/f_int.c", 134);
goto LABEL_23;
}
LABEL_24:
if ( !v27 )
{
*a2 = v18;
a2[2] = v10;
return 1;
}
v5 = BIO_gets(a1, (int)a3, a4);
v11 = 0;
if ( v5 <= 0 )
goto LABEL_23;
v6 = (unsigned __int8 *)&a3[v5];
v7 = (unsigned __int8)a3[v5 - 1];
v9 = v18;
if ( v7 != 10 )
break;
LABEL_27:
a3[--v5] = 0;
if ( !v5 )
goto LABEL_23;
v6 = (unsigned __int8 *)&a3[v5];
v7 = (unsigned __int8)a3[v5 - 1];
if ( v7 == 13 )
{
LABEL_29:
a3[--v5] = 0;
if ( !v5 )
goto LABEL_23;
v6 = (unsigned __int8 *)&a3[v5];
v7 = (unsigned __int8)a3[v5 - 1];
}
}
}
}
v10 = nullptr;
LABEL_23:
ERR_put_error(13, 102, 150, (int)"crypto/asn1/f_int.c", 151);
CRYPTO_free(v10, (int)"crypto/asn1/f_int.c", 152);
return 0;
}