//
// sub_1006223C8 from 0x1006223c8 to 0x100622534 (364 bytes)
//
// 4 xrefs:
// > sub_100622260 @ 0x100622260
// > sub_100622744 @ 0x100622794
// > sub_100622744 @ 0x1006227ac
// > sub_10062280C @ 0x10062281c
//
// 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
//
__int64 __fastcall sub_1006223C8(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
int v8; // w8
__int64 v9; // x21
int v10; // w8
_QWORD *v11; // x9
bool v12; // vf
int v13; // w0
_OWORD v15[4]; // [xsp+0h] [xbp-80h] BYREF
v15[0] = *(_OWORD *)"ENGINE_modexp";
memset(&v15[1], 0, 48);
if ( off_100885B70 )
{
if ( a1 )
{
sub_1005AAF94(a1, *(_DWORD *)(a4 + 8));
v8 = *(_DWORD *)(a1 + 12);
if ( v8 == *(_DWORD *)(a4 + 8) )
{
v9 = ((__int64 (__fastcall *)(_OWORD *, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD, _QWORD))off_100885B70)(
v15,
(unsigned int)(8 * v8),
*(_QWORD *)a4,
(unsigned int)(8 * *(_DWORD *)(a3 + 8)),
*(_QWORD *)a3,
(unsigned int)(8 * *(_DWORD *)(a2 + 8)),
*(_QWORD *)a2,
*(_QWORD *)a1);
sub_100622264((const char *)v15, 107, v9);
if ( (_DWORD)v9 == 1 )
{
v10 = *(_DWORD *)(a4 + 8);
*(_DWORD *)(a1 + 8) = v10;
if ( v10 >= 1 )
{
v11 = (_QWORD *)(*(_QWORD *)a1 + 8LL * (v10 - 1));
do
{
if ( *v11 )
break;
--v11;
v12 = __OFSUB__(v10--, 1);
}
while ( !((v10 < 0) ^ v12 | (v10 == 0)) );
*(_DWORD *)(a1 + 8) = v10;
}
return 1;
}
}
else
{
return 0;
}
}
else
{
return 0;
}
}
else
{
v13 = dword_100885B54;
if ( !dword_100885B54 )
{
v13 = sub_1005E197C();
dword_100885B54 = v13;
}
sub_1005E0E48(v13, 107, 117, (__int64)"e_sureware.c", 1077);
return 0;
}
return v9;
}