//
// BN_div_word from 0x9ed3ec to 0x9ed4cc (224 bytes)
//
// 3 xrefs:
// > a2d_ASN1_OBJECT @ 0x9d22f0
// > BN_bn2dec @ 0x9ec2d4
// > ??> @ 0x77c3c
//
// 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_div_word(int *a1, unsigned int a2)
{
int result; // r0
int v5; // r0
char v6; // r8
int v7; // r3
int v8; // r7
unsigned int v9; // r4
int v10; // r2
int v11; // r5
unsigned int v12; // r3
int v13; // r9
int v14; // r0
if ( !a2 )
return -1;
if ( !a1[1] )
return 0;
v5 = BN_num_bits_word(a2);
v6 = 32 - v5;
if ( !BN_lshift(a1, a1, 32 - v5) )
return -1;
v7 = a1[1];
v8 = v7 - 1;
if ( v7 - 1 < 0 )
{
result = 0;
}
else
{
v9 = a2 << v6;
v10 = *a1;
v11 = 4 * v8;
v12 = 0;
do
{
v13 = *(_DWORD *)(v10 + v11);
v14 = bn_div_words(v12, v13, v9);
--v8;
v10 = *a1;
*(_DWORD *)(*a1 + v11) = v14;
v12 = v13 - v9 * v14;
v11 -= 4;
}
while ( v8 != -1 );
result = v12 >> v6;
v7 = a1[1];
}
if ( v7 > 0 && !*(_DWORD *)(*a1 + 4 * (v7 + 0x3FFFFFFF)) )
a1[1] = v7 - 1;
return result;
}