//
// BN_usub from 0xe12ed8 to 0xe12fd0 (248 bytes)
//
// 12 xrefs:
// > ec_GFp_simple_set_compressed_coordinates @ 0xd988b8
// > ec_GFp_simple_invert @ 0xd9ab34
// > BN_add @ 0xe1301c
// > BN_add @ 0xe1305c
// > BN_sub @ 0xe13168
// > BN_sub @ 0xe131ac
// > int_bn_mod_inverse @ 0xe18e88
// > int_bn_mod_inverse @ 0xe18f70
// > BN_mod_add_quick @ 0xe197fc
// > BN_div_recp @ 0xe1abc0
// > BN_div_recp @ 0xe1abf4
// > ??> @ 0x9e190
//
// 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
//
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;
}