//
// BN_sub_word from 0x9ed4cc to 0x9ed5c0 (244 bytes)
//
// 7 xrefs:
// > BN_MONT_CTX_set @ 0x9ea4bc
// > BN_add_word @ 0x9ed668
// > OBJ_obj2txt @ 0xa3163c
// > BN_mod_sqrt @ 0xa86578
// > DH_check_pub_key @ 0xa94414
// > BN_is_prime_fasttest_ex @ 0xadfa30
// > ??> @ 0x7985c
//
// 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_sub_word(int **a1, unsigned int a2)
{
unsigned int v2; // r4
int result; // r0
int *v5; // r1
int *v6; // r2
unsigned int v7; // r3
int v8; // t1
int v9; // r3
int v10; // r4
v2 = a2;
if ( !a2 )
return 1;
if ( BN_is_zero((int)a1) )
{
v10 = BN_set_word(a1, v2);
if ( v10 )
{
BN_set_negative((_BOOL4)a1, 1);
return v10;
}
else
{
return 0;
}
}
else
{
v5 = a1[3];
if ( v5 )
{
a1[3] = nullptr;
result = BN_add_word(a1, v2);
a1[3] = &dword_0 + 1;
}
else
{
result = (int)a1[1];
v6 = *a1;
v7 = **a1;
if ( result == 1 )
{
if ( v2 > v7 )
{
*v6 = v2 - v7;
a1[3] = &dword_0 + 1;
return result;
}
}
else if ( v2 > v7 )
{
do
{
*v6 = v7 - v2;
v8 = v6[1];
++v6;
v7 = v8;
v5 = (int *)((char *)v5 + 1);
v2 = 1;
}
while ( !v8 );
}
v9 = v7 - v2;
*v6 = v9;
if ( v9 )
return 1;
result = 1;
if ( v5 == (int *)((char *)a1[1] - 1) )
a1[1] = v5;
}
}
return result;
}