//
// BN_sub_word from 0x7d88cc to 0x7d89c0 (244 bytes)
//
// 7 xrefs:
// > BN_MONT_CTX_set @ 0x7d58bc
// > BN_add_word @ 0x7d8a68
// > OBJ_obj2txt @ 0x81ca3c
// > BN_mod_sqrt @ 0x871978
// > DH_check_pub_key @ 0x87f814
// > BN_is_prime_fasttest_ex @ 0x8caa30
// > ??> @ 0x5fddc
//
// 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_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;
}