//
// cocos2d::CCSpriteBatchNode::updateAtlasIndex from 0xd8882c to 0xd88a44 (536 bytes)
//
// 4 xrefs:
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0xd888a8
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0xd889a4
// > cocos2d::CCSpriteBatchNode::sortAllChildren @ 0xd88b84
// > ??> @ 0xbdcd0
//
// This function is hookable on this platform (idp: arm, 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 13:08:14 +0000
//
__int64 __fastcall cocos2d::CCSpriteBatchNode::updateAtlasIndex(
cocos2d::CCSpriteBatchNode *this,
cocos2d::CCSprite *a2,
int *a3)
{
__int64 v6; // x0
__int64 v7; // x21
unsigned int *v8; // x1
cocos2d::CCSprite **v9; // x19
__int64 result; // x0
char *v11; // x21
cocos2d::CCSprite *v12; // x1
int v13; // w1
int v14; // w2
int v15; // w1
int v16; // w2
unsigned int *v17; // x1
cocos2d::CCSprite **v18; // x21
char *v19; // x24
cocos2d::CCSprite *v20; // x23
int v21; // w25
int v22; // w4
int v23; // w3
unsigned int *v24; // x1
__int64 v25; // x0
v6 = (*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2);
v7 = v6;
if ( !v6 || (v8 = *(unsigned int **)(v6 + 56), !*v8) )
{
result = *((unsigned __int8 *)a2 + 559);
if ( *((_BYTE *)a2 + 559) )
return result;
goto LABEL_9;
}
if ( *((_BYTE *)a2 + 559) )
{
v9 = *((cocos2d::CCSprite ***)v8 + 2);
result = 8LL * *v8 - 8;
v11 = (char *)v9 + result;
if ( v9 <= (cocos2d::CCSprite **)((char *)v9 + result) )
{
do
{
v12 = *v9;
if ( !*v9 )
break;
++v9;
result = cocos2d::CCSpriteBatchNode::updateAtlasIndex(this, v12, a3);
}
while ( v11 >= (char *)v9 );
}
return result;
}
if ( ((*(__int64 (__fastcall **)(_QWORD))(***((_QWORD ***)v8 + 2) + 104LL))(**((_QWORD **)v8 + 2)) & 0x80000000) != 0 )
{
v24 = *(unsigned int **)(v7 + 56);
if ( !*v24 )
goto LABEL_9;
v18 = *((cocos2d::CCSprite ***)v24 + 2);
v25 = 8LL * *v24 - 8;
v19 = (char *)v18 + v25;
if ( v18 > (cocos2d::CCSprite **)((char *)v18 + v25) )
goto LABEL_9;
v20 = *v18;
v21 = 1;
if ( !*v18 )
goto LABEL_9;
goto LABEL_18;
}
v15 = *((_DWORD *)a2 + 90);
*((_DWORD *)a2 + 90) = *a3;
v16 = *a3;
if ( *a3 != v15 )
{
cocos2d::CCSpriteBatchNode::swap(this, v15, v16);
v16 = *a3;
}
*a3 = v16 + 1;
v17 = *(unsigned int **)(v7 + 56);
result = *v17;
if ( (_DWORD)result )
{
v18 = *((cocos2d::CCSprite ***)v17 + 2);
result = 8LL * (unsigned int)result - 8;
v19 = (char *)v18 + result;
if ( v18 <= (cocos2d::CCSprite **)((char *)v18 + result) )
{
v20 = *v18;
v21 = 0;
if ( *v18 )
{
do
{
LABEL_18:
if ( v21 && ((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)v20 + 104LL))(v20) & 0x80000000) == 0 )
{
v22 = *((_DWORD *)a2 + 90);
*((_DWORD *)a2 + 90) = *a3;
v23 = *a3;
if ( *a3 != v22 )
{
cocos2d::CCSpriteBatchNode::swap(this, v22, *a3);
v23 = *a3;
}
v21 = 0;
*a3 = v23 + 1;
}
++v18;
result = cocos2d::CCSpriteBatchNode::updateAtlasIndex(this, v20, a3);
if ( v19 < (char *)v18 )
break;
v20 = *v18;
}
while ( *v18 );
if ( !v21 )
return result;
LABEL_9:
result = (unsigned int)*a3;
v13 = *((_DWORD *)a2 + 90);
*((_DWORD *)a2 + 90) = result;
v14 = *a3;
if ( *a3 != v13 )
{
result = cocos2d::CCSpriteBatchNode::swap(this, v13, v14);
v14 = *a3;
}
*a3 = v14 + 1;
}
}
}
return result;
}