//
// BN_bn2binpad from 0x9e9240 to 0x9e92ec (172 bytes)
//
// 6 xrefs:
// > ec_key_simple_priv2oct @ 0x9fe4b0
// > sub_A4B2E0 @ 0xa4b370
// > sub_A4B2E0 @ 0xa4b388
// > SRP_Calc_u @ 0xa4b4a4
// > SRP_Calc_u @ 0xa4b4bc
// > ??> @ 0x795cc
//
// 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:25 +0000
//
int __fastcall BN_bn2binpad(_DWORD *a1, _BYTE *a2, int a3)
{
int v6; // r0
int v7; // r3
int v8; // r7
int v9; // r3
unsigned int v10; // r2
int v11; // lr
char v12; // r12
if ( a3 < 0 )
return -1;
v6 = BN_num_bits(a1);
v7 = v6 + 7;
if ( v6 + 7 < 0 )
v7 = v6 + 14;
v8 = v7 >> 3;
if ( a3 < v7 >> 3 )
return -1;
if ( a3 > v7 >> 3 )
{
memset(a2, 0, a3 - v8);
a2 += a3 - v8;
}
v9 = v8 - 1;
if ( v8 )
{
do
{
v10 = (unsigned int)(v9 >> 31) >> 30;
v11 = v9 + 3;
v12 = v9 + v10;
if ( v9 >= 0 )
v11 = v9;
--v9;
*a2++ = *(_DWORD *)(*a1 + 4 * (v11 >> 2)) >> (8 * ((v12 & 3) - v10));
}
while ( v9 != -1 );
}
return a3;
}