//
// cocos2d::CCSprite::sortAllChildren from 0x18008d270 to 0x18008d3e3 (371 bytes)
//
// 10 xrefs:
// > ??> @ 0x1800ebac0
// > ??> @ 0x1800ebf98
// > ??> @ 0x1800ecb18
// > ??> @ 0x1801039d0
// > ??> @ 0x1801069c8
// > ??> @ 0x18013d420
// > ??> @ 0x18013d468
// > ??> @ 0x18013d478
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b5e80
//
// 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
//
void __fastcall cocos2d::CCSprite::sortAllChildren(cocos2d::CCSprite *this)
{
cocos2d::ccArray *data; // rdx
__int64 num; // rax
cocos2d::CCObject **arr; // r14
int v5; // r12d
__int64 i; // r15
cocos2d::CCObject *v7; // rsi
int v8; // ebx
__int64 v9; // rbp
int v10; // edi
int v11; // edi
unsigned int v12; // edi
cocos2d::CCObject *v13; // rcx
int v14; // eax
cocos2d::CCArray *m_pChildren; // rax
cocos2d::ccArray *v16; // rbx
__int64 v17; // rax
cocos2d::CCObject **v18; // rbx
cocos2d::CCObject **j; // rdi
__int64 v20; // [rsp+50h] [rbp+8h]
if ( this->m_bReorderChildDirty )
{
data = this->m_pChildren->data;
num = (int)data->num;
arr = data->arr;
v20 = num;
if ( num > 1 )
{
v5 = 0;
for ( i = 1; i < num; ++i )
{
v7 = arr[i];
v8 = v5;
v9 = i - 1;
if ( v5 >= 0 )
{
do
{
v10 = ((__int64 (__fastcall *)(cocos2d::CCObject *))arr[v9]->__vftable[1].acceptVisitor)(arr[v9]);
if ( ((int (__fastcall *)(cocos2d::CCObject *))v7->__vftable[1].acceptVisitor)(v7) >= v10 )
{
v11 = ((__int64 (__fastcall *)(cocos2d::CCObject *))arr[v9]->__vftable[1].acceptVisitor)(arr[v9]);
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))v7->__vftable[1].acceptVisitor)(v7) != v11 )
break;
v12 = ((__int64 (__fastcall *)(cocos2d::CCObject *))arr[v9]->__vftable[5].update)(arr[v9]);
if ( ((unsigned int (__fastcall *)(cocos2d::CCObject *))v7->__vftable[5].update)(v7) >= v12 )
break;
}
v13 = arr[v9];
v14 = v8 + 1;
arr[v9-- + 1] = v13;
--v8;
v13->m_uUnknown = v14;
}
while ( v8 >= 0 );
num = v20;
}
arr[v9 + 1] = v7;
++v5;
v7->m_uUnknown = v8 + 1;
}
}
if ( this->m_pobBatchNode )
{
m_pChildren = this->m_pChildren;
if ( m_pChildren )
{
v16 = m_pChildren->data;
v17 = v16->num;
if ( (_DWORD)v17 )
{
v18 = v16->arr;
for ( j = &v18[v17 - 1]; v18 <= j; ++v18 )
{
if ( !*v18 )
break;
((void (__fastcall *)(cocos2d::CCObject *))(*v18)->__vftable[8].copyWithZone)(*v18);
}
}
}
}
this->m_bReorderChildDirty = 0;
}
}