//
// BN_usub from 0x10911d8 to 0x10912d0 (248 bytes)
//
// 12 xrefs:
// > ec_GFp_simple_set_compressed_coordinates @ 0x1016c18
// > ec_GFp_simple_invert @ 0x1018e94
// > BN_add @ 0x109131c
// > BN_add @ 0x109135c
// > BN_sub @ 0x1091468
// > BN_sub @ 0x10914ac
// > int_bn_mod_inverse @ 0x1097188
// > int_bn_mod_inverse @ 0x1097270
// > BN_mod_add_quick @ 0x1097afc
// > BN_div_recp @ 0x1098ec0
// > BN_div_recp @ 0x1098ef4
// > ??> @ 0xd01b0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:17:21 +0000
//
unsigned __int64 *__fastcall BN_usub(unsigned __int64 *a1, __int64 *a2, __int64 a3)
{
unsigned int v3; // w19
int v5; // w22
unsigned int v6; // w20
unsigned __int64 *result; // x0
__int64 v9; // x3
__int64 v10; // x21
__int64 v11; // x19
unsigned __int64 v12; // x24
__int64 v13; // x0
__int64 v14; // x2
__int64 v15; // x3
v3 = *(_DWORD *)(a3 + 8);
v5 = *((_DWORD *)a2 + 2);
v6 = v5 - v3;
if ( (int)(v5 - v3) < 0 )
{
ERR_put_error(3, 115, 100, (__int64)"crypto/bn/bn_add.c", 121);
return nullptr;
}
else
{
result = bn_wexpand(a1, v5);
if ( result )
{
v9 = v3;
v10 = *a2;
v11 = 8LL * (int)v3;
v12 = *a1;
v13 = bn_sub_words(*a1, v10, *(_QWORD *)a3, v9);
if ( v6 )
{
v14 = 0;
do
{
v15 = *(_QWORD *)(v10 + v11 + 8 * v14);
*(_QWORD *)(v12 + v11 + 8 * v14++) = v15 - v13;
v13 = (unsigned __int8)v13 & (v15 == 0);
}
while ( v14 != v6 - 1 + 1LL );
}
*((_DWORD *)a1 + 2) = v5;
*((_DWORD *)a1 + 4) = 0;
bn_correct_top((__int64)a1);
return (_QWORD *)(dword_0 + 1);
}
}
return result;
}