//
// sub_1404C7740 from 0x1404c7740 to 0x1404c7834 (244 bytes)
//
// 5 xrefs:
// > sub_1404C64E0 @ 0x1404c652a
// > sub_1404C64E0 @ 0x1404c6539
// > ??> @ 0x1406a9468
// > ??> @ 0x1406a9478
// > ??> @ 0x1406dd1cc
//
// 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_1404C7740(__int64 *a1, unsigned __int64 a2)
{
_QWORD *v2; // rbx
__int64 v3; // r10
__int64 result; // rax
unsigned __int64 v6; // r9
__int64 v7; // rbp
__int64 i; // rdi
__int64 v9; // rcx
unsigned __int64 v10; // r8
v2 = (_QWORD *)a1[1];
v3 = *a1;
result = (unsigned __int64)((unsigned __int128)(((__int64)v2 - *a1) * (__int128)0x2AAAAAAAAAAAAAABLL) >> 64) >> 63;
v6 = ((__int64)v2 - *a1) / 24;
if ( a2 >= v6 )
{
if ( a2 > v6 )
{
v9 = a1[2] - v3;
result = (unsigned __int64)((unsigned __int128)(v9 * (__int128)0x2AAAAAAAAAAAAAABLL) >> 64) >> 63;
if ( a2 <= v9 / 24 )
{
v10 = a2 - v6;
if ( a2 != v6 )
{
result = 0;
do
{
*v2 = 0;
v2[1] = 0;
v2[2] = 0;
v2 += 3;
--v10;
}
while ( v10 );
}
a1[1] = (__int64)v2;
}
else
{
return sub_1404C78D0(a1, a2);
}
}
}
else
{
result = 3 * a2;
v7 = v3 + 24 * a2;
for ( i = v7; (_QWORD *)i != v2; i += 24 )
result = sub_14005D100(i);
a1[1] = v7;
}
return result;
}