//
// d2i_ASN1_UINTEGER from 0x861c54 to 0x861e44 (496 bytes)
//
// 1 xrefs:
// > ??> @ 0x6987c
//
// 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 d2i_ASN1_UINTEGER(int *a1, unsigned __int8 **a2, int a3)
{
int v6; // r4
int v7; // r0
unsigned __int8 *v8; // r3
__int16 v9; // r2
int result; // r0
void *v11; // r0
void *v12; // r7
size_t v13; // r2
bool v14; // zf
unsigned __int8 *v15; // r1
_BOOL4 v16; // r3
unsigned __int8 *v17; // r3
unsigned __int8 *v18; // [sp+8h] [bp-14h] BYREF
size_t v19; // [sp+Ch] [bp-10h] BYREF
int v20; // [sp+10h] [bp-Ch] BYREF
int v21; // [sp+14h] [bp-8h] BYREF
if ( a1 && (v6 = *a1) != 0 )
{
v18 = *a2;
if ( (ASN1_get_object(&v18, (int *)&v19, &v20, &v21, a3) & 0x80) != 0 )
{
ERR_put_error(13, 150, 102, (int)"crypto/asn1/a_int.c", 464);
LABEL_12:
if ( *a1 != v6 )
goto LABEL_13;
return 0;
}
if ( v20 != 2 )
{
ERR_put_error(13, 150, 115, (int)"crypto/asn1/a_int.c", 464);
goto LABEL_12;
}
}
else
{
v7 = ASN1_INTEGER_new();
v6 = v7;
if ( !v7 )
return 0;
v8 = *a2;
*(_DWORD *)(v7 + 4) = 2;
v18 = v8;
if ( (ASN1_get_object(&v18, (int *)&v19, &v20, &v21, a3) & 0x80) != 0 )
{
v9 = 102;
goto LABEL_11;
}
if ( v20 != 2 )
{
v9 = 115;
goto LABEL_11;
}
}
v11 = CRYPTO_malloc((void *)(v19 + 1), (int)"crypto/asn1/a_int.c", 441);
v12 = v11;
if ( !v11 )
{
v9 = 65;
LABEL_11:
ERR_put_error(13, 150, v9, (int)"crypto/asn1/a_int.c", 464);
if ( !a1 )
{
LABEL_13:
ASN1_INTEGER_free(v6);
return 0;
}
goto LABEL_12;
}
v13 = v19;
v14 = v19 == 0;
*(_DWORD *)(v6 + 4) = 2;
if ( !v14 )
{
v15 = v18;
v16 = *v18 == 0;
if ( v13 == 1 )
v16 = 0;
if ( v16 )
{
--v13;
v15 = v18 + 1;
v19 = v13;
++v18;
}
memcpy(v11, v15, v13);
v18 += v19;
}
CRYPTO_free(*(void **)(v6 + 8), (int)"crypto/asn1/a_int.c", 456);
*(_DWORD *)v6 = v19;
v17 = v18;
*(_DWORD *)(v6 + 8) = v12;
result = v6;
if ( a1 )
*a1 = v6;
*a2 = v17;
return result;
}