//
// sub_1094410 from 0x1094410 to 0x10945e0 (464 bytes)
//
// 2 xrefs:
// > BN_mod_exp_mont_consttime @ 0x1094ff8
// > BN_mod_exp_mont_consttime @ 0x109505c
//
// 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:22 +0000
//
unsigned __int64 *__fastcall sub_1094410(__int64 a1, int a2, _QWORD *a3, int a4, int a5)
{
unsigned __int64 *result; // x0
int v8; // w1
_QWORD *v9; // x2
unsigned __int64 v10; // x11
__int64 v11; // x9
__int64 v12; // x7
__int64 *v13; // x8
int j; // w5
__int64 v15; // x4
__int64 v16; // t1
__int64 v17; // x0
int v18; // w13
__int64 v19; // x5
__int64 v20; // x4
__int64 v21; // x6
__int64 v22; // x0
__int64 v23; // x17
unsigned __int64 v24; // x23
__int64 v25; // x1
__int64 v26; // x22
__int64 v27; // x12
_QWORD *v28; // x7
int i; // w10
__int64 v30; // x6
result = bn_wexpand((unsigned __int64 *)a1, a2);
v8 = 1 << a5;
if ( result )
{
v9 = a3;
if ( a5 > 3 )
{
v17 = (unsigned int)(a4 >> (a5 - 2));
v18 = 1 << (a5 - 2);
v19 = (unsigned int)v17 ^ 2;
v20 = (unsigned int)v17 ^ 1;
v21 = (unsigned int)v17 ^ 3;
v22 = (__int64)(((unsigned int)(v17 - 1) & (unsigned __int64)~v17) << 32) >> 63;
v23 = (__int64)(((unsigned int)(v21 - 1) & (unsigned __int64)~v21) << 32) >> 63;
if ( a2 > 0 )
{
v24 = *(_QWORD *)a1;
v25 = 8LL * v8;
v26 = 0;
do
{
v27 = 0;
if ( v18 > 0 )
{
v28 = v9;
for ( i = 0; i != v18; ++i )
{
v30 = i ^ (v18 - 1) & (unsigned int)a4;
v27 |= ((__int64)(((unsigned int)(v30 - 1) & (unsigned __int64)~v30) << 32) >> 63)
& (v28[v18] & ((__int64)(((unsigned int)(v20 - 1) & (unsigned __int64)~v20) << 32) >> 63)
| v28[2 * v18] & ((__int64)(((unsigned int)(v19 - 1) & (unsigned __int64)~v19) << 32) >> 63)
| *v28 & v22
| v28[3 * v18] & v23);
++v28;
}
}
*(_QWORD *)(v24 + 8 * v26++) = v27;
v9 = (_QWORD *)((char *)v9 + v25);
}
while ( a2 > (int)v26 );
}
}
else if ( a2 > 0 )
{
v10 = *(_QWORD *)a1;
v11 = 0;
do
{
v12 = 0;
if ( v8 > 0 )
{
v13 = v9;
for ( j = 0; j != v8; ++j )
{
v15 = j ^ (unsigned int)a4;
v16 = *v13++;
v12 |= ((__int64)(((unsigned int)(v15 - 1) & (unsigned __int64)~v15) << 32) >> 63) & v16;
}
}
*(_QWORD *)(v10 + 8 * v11++) = v12;
v9 += v8;
}
while ( a2 > (int)v11 );
}
*(_DWORD *)(a1 + 8) = a2;
bn_correct_top(a1);
return (_QWORD *)(dword_0 + 1);
}
return result;
}