//
// BN_mod_mul_montgomery from 0x9ea124 to 0x9ea238 (276 bytes)
//
// 21 xrefs:
// > BN_to_montgomery @ 0x9e94d8
// > ec_GFp_mont_field_mul @ 0xa049a8
// > ec_GFp_mont_field_sqr @ 0xa04a00
// > BN_mod_exp_mont_consttime @ 0xa82124
// > BN_mod_exp_mont_consttime @ 0xa821a0
// > BN_mod_exp_mont_consttime @ 0xa822c8
// > BN_mod_exp_mont_consttime @ 0xa82334
// > BN_mod_exp_mont @ 0xa82694
// > BN_mod_exp_mont @ 0xa826f4
// > BN_mod_exp_mont @ 0xa82814
// > BN_mod_exp_mont @ 0xa8284c
// > BN_mod_exp_mont @ 0xa829d4
// > BN_mod_exp_mont_word @ 0xa82b38
// > BN_mod_exp2_mont @ 0xa83600
// > BN_mod_exp2_mont @ 0xa83638
// > BN_mod_exp2_mont @ 0xa83768
// > BN_mod_exp2_mont @ 0xa837b0
// > BN_mod_exp2_mont @ 0xa839c4
// > BN_mod_exp2_mont @ 0xa839f4
// > BN_mod_exp2_mont @ 0xa83a30
// > ??> @ 0x7964c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:26 +0000
//
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_9E9EC4(a1, v11, a4) != 0;
goto LABEL_7;
}
LABEL_6:
v12 = 0;
LABEL_7:
BN_CTX_end(a5);
return v12;
}
return result;
}