//
// BN_dec2bn from 0xffc3dc to 0xffc5b0 (468 bytes)
//
// 3 xrefs:
// > BN_asc2bn @ 0xffc5dc
// > s2i_ASN1_INTEGER @ 0x1081c9c
// > ??> @ 0x55210
//
// 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:15:51 +0000
//
__int64 __fastcall BN_dec2bn(__int64 *a1, unsigned __int8 *a2)
{
unsigned __int8 *v2; // x20
int v4; // w25
__int64 v5; // x2
int v6; // w3
int v7; // w24
unsigned int v8; // w23
__int64 v9; // x22
int v10; // w1
__int64 v11; // x19
unsigned __int8 *v12; // x21
int v13; // w1
__int64 v14; // x19
int v15; // t1
int v16; // w1
__int64 result; // x0
v2 = a2;
if ( !a2 || !*a2 )
return 0;
v4 = 0;
if ( *a2 == 45 )
{
v2 = a2 + 1;
v4 = 1;
}
v5 = 0;
while ( 1 )
{
v6 = v2[v5];
v7 = v5++;
if ( (unsigned int)(v6 - 48) > 9 )
break;
if ( v5 == 0x20000000 )
goto LABEL_23;
}
if ( !v7 )
{
LABEL_23:
v9 = 0;
goto LABEL_24;
}
v8 = v4 + v7;
if ( !a1 )
return v8;
v9 = *a1;
if ( *a1 )
{
BN_set_word(*a1, 0);
}
else
{
v9 = BN_new();
if ( !v9 )
return 0;
}
if ( 4 * v7 <= 2147483584 )
{
v10 = (4 * v7 + 63) >> 6;
if ( v10 <= *(_DWORD *)(v9 + 12) || bn_expand2((unsigned __int64 *)v9, v10) )
{
v11 = 0;
v12 = &v2[v7];
v13 = 19 - v7 % 19;
if ( v13 == 19 )
v13 = 0;
while ( 1 )
{
++v13;
v14 = 5 * v11;
if ( v2 == v12 )
break;
while ( 1 )
{
v15 = *v2++;
v11 = v15 - 48 + 2 * v14;
if ( v13 != 19 )
break;
if ( !(unsigned int)BN_mul_word(v9, 0x8AC7230489E80000LL) || !(unsigned int)BN_add_word(v9, v11) )
goto LABEL_24;
v13 = 1;
v14 = 0;
if ( v2 == v12 )
goto LABEL_20;
}
}
LABEL_20:
bn_correct_top(v9);
v16 = *(_DWORD *)(v9 + 8);
result = v8;
*a1 = v9;
if ( v16 )
*(_DWORD *)(v9 + 16) = v4;
return result;
}
}
LABEL_24:
if ( *a1 )
return 0;
BN_free(v9);
return 0;
}