//
// cocos2d::CCSpriteBatchNode::rebuildIndexInOrder from 0x100177890 to 0x1001779b0 (288 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::rebuildIndexInOrder @ 0x100177918
// > cocos2d::CCSpriteBatchNode::rebuildIndexInOrder @ 0x100177996
//
// 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
//
unsigned int __fastcall cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(
cocos2d::CCSpriteBatchNode *a1,
cocos2d::CCSprite *a2,
unsigned int a3)
{
__int64 v4; // rax
__int64 v5; // r15
unsigned int *v6; // rax
cocos2d::CCSprite **v7; // r14
unsigned __int64 v8; // r15
cocos2d::CCSprite *v9; // r13
unsigned int *v10; // rax
cocos2d::CCSprite **v11; // r14
unsigned __int64 v12; // r12
cocos2d::CCSprite *v13; // r15
__int64 v15; // [rsp+10h] [rbp-30h]
v4 = ((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2);
v15 = v4;
if ( v4 )
{
v5 = v4;
if ( (unsigned int)sub_100720070(v4) )
{
v6 = *(unsigned int **)(v5 + 56);
if ( *v6 )
{
v7 = *((cocos2d::CCSprite ***)v6 + 2);
v8 = (unsigned __int64)&v7[*v6 - 1];
do
{
v9 = *v7;
if ( !*v7 )
break;
if ( ((int (__fastcall *)(cocos2d::CCSprite *))v9->getZOrder)(*v7) < 0 )
a3 = cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(a1, v9, a3);
++v7;
}
while ( (unsigned __int64)v7 <= v8 );
}
}
}
if ( !((unsigned __int8 (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))a2->isEqual)(a2, a1) )
a2->m_uAtlasIndex = a3++;
if ( v15 )
{
if ( (unsigned int)sub_100720070(v15) )
{
v10 = *(unsigned int **)(v15 + 56);
if ( *v10 )
{
v11 = *((cocos2d::CCSprite ***)v10 + 2);
v12 = (unsigned __int64)&v11[*v10 - 1];
do
{
v13 = *v11;
if ( !*v11 )
break;
if ( ((int (__fastcall *)(cocos2d::CCSprite *))v13->getZOrder)(*v11) >= 0 )
a3 = cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(a1, v13, a3);
++v11;
}
while ( (unsigned __int64)v11 <= v12 );
}
}
}
return a3;
}