//
// BN_bn2binpad from 0x7d4640 to 0x7d46ec (172 bytes)
//
// 6 xrefs:
// > ec_key_simple_priv2oct @ 0x7e98b0
// > sub_8366E0 @ 0x836770
// > sub_8366E0 @ 0x836788
// > SRP_Calc_u @ 0x8368a4
// > SRP_Calc_u @ 0x8368bc
// > ??> @ 0x5fb4c
//
// 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 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;
}