//
// sub_1404A0CB0 from 0x1404a0cb0 to 0x1404a0e3a (394 bytes)
//
// 2 xrefs:
// > sub_1404A0A80 @ 0x1404a0b12
// > ??> @ 0x1409294a4
//
// 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:32:56 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall sub_1404A0CB0(__int64 *a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // rdi
__int64 v6; // rbp
__int64 result; // rax
__int64 j; // rsi
unsigned __int64 v9; // r15
unsigned __int64 i; // rdi
__int64 v11; // rdi
__int64 v12; // rbx
v3 = a3;
v6 = *a1;
if ( a3 <= (a1[2] - *a1) / 120 )
{
j = a1[1];
result = (unsigned __int64)(j - v6 + ((unsigned __int128)((j - v6) * (__int128)(__int64)0x8888888888888889uLL) >> 64)) >> 63;
v9 = (j - v6) / 120;
if ( a3 <= v9 )
{
j = v6 + 120 * a3;
if ( a3 )
{
do
{
result = sub_1404A0E40(v6, a2);
v6 += 120;
a2 += 120;
--v3;
}
while ( v3 );
}
v11 = a1[1];
if ( j != v11 )
{
v12 = j + 40;
do
{
sub_14003D310(v12 + 48);
sub_14003D310(v12);
sub_14003D310(v12 - 32);
v12 += 120;
result = v12 - 40;
}
while ( v12 - 40 != v11 );
}
}
else
{
for ( ; v6 != j; j = a1[1] )
{
result = sub_1404A0E40(v6, a2);
v6 += 120;
a2 += 120;
}
for ( i = v3 - v9; i; --i )
{
result = sub_14049D6F0(j, a2);
j += 120;
a2 += 120;
}
}
}
else
{
result = sub_1404A0EE0(a1, a3);
for ( j = *a1; v3; --v3 )
{
result = sub_14049D6F0(j, a2);
j += 120;
a2 += 120;
}
}
a1[1] = j;
return result;
}