//
// a2i_ASN1_INTEGER from 0xe0edcc to 0xe0f0f0 (804 bytes)
//
// 2 xrefs:
// > a2i_ASN1_ENUMERATED @ 0xe0f104
// > ??> @ 0x83700
//
// 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
//
__int64 __fastcall a2i_ASN1_INTEGER(__int64 a1, __int64 a2, char *a3, unsigned int a4)
{
int v8; // w0
char *v9; // x3
int v10; // w21
int v11; // w7
int v12; // w28
int v13; // w1
char *v14; // x19
char *v15; // x6
_BOOL4 v16; // w23
int v17; // w1
char v18; // w4
char *v19; // x2
char *v20; // x27
int v21; // w0
int v22; // w26
int v23; // w22
char *v24; // x24
__int64 v25; // x25
__int64 v26; // x27
__int64 v27; // x28
int v28; // w0
char *v29; // x1
unsigned __int64 v31; // x1
char *v32; // x0
*(_DWORD *)(a2 + 4) = 2;
v8 = BIO_gets(a1, (__int64)a3, a4);
if ( v8 > 0 )
{
v9 = &a3[v8];
v10 = 0;
v11 = 1;
v12 = 0;
v13 = (unsigned __int8)*(v9 - 1);
v14 = nullptr;
if ( v13 == 10 )
goto LABEL_21;
while ( 1 )
{
if ( v13 == 13 )
goto LABEL_23;
while ( 1 )
{
v15 = a3;
v16 = v13 == 92;
v17 = 0;
while ( 1 )
{
v18 = *v15;
v19 = v15++;
if ( (unsigned __int8)(v18 - 48) > 9u && (unsigned __int8)((v18 & 0xDF) - 65) > 5u )
break;
if ( ++v17 >= v8 )
{
v19 = v9;
goto LABEL_9;
}
}
v8 = v17;
LABEL_9:
*v19 = 0;
if ( v8 <= 1 )
goto LABEL_27;
v20 = a3;
if ( v11 && *a3 == 48 && a3[1] == 48 )
{
v20 = a3 + 2;
v8 -= 2;
}
v21 = v8 - v16;
if ( (v21 & 1) != 0 )
{
ERR_put_error(13, 102, 145, (__int64)"crypto/asn1/f_int.c", 114);
CRYPTO_free(v14, (__int64)"crypto/asn1/f_int.c", 115);
return 0;
}
v22 = v21 >> 1;
v23 = v12 + (v21 >> 1);
if ( v23 > v10 )
{
v31 = v10;
v10 = v23 + v22;
v32 = (char *)CRYPTO_clear_realloc(v14, v31, (void *)(v23 + v22), (__int64)"crypto/asn1/f_int.c", 0x78u);
if ( !v32 )
{
ERR_put_error(13, 102, 65, (__int64)"crypto/asn1/f_int.c", 122);
CRYPTO_free(v14, (__int64)"crypto/asn1/f_int.c", 123);
return 0;
}
v14 = v32;
}
v24 = v20;
v25 = v12;
v26 = 0;
if ( v22 )
{
while ( 1 )
{
v27 = 0;
v28 = OPENSSL_hexchar2int(*v24);
v29 = &v14[v25];
if ( v28 < 0 )
break;
while ( 1 )
{
v29[v26] = v28 | (16 * v29[v26]);
if ( v27 )
break;
v27 = 1;
v28 = OPENSSL_hexchar2int(v24[1]);
v29 = &v14[v25];
if ( v28 < 0 )
goto LABEL_26;
}
++v26;
v24 += 2;
if ( v22 <= (int)v26 )
goto LABEL_18;
}
LABEL_26:
ERR_put_error(13, 102, 141, (__int64)"crypto/asn1/f_int.c", 134);
goto LABEL_27;
}
LABEL_18:
if ( !v16 )
{
*(_DWORD *)a2 = v23;
*(_QWORD *)(a2 + 8) = v14;
return 1;
}
v8 = BIO_gets(a1, (__int64)a3, a4);
v11 = 0;
if ( v8 <= 0 )
goto LABEL_27;
v9 = &a3[v8];
v13 = (unsigned __int8)*(v9 - 1);
v12 = v23;
if ( v13 != 10 )
break;
LABEL_21:
a3[--v8] = 0;
if ( !v8 )
goto LABEL_27;
v9 = &a3[v8];
v13 = (unsigned __int8)*(v9 - 1);
if ( v13 == 13 )
{
LABEL_23:
a3[--v8] = 0;
if ( !v8 )
goto LABEL_27;
v9 = &a3[v8];
v13 = (unsigned __int8)*(v9 - 1);
}
}
}
}
v14 = nullptr;
LABEL_27:
ERR_put_error(13, 102, 150, (__int64)"crypto/asn1/f_int.c", 151);
CRYPTO_free(v14, (__int64)"crypto/asn1/f_int.c", 152);
return 0;
}