//
// sub_140375B50 from 0x140375b50 to 0x140375d47 (503 bytes)
//
// 3 xrefs:
// > sub_140370210 @ 0x140370266
// > ??> @ 0x1409220e8
// > ??> @ 0x1409220f4
//
// This function is hookable on this platform (idp: pc, 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 11:31:01 +0000
//
unsigned __int64 *__fastcall sub_140375B50(
unsigned __int64 *a1,
unsigned __int64 a2,
unsigned __int64 a3,
unsigned __int8 (__fastcall *a4)(__int64, unsigned __int64))
{
unsigned __int64 v4; // rbp
unsigned __int64 v5; // r13
unsigned __int64 v6; // rbx
unsigned __int64 v8; // rsi
unsigned __int64 v9; // rdi
unsigned __int64 v10; // rdi
unsigned __int64 v11; // r14
unsigned __int64 v12; // r12
__int64 v13; // rbp
unsigned __int64 v14; // rbp
v4 = a2;
v5 = a3;
v6 = a2 + ((__int64)(a3 - a2) >> 7 << 6);
sub_1403778E0(a2, v6, a3 - 64);
v8 = v6 + 64;
if ( v4 < v6 )
{
do
{
v9 = v6 - 64;
if ( a4(v6 - 64, v6) )
break;
if ( a4(v6, v6 - 64) )
break;
v6 -= 64LL;
}
while ( v4 < v9 );
}
for ( ; v8 < v5; v8 += 64LL )
{
if ( a4(v8, v6) )
break;
if ( a4(v6, v8) )
break;
}
v10 = v8;
v11 = v6;
while ( 1 )
{
while ( 1 )
{
if ( v10 < v5 )
{
do
{
if ( !a4(v6, v10) )
{
if ( a4(v10, v6) )
break;
if ( v8 != v10 )
sub_140377AD0(v8, v10);
v8 += 64LL;
}
v10 += 64LL;
}
while ( v10 < v5 );
v4 = a2;
}
v12 = v10;
if ( v4 < v11 )
{
v13 = v11 - 64;
do
{
if ( !a4(v13, v6) )
{
if ( a4(v6, v13) )
break;
v6 -= 64LL;
if ( v6 != v13 )
sub_140377AD0(v6, v13);
}
v11 -= 64LL;
v13 -= 64;
}
while ( a2 < v11 );
v5 = a3;
}
v14 = v6;
if ( v11 == a2 )
break;
v11 -= 64LL;
if ( v10 != v5 )
{
v14 = v10;
v12 = v11;
goto LABEL_36;
}
v6 -= 64LL;
if ( v11 != v6 )
sub_140377AD0(v11, v6);
v8 -= 64LL;
sub_140377AD0(v6, v8);
v4 = a2;
}
if ( v10 == v5 )
break;
if ( v8 != v10 )
sub_140377AD0(v6, v8);
v8 += 64LL;
v6 += 64LL;
LABEL_36:
v10 += 64LL;
sub_140377AD0(v14, v12);
v4 = a2;
}
*a1 = v6;
a1[1] = v8;
return a1;
}