//
// BN_sub_word from 0xd7f5b0 to 0xd7f6ac (252 bytes)
//
// 7 xrefs:
// > BN_MONT_CTX_set @ 0xd7be68
// > BN_add_word @ 0xd7f77c
// > OBJ_obj2txt @ 0xdc268c
// > BN_mod_sqrt @ 0xe1b02c
// > DH_check_pub_key @ 0xe29aa8
// > BN_is_prime_fasttest_ex @ 0xe76f3c
// > ??> @ 0x4a0e8
//
// 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
//
__int64 __fastcall BN_sub_word(__int64 a1, unsigned __int64 a2)
{
__int64 result; // x0
_BOOL4 is_zero; // w0
__int64 v5; // x1
int v6; // w4
unsigned __int64 *v7; // x3
unsigned __int64 v8; // x2
unsigned __int64 v9; // t1
unsigned __int64 v10; // x2
unsigned __int64 v11; // x2
unsigned int v12; // w20
if ( !a2 )
return 1;
is_zero = BN_is_zero(a1);
v5 = a2;
if ( !is_zero )
{
v6 = *(_DWORD *)(a1 + 16);
if ( v6 )
{
*(_DWORD *)(a1 + 16) = 0;
result = BN_add_word(a1, a2);
*(_DWORD *)(a1 + 16) = 1;
return result;
}
result = *(unsigned int *)(a1 + 8);
v7 = *(unsigned __int64 **)a1;
v8 = **(_QWORD **)a1;
if ( (_DWORD)result == 1 )
{
if ( a2 > v8 )
{
*v7 = a2 - v8;
*(_DWORD *)(a1 + 16) = 1;
return result;
}
v11 = v8 - a2;
*v7 = v11;
if ( !v11 )
*(_DWORD *)(a1 + 8) = 0;
}
else
{
if ( a2 > v8 )
{
do
{
*v7 = v8 - v5;
v9 = v7[1];
++v7;
v8 = v9;
++v6;
v5 = 1;
}
while ( !v9 );
}
v10 = v8 - v5;
*v7 = v10;
if ( !v10 && v6 == (_DWORD)result - 1 )
*(_DWORD *)(a1 + 8) = v6;
}
return 1;
}
v12 = (unsigned int)BN_set_word(a1, a2);
result = 0;
if ( v12 )
{
BN_set_negative(a1, 1);
return v12;
}
return result;
}