//
// sub_1403F8010 from 0x1403f8010 to 0x1403f815f (335 bytes)
//
// 5 xrefs:
// > SecretLayer5::init @ 0x1403f4301
// > SecretLayer5::onSubmit @ 0x1403f7078
// > ??> @ 0x14069df98
// > ??> @ 0x14069dfd4
// > ??> @ 0x1406d8300
//
// 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_1403F8010(_DWORD *a1, _DWORD *a2, __int64 a3)
{
__int64 result; // rax
unsigned __int64 i; // r14
unsigned __int64 v8; // r13
char v9; // r12
unsigned __int64 v10; // rsi
unsigned __int64 v11; // rbp
__int64 v12; // rsi
unsigned int v13; // eax
_DWORD *v14; // r9
unsigned __int64 v15; // rdx
int v16; // ecx
_DWORD *v17; // [rsp+60h] [rbp+8h]
unsigned __int64 v18; // [rsp+68h] [rbp+10h]
result = 64;
for ( i = -1; i > 0xFFFFFFFF; i >>= 1 )
--result;
if ( a1 != a2 )
{
v17 = a1 + 1;
v8 = 1;
if ( a1 + 1 != a2 )
{
v9 = result - 1;
while ( 1 )
{
v10 = 0;
v11 = 0;
do
{
v12 = 2 * (v10 << v9);
do
v13 = sub_1403F8160(a3);
while ( v13 > i );
v10 = v13 | (unsigned __int64)v12;
v11 = i | (2 * (v11 << v9));
}
while ( v11 < v8 );
v18 = v8 + 1;
if ( v10 / v18 < v11 / v18 || v11 % v18 == v8 )
{
v14 = v17;
result = v10 / v18;
v15 = v10 % v18;
if ( v10 % v18 != v8 )
{
v16 = *v17;
result = (unsigned int)a1[v15];
*v17 = result;
a1[v15] = v16;
}
++v8;
++v17;
if ( v14 + 1 == a2 )
break;
}
}
}
}
return result;
}