//
// cocos2d::CCSprite::sortAllChildren from 0x5e5fac to 0x5e6096 (234 bytes)
//
// 0 xrefs:
//
// 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 cocos2d::CCSprite::sortAllChildren(cocos2d::CCSprite *a1)
{
int v2; // r6
cocos2d::ccArray *data; // r3
cocos2d::CCObject **arr; // r10
cocos2d::CCObject **v5; // r8
cocos2d::CCObject *v6; // r4
cocos2d::CCObject *v7; // t1
int v8; // r7
cocos2d::CCObject **i; // r5
int v10; // r9
cocos2d::CCObject *v11; // r3
cocos2d::CCArray *m_pChildren; // r3
cocos2d::ccArray *v13; // r1
cocos2d::CCObject **v14; // r5
cocos2d::CCObject **v15; // r4
int v16; // r0
int v17; // t1
signed int num; // [sp+0h] [bp-Ch]
int v19; // [sp+4h] [bp-8h]
int v20; // [sp+4h] [bp-8h]
unsigned int v21; // [sp+4h] [bp-8h]
if ( a1->m_bReorderChildDirty )
{
v2 = 1;
data = a1->m_pChildren->data;
arr = data->arr;
v5 = arr;
num = data->num;
while ( v2 < num )
{
v7 = v5[1];
++v5;
v6 = v7;
v8 = v2 - 1;
for ( i = v5; ; --i )
{
v10 = v8 + 1;
if ( v8 < 0 )
break;
v19 = ((int (__fastcall *)(cocos2d::CCObject *))v6->__vftable[1].isEqual)(v6);
if ( v19 >= ((int (__fastcall *)(_DWORD))(*(i - 1))->__vftable[1].isEqual)(*(i - 1)) )
{
v20 = ((int (__fastcall *)(cocos2d::CCObject *))v6->__vftable[1].isEqual)(v6);
if ( v20 != ((int (__fastcall *)(_DWORD))(*(i - 1))->__vftable[1].isEqual)(*(i - 1)) )
break;
v21 = ((int (__fastcall *)(cocos2d::CCObject *))v6->__vftable[5].copyWithZone)(v6);
if ( v21 >= ((int (__fastcall *)(_DWORD))(*(i - 1))->__vftable[5].copyWithZone)(*(i - 1)) )
break;
}
v11 = *(i - 1);
--v8;
*i = v11;
v11->m_uUnknown = v10;
}
arr[v10] = v6;
++v2;
v6->m_uUnknown = v10;
}
if ( a1->m_pobBatchNode )
{
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
v13 = m_pChildren->data;
if ( v13->num )
{
v14 = v13->arr;
v15 = &v14[v13->num] + 0x3FFFFFFF;
while ( v14 <= v15 )
{
v17 = (int)*v14++;
v16 = v17;
if ( !v17 )
break;
(*(void (__fastcall **)(int))(*(_DWORD *)v16 + 292))(v16);
}
}
}
}
a1->m_bReorderChildDirty = 0;
}
}