//
// sub_1800A1D70 from 0x1800a1d70 to 0x1800a1dfc (140 bytes)
//
// 9 xrefs:
// > cocos2d::CCNode::getChildren @ 0x18000346d
// > cocos2d::CCNode::qsortAllChildrenWithIndex @ 0x180004619
// > cocos2d::CCNode::updateChildIndexes @ 0x180005654
// > sub_1800A1380 @ 0x1800a13c8
// > sub_1800A16E0 @ 0x1800a16f8
// > sub_1800A19E0 @ 0x1800a19e9
// > ??> @ 0x1801481e4
// > ??> @ 0x180148218
// > ??> @ 0x1801c17c4
//
// 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:22:13 +0000
//
__int64 __fastcall sub_1800A1D70(__int64 a1)
{
__int64 result; // rax
int v2; // r10d
int v3; // r11d
__int64 v4; // rsi
__int64 v5; // r9
__int64 v6; // r8
__int64 v7; // rbx
__int64 v8; // rdx
result = *(int *)(a1 + 8);
if ( (_DWORD)result != -1 )
{
v2 = 0;
v3 = 0;
v4 = *(int *)(a1 + 8);
if ( (int)result > 0 )
{
result = 0;
v5 = 0;
do
{
v6 = *(_QWORD *)(a1 + 16);
v7 = *(_QWORD *)(v6 + 8 * result);
if ( v7 )
{
if ( v5 > 0 )
{
v8 = 8 * (result - v5);
*(_QWORD *)(v8 + v6) = v7;
*(_DWORD *)(*(_QWORD *)(v8 + *(_QWORD *)(a1 + 16)) + 36LL) = v3 - v2;
}
}
else
{
++v2;
++v5;
}
++v3;
++result;
}
while ( result < v4 );
}
*(_DWORD *)(a1 + 8) = -1;
}
return result;
}