//
// BN_mod_mul_montgomery from 0x7d5524 to 0x7d5638 (276 bytes)
//
// 21 xrefs:
// > BN_to_montgomery @ 0x7d48d8
// > ec_GFp_mont_field_mul @ 0x7efda8
// > ec_GFp_mont_field_sqr @ 0x7efe00
// > BN_mod_exp_mont_consttime @ 0x86d524
// > BN_mod_exp_mont_consttime @ 0x86d5a0
// > BN_mod_exp_mont_consttime @ 0x86d6c8
// > BN_mod_exp_mont_consttime @ 0x86d734
// > BN_mod_exp_mont @ 0x86da94
// > BN_mod_exp_mont @ 0x86daf4
// > BN_mod_exp_mont @ 0x86dc14
// > BN_mod_exp_mont @ 0x86dc4c
// > BN_mod_exp_mont @ 0x86ddd4
// > BN_mod_exp_mont_word @ 0x86df38
// > BN_mod_exp2_mont @ 0x86ea00
// > BN_mod_exp2_mont @ 0x86ea38
// > BN_mod_exp2_mont @ 0x86eb68
// > BN_mod_exp2_mont @ 0x86ebb0
// > BN_mod_exp2_mont @ 0x86edc4
// > BN_mod_exp2_mont @ 0x86edf4
// > BN_mod_exp2_mont @ 0x86ee30
// > ??> @ 0x5fbcc
//
// 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_mod_mul_montgomery(int *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, int a5)
{
int v5; // r12
int v10; // r7
_DWORD *v11; // r7
_BOOL4 v12; // r4
int result; // r0
v5 = a4[7];
if ( v5 <= 1 )
goto LABEL_3;
v10 = a2[1];
if ( v10 != v5 || v10 != a3[1] )
goto LABEL_3;
result = bn_wexpand((int)a1, a2[1]);
if ( result )
{
if ( bn_mul_mont(*a1, *a2, *a3, a4[6], a4 + 16, v10) )
{
a1[3] = a2[3] ^ a3[3];
a1[1] = v10;
bn_correct_top(a1);
return 1;
}
LABEL_3:
BN_CTX_start(a5);
v11 = (_DWORD *)BN_CTX_get(a5);
if ( v11 )
{
if ( a2 == a3 )
{
if ( !BN_sqr() )
goto LABEL_6;
}
else if ( !BN_mul() )
{
goto LABEL_6;
}
v12 = sub_7D52C4(a1, v11, a4) != 0;
goto LABEL_7;
}
LABEL_6:
v12 = 0;
LABEL_7:
BN_CTX_end(a5);
return v12;
}
return result;
}