//
// cocos2d::CCSpriteBatchNode::sortAllChildren from 0xb17564 to 0xb176c0 (348 bytes)
//
// 5 xrefs:
// > ??> @ 0x416d0
// > ??> @ 0x1137a18
// > ??> @ 0x1202c48
// > ??> @ 0x1218d38
// > ??> @ 0x121abb8
//
// 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::CCSpriteBatchNode::sortAllChildren(cocos2d::CCSpriteBatchNode *a1)
{
cocos2d::CCArray *m_pChildren; // x1
cocos2d::ccArray *data; // x2
cocos2d::CCObject **arr; // x21
cocos2d::CCObject **v5; // x22
cocos2d::CCObject *v6; // x0
cocos2d::ccArray *v7; // x1
cocos2d::CCSprite **v8; // x21
__int64 v9; // x0
char *v10; // x22
cocos2d::CCSprite *i; // x1
int v12; // [xsp+44h] [xbp+44h] BYREF
if ( a1->m_bReorderChildDirty )
{
if ( !a1->m_bManualSortChildren )
{
if ( a1->m_bUseChildIndex )
{
LABEL_4:
cocos2d::CCNode::sortAllChildrenWithIndex(a1);
LABEL_5:
if ( (unsigned int)cocos2d::CCArray::count(a1->m_pChildren) )
{
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
data = m_pChildren->data;
if ( data->num && (arr = data->arr, v5 = &arr[data->num - 1], arr <= v5) && (v6 = *arr) != nullptr )
{
do
{
++arr;
((void (__fastcall *)(cocos2d::CCObject *))v6->__vftable[7].isEqual)(v6);
if ( v5 < arr )
break;
v6 = *arr;
}
while ( *arr );
m_pChildren = a1->m_pChildren;
v12 = 0;
if ( !m_pChildren )
goto LABEL_13;
}
else
{
v12 = 0;
}
v7 = m_pChildren->data;
if ( v7->num )
{
v8 = (cocos2d::CCSprite **)v7->arr;
v9 = 8LL * v7->num - 8;
v10 = (char *)v8 + v9;
if ( v8 <= (cocos2d::CCSprite **)((char *)v8 + v9) )
{
for ( i = *v8; *v8; i = *v8 )
{
++v8;
cocos2d::CCSpriteBatchNode::updateAtlasIndex(a1, i, &v12);
if ( v10 < (char *)v8 )
break;
}
}
}
}
}
LABEL_13:
a1->m_bReorderChildDirty = 0;
a1->m_bManualSortAllChildrenDirty = 0;
return;
}
LABEL_17:
cocos2d::CCNode::sortAllChildrenNoIndex(a1);
goto LABEL_5;
}
if ( a1->m_bManualSortAllChildrenDirty )
{
if ( a1->m_bUseChildIndex )
goto LABEL_4;
goto LABEL_17;
}
}
}