//
// BN_mod_mul_montgomery from 0xff9dfc to 0xff9f18 (284 bytes)
//
// 21 xrefs:
// > BN_to_montgomery @ 0xff8dac
// > ec_GFp_mont_field_mul @ 0x1014988
// > ec_GFp_mont_field_sqr @ 0x10149e4
// > BN_mod_exp_mont_consttime @ 0x1094ed0
// > BN_mod_exp_mont_consttime @ 0x1094f3c
// > BN_mod_exp_mont_consttime @ 0x1095028
// > BN_mod_exp_mont_consttime @ 0x1095078
// > BN_mod_exp_mont @ 0x10955d8
// > BN_mod_exp_mont @ 0x1095604
// > BN_mod_exp_mont @ 0x1095674
// > BN_mod_exp_mont @ 0x1095690
// > BN_mod_exp_mont @ 0x109570c
// > BN_mod_exp_mont_word @ 0x10959c8
// > BN_mod_exp2_mont @ 0x1096448
// > BN_mod_exp2_mont @ 0x1096464
// > BN_mod_exp2_mont @ 0x1096584
// > BN_mod_exp2_mont @ 0x10965ac
// > BN_mod_exp2_mont @ 0x1096764
// > BN_mod_exp2_mont @ 0x109678c
// > BN_mod_exp2_mont @ 0x1096838
// > ??> @ 0x5f908
//
// 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:15:50 +0000
//
unsigned __int64 *__fastcall BN_mod_mul_montgomery(
unsigned __int64 *a1,
__int64 a2,
__int64 a3,
__int64 a4,
__int64 a5)
{
int v6; // w4
unsigned int v11; // w23
__int64 v12; // x23
_BOOL4 v13; // w20
unsigned __int64 *result; // x0
int v15; // w2
int v16; // w1
v6 = *(_DWORD *)(a4 + 40);
if ( v6 <= 1 )
goto LABEL_3;
v11 = *(_DWORD *)(a2 + 8);
if ( v11 != v6 || v11 != *(_DWORD *)(a3 + 8) )
goto LABEL_3;
result = bn_wexpand(a1, v11);
if ( result )
{
if ( (unsigned int)bn_mul_mont(*a1, *(_QWORD *)a2, *(_QWORD *)a3, *(_QWORD *)(a4 + 32), a4 + 80, v11) )
{
v15 = *(_DWORD *)(a3 + 16);
v16 = *(_DWORD *)(a2 + 16);
*((_DWORD *)a1 + 2) = v11;
*((_DWORD *)a1 + 4) = v15 ^ v16;
bn_correct_top((__int64)a1);
return (_QWORD *)(dword_0 + 1);
}
LABEL_3:
BN_CTX_start(a5);
v12 = BN_CTX_get(a5);
if ( v12 )
{
if ( a2 == a3 )
{
if ( !(unsigned int)BN_sqr() )
goto LABEL_6;
}
else if ( !(unsigned int)BN_mul() )
{
goto LABEL_6;
}
v13 = sub_FF9954((__int64)a1, v12, a4) != 0;
goto LABEL_7;
}
LABEL_6:
v13 = 0;
LABEL_7:
BN_CTX_end(a5);
return (unsigned __int64 *)v13;
}
return result;
}