//
// sub_1403778E0 from 0x1403778e0 to 0x140377acc (492 bytes)
//
// 4 xrefs:
// > sub_140375B50 @ 0x140375b97
// > ??> @ 0x1408bc5a4
// > ??> @ 0x1408bc5f4
// > ??> @ 0x140922304
//
// 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
//
__int64 __fastcall sub_1403778E0(
__int64 a1,
__int64 a2,
__int64 a3,
unsigned __int8 (__fastcall *a4)(__int64, __int64))
{
__int64 v6; // rax
__int64 v9; // r13
__int64 v10; // r15
__int64 v11; // r13
__int64 v12; // rbp
__int64 v13; // r12
__int64 v14; // rsi
__int64 v15; // r15
__int64 result; // rax
v6 = (a3 - a1) >> 6;
if ( v6 <= 40 )
{
if ( a4(a2, a1) )
sub_140377AD0(a2, a1);
result = ((__int64 (__fastcall *)(__int64, __int64))a4)(a3, a2);
if ( (_BYTE)result )
{
sub_140377AD0(a3, a2);
result = ((__int64 (__fastcall *)(__int64, __int64))a4)(a2, a1);
if ( (_BYTE)result )
return sub_140377AD0(a2, a1);
}
}
else
{
v9 = (v6 + 1) >> 3;
v10 = v9 << 6;
v11 = v9 << 7;
v12 = v10 + a1;
v13 = a1 + v11;
if ( a4(v10 + a1, a1) )
sub_140377AD0(v12, a1);
if ( a4(v13, v12) )
{
sub_140377AD0(v13, v12);
if ( a4(v12, a1) )
sub_140377AD0(v12, a1);
}
if ( a4(a2, a2 - v10) )
sub_140377AD0(a2, a2 - v10);
if ( a4(v10 + a2, a2) )
{
sub_140377AD0(v10 + a2, a2);
if ( a4(a2, a2 - v10) )
sub_140377AD0(a2, a2 - v10);
}
v14 = a3 - v10;
v15 = a3 - v11;
if ( a4(v14, a3 - v11) )
sub_140377AD0(v14, v15);
if ( a4(a3, v14) )
{
sub_140377AD0(a3, v14);
if ( a4(v14, v15) )
sub_140377AD0(v14, v15);
}
if ( a4(a2, v12) )
sub_140377AD0(a2, v12);
result = ((__int64 (__fastcall *)(__int64, __int64))a4)(v14, a2);
if ( (_BYTE)result )
{
sub_140377AD0(v14, a2);
result = ((__int64 (__fastcall *)(__int64, __int64))a4)(a2, v12);
if ( (_BYTE)result )
return sub_140377AD0(a2, v12);
}
}
return result;
}