//
// sub_1402541E0 from 0x1402541e0 to 0x1402544f4 (788 bytes)
//
// 2 xrefs:
// > sub_1402520F0 @ 0x140252157
// > ??> @ 0x1406cf744
//
// 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
//
unsigned __int64 *__fastcall sub_1402541E0(
unsigned __int64 *a1,
unsigned __int64 a2,
unsigned __int64 a3,
unsigned __int8 (__fastcall *a4)(unsigned __int64, unsigned __int64))
{
unsigned __int64 v7; // rbx
unsigned __int64 v8; // rsi
unsigned __int64 v9; // rdi
unsigned __int64 v10; // rdi
unsigned __int64 v11; // r14
bool v12; // zf
unsigned __int64 v13; // rbp
void *v16[25]; // [rsp+30h] [rbp-148h] BYREF
_BYTE v17[40]; // [rsp+F8h] [rbp-80h] BYREF
v7 = a2 + 232 * (((__int64)((unsigned __int128)((__int64)(a3 - a2) * (__int128)0x469EE58469EE5847LL) >> 64) >> 6) / 2);
sub_140255450(a2, v7, a3 - 232);
v8 = v7 + 232;
if ( a2 < v7 )
{
do
{
v9 = v7 - 232;
if ( a4(v7 - 232, v7) )
break;
if ( a4(v7, v7 - 232) )
break;
v7 -= 232LL;
}
while ( a2 < v9 );
}
for ( ; v8 < a3; v8 += 232LL )
{
if ( a4(v8, v7) )
break;
if ( a4(v7, v8) )
break;
}
v10 = v8;
v11 = v7;
while ( 1 )
{
while ( 1 )
{
for ( ; v10 < a3; v10 += 232LL )
{
if ( !a4(v7, v10) )
{
if ( a4(v10, v7) )
break;
if ( v8 != v10 )
sub_140255660(v8, v10);
v8 += 232LL;
}
}
v12 = v11 == a2;
if ( v11 > a2 )
{
v13 = v11 - 232;
do
{
if ( !a4(v13, v7) )
{
if ( a4(v7, v13) )
break;
v7 -= 232LL;
if ( v7 != v13 )
sub_140255660(v7, v13);
}
v11 -= 232LL;
v13 -= 232LL;
}
while ( a2 < v11 );
v12 = v11 == a2;
}
if ( v12 )
break;
v11 -= 232LL;
if ( v10 == a3 )
{
v7 -= 232LL;
if ( v11 != v7 )
sub_140255660(v11, v7);
v8 -= 232LL;
sub_1402548A0(v16, v7);
sub_140250C90(v7, v8);
sub_140250C90(v8, (__int64)v16);
sub_14005E430((__int64)v17);
sub_1402508A0(v16, (__int64)v16);
}
else
{
sub_1402548A0(v16, v10);
sub_140250C90(v10, v11);
sub_140250C90(v11, (__int64)v16);
sub_14005E430((__int64)v17);
sub_1402508A0(v16, (__int64)v16);
v10 += 232LL;
}
}
if ( v10 == a3 )
break;
if ( v8 != v10 )
{
sub_1402548A0(v16, v7);
sub_140250C90(v7, v8);
sub_140250C90(v8, (__int64)v16);
sub_14005E430((__int64)v17);
sub_1402508A0(v16, (__int64)v16);
}
v8 += 232LL;
sub_1402548A0(v16, v7);
sub_140250C90(v7, v10);
sub_140250C90(v10, (__int64)v16);
sub_14005E430((__int64)v17);
sub_1402508A0(v16, (__int64)v16);
v7 += 232LL;
v10 += 232LL;
}
*a1 = v7;
a1[1] = v8;
return a1;
}