//
// BN_dec2bn from 0x9ec560 to 0x9ec704 (420 bytes)
//
// 3 xrefs:
// > BN_asc2bn @ 0x9ec738
// > s2i_ASN1_INTEGER @ 0xa71c68
// > ??> @ 0x7998c
//
// 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:07:27 +0000
//
int __fastcall BN_dec2bn(int ***a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // r9
int v3; // r3
_BOOL4 v5; // r8
unsigned __int8 *v6; // r2
int v7; // r4
int v8; // t1
int v9; // r6
int **v10; // r5
int v11; // r1
unsigned __int8 *v12; // r10
int v13; // r2
int v14; // r3
int v15; // r4
int v16; // r4
int v17; // t1
int v18; // r0
int *v20; // r3
v2 = a2;
if ( !a2 )
return 0;
v3 = *a2;
if ( !*a2 )
return 0;
if ( v3 == 45 )
v2 = a2 + 1;
v5 = v3 == 45;
v6 = v2 - 1;
v7 = 0;
while ( 1 )
{
v8 = *++v6;
if ( (unsigned int)(v8 - 48) > 9 )
break;
if ( ++v7 == 0x20000000 )
{
v10 = nullptr;
goto LABEL_23;
}
}
if ( !v7 )
{
v10 = nullptr;
goto LABEL_23;
}
v9 = v5 + v7;
if ( !a1 )
return v9;
v10 = *a1;
if ( !*a1 )
{
v10 = (int **)BN_new();
if ( v10 )
goto LABEL_11;
return 0;
}
BN_set_word(*a1, 0);
LABEL_11:
if ( 4 * v7 <= 2147483616 )
{
v11 = (4 * v7 + 31) >> 5;
if ( v11 <= (int)v10[2] || bn_expand2((int)v10, v11) )
{
v12 = &v2[v7];
v13 = 9 * (v7 / 9);
if ( v7 == v13 )
v14 = 0;
else
v14 = v13 - v7 + 9;
v15 = 0;
while ( 1 )
{
++v14;
v16 = 10 * v15 - 48;
if ( v2 == v12 )
break;
v17 = *v2++;
v15 = v16 + v17;
if ( v14 == 9 )
{
if ( !BN_mul_word(v10, 1000000000) )
goto LABEL_23;
v18 = BN_add_word(v10, v15);
v14 = 0;
v15 = 0;
if ( !v18 )
goto LABEL_23;
}
}
bn_correct_top(v10);
v20 = v10[1];
*a1 = v10;
if ( v20 )
{
v10[3] = (int *)v5;
return v9;
}
return v9;
}
}
LABEL_23:
if ( *a1 )
return 0;
BN_free((int)v10);
return 0;
}