//
// cocos2d::CCSpriteBatchNode::rebuildIndexInOrder from 0x100156c40 to 0x100156d60 (288 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::rebuildIndexInOrder @ 0x100156cc8
// > cocos2d::CCSpriteBatchNode::rebuildIndexInOrder @ 0x100156d46
//
// 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 12:25:04 +0000
//
__int64 __fastcall cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(__int64 a1, _DWORD *a2, unsigned int a3)
{
__int64 v4; // rax
__int64 v5; // r15
unsigned int *v6; // rax
_QWORD *v7; // r14
unsigned __int64 v8; // r15
__int64 v9; // r13
unsigned int *v10; // rax
_QWORD *v11; // r14
unsigned __int64 v12; // r12
__int64 v13; // r15
__int64 v15; // [rsp+10h] [rbp-30h]
v4 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2);
v15 = v4;
if ( v4 )
{
v5 = v4;
if ( (unsigned int)sub_1007FEF90(v4) )
{
v6 = *(unsigned int **)(v5 + 56);
if ( *v6 )
{
v7 = *((_QWORD **)v6 + 2);
v8 = (unsigned __int64)&v7[*v6 - 1];
do
{
v9 = *v7;
if ( !*v7 )
break;
if ( (*(int (__fastcall **)(_QWORD))(*(_QWORD *)v9 + 104LL))(*v7) < 0 )
a3 = cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(a1, v9, a3);
++v7;
}
while ( (unsigned __int64)v7 <= v8 );
}
}
}
if ( !(*(unsigned __int8 (__fastcall **)(_DWORD *, __int64))(*(_QWORD *)a2 + 24LL))(a2, a1) )
a2[90] = a3++;
if ( v15 )
{
if ( (unsigned int)sub_1007FEF90(v15) )
{
v10 = *(unsigned int **)(v15 + 56);
if ( *v10 )
{
v11 = *((_QWORD **)v10 + 2);
v12 = (unsigned __int64)&v11[*v10 - 1];
do
{
v13 = *v11;
if ( !*v11 )
break;
if ( (*(int (__fastcall **)(_QWORD))(*(_QWORD *)v13 + 104LL))(*v11) >= 0 )
a3 = cocos2d::CCSpriteBatchNode::rebuildIndexInOrder(a1, v13, a3);
++v11;
}
while ( (unsigned __int64)v11 <= v12 );
}
}
}
return a3;
}