//
// BN_bn2dec from 0xffbfa8 to 0xffc200 (600 bytes)
//
// 4 xrefs:
// > OBJ_obj2txt @ 0x1040a24
// > i2s_ASN1_ENUMERATED @ 0x1081ba0
// > i2s_ASN1_INTEGER @ 0x1081c0c
// > ??> @ 0x56098
//
// 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
//
_BYTE *__fastcall BN_bn2dec(__int64 a1)
{
int v2; // w0
int v3; // w20
__int64 v4; // x19
__int64 v5; // x26
__int64 v6; // x21
__int64 v7; // x0
_BYTE *v8; // x24
unsigned __int64 *v9; // x0
__int64 v10; // x25
_BYTE *v12; // x20
__int64 *v13; // x23
__int64 v14; // x0
__int64 v15; // x3
__int64 *v16; // x23
__int64 v18; // t1
v2 = BN_num_bits(a1);
v3 = 3 * v2 / 10 + 3 * v2 / 1000;
v4 = (v3 + 2) / 19 + 1;
v5 = CRYPTO_malloc(8 * v4, "crypto/bn/bn_print.c", 73);
v6 = v3 + 5;
v7 = CRYPTO_malloc(v6, "crypto/bn/bn_print.c", 74);
v8 = (_BYTE *)v7;
if ( !v5 || !v7 )
{
v10 = 0;
ERR_put_error(3, 104, 65, "crypto/bn/bn_print.c", 76);
goto LABEL_8;
}
v9 = BN_dup(a1);
v10 = (__int64)v9;
if ( !v9 )
{
LABEL_8:
CRYPTO_free(v5, "crypto/bn/bn_print.c", 118);
BN_free(v10);
CRYPTO_free(v8, "crypto/bn/bn_print.c", 122);
return nullptr;
}
if ( BN_is_zero((__int64)v9) )
{
v8[1] = 0;
*v8 = 48;
}
else
{
v12 = v8;
if ( BN_is_negative(v10) )
{
v12 = v8 + 1;
*v8 = 45;
}
v13 = (__int64 *)v5;
while ( !BN_is_zero(v10) )
{
if ( v4 > ((__int64)v13 - v5) >> 3 )
{
v14 = BN_div_word(v10, 0x8AC7230489E80000LL);
*v13++ = v14;
if ( v14 != -1 )
continue;
}
goto LABEL_8;
}
v15 = *(v13 - 1);
v16 = v13 - 1;
BIO_snprintf(v12, v8 - v12 + v6, "%lu", v15);
if ( *v12 )
{
while ( *++v12 )
;
}
while ( (__int64 *)v5 != v16 )
{
v18 = *--v16;
BIO_snprintf(v12, v8 - v12 + v6, "%019lu", v18);
if ( *v12 )
{
while ( *++v12 )
;
}
}
}
CRYPTO_free(v5, "crypto/bn/bn_print.c", 118);
BN_free(v10);
return v8;
}