//
// cocos2d::CCSpriteBatchNode::insertChild from 0x7f2880 to 0x7f2a38 (440 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x7f29a4
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x7f2a20
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:01:05 +0000
//
int __fastcall cocos2d::CCSpriteBatchNode::insertChild(
cocos2d::CCSpriteBatchNode *this,
cocos2d::CCSprite *a2,
unsigned int a3)
{
int v6; // r3
int v7; // r8
void *v8; // r0
unsigned int v9; // r2
unsigned int v10; // r6
unsigned int *v11; // r8
int v12; // r3
int v13; // r1
int result; // r0
cocos2d::CCSprite **v15; // r6
int v16; // r8
unsigned int v17; // r8
cocos2d::CCSprite *v18; // r4
cocos2d::CCSprite *v19; // t1
int v20; // r0
unsigned int v21; // r0
cocos2d::CCSprite **v22; // r6
int v23; // r8
unsigned int v24; // r8
cocos2d::CCSprite *v25; // r4
cocos2d::CCSprite *v26; // t1
int v27; // r0
unsigned int v28; // r0
_BYTE v29[96]; // [sp+4h] [bp-64h] BYREF
(*(void (__fastcall **)(cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))(*(_DWORD *)a2 + 560))(a2, this);
v6 = *(_DWORD *)a2;
*((_DWORD *)a2 + 72) = a3;
(*(void (__fastcall **)(cocos2d::CCSprite *, int))(v6 + 600))(a2, 1);
if ( *((_BYTE *)a2 + 471) )
{
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
if ( result )
{
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
if ( **(_DWORD **)(result + 52) )
{
v22 = *(cocos2d::CCSprite ***)(*(_DWORD *)((*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2)
+ 52)
+ 12);
v23 = *(_DWORD *)(*(_DWORD *)((*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2) + 52) + 12);
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
v24 = v23 + 4 * (**(_DWORD **)(result + 52) + 0x3FFFFFFF);
while ( (unsigned int)v22 <= v24 )
{
v26 = *v22++;
v25 = v26;
if ( !v26 )
break;
v27 = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)v25 + 52))(v25);
v28 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v25, v27);
result = cocos2d::CCSpriteBatchNode::insertChild(this, v25, v28);
}
}
}
}
else
{
v7 = (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 67) + 40))(*((_DWORD *)this + 67));
if ( v7 == (*(int (__fastcall **)(_DWORD))(**((_DWORD **)this + 67) + 44))(*((_DWORD *)this + 67)) )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(this);
v8 = memcpy(v29, (char *)a2 + 372, sizeof(v29));
cocos2d::CCTextureAtlas::insertQuad(*((_DWORD *)this + 67), v8);
v9 = a3;
v10 = a3 + 1;
v11 = *(unsigned int **)(*((_DWORD *)this + 70) + 52);
cocos2d::ccArrayInsertObjectAtIndexBatch(v11, a2, v9);
v12 = 4 * v10;
while ( v10 < *v11 )
{
++v10;
v13 = *(_DWORD *)(v11[3] + v12);
v12 += 4;
++*(_DWORD *)(v13 + 288);
}
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
if ( result )
{
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
if ( **(_DWORD **)(result + 52) )
{
v15 = *(cocos2d::CCSprite ***)(*(_DWORD *)((*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2)
+ 52)
+ 12);
v16 = *(_DWORD *)(*(_DWORD *)((*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2) + 52) + 12);
result = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)a2 + 244))(a2);
v17 = v16 + 4 * (**(_DWORD **)(result + 52) + 0x3FFFFFFF);
while ( (unsigned int)v15 <= v17 )
{
v19 = *v15++;
v18 = v19;
if ( !v19 )
break;
v20 = (*(int (__fastcall **)(cocos2d::CCSprite *))(*(_DWORD *)v18 + 52))(v18);
v21 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v18, v20);
result = cocos2d::CCSpriteBatchNode::insertChild(this, v18, v21);
}
}
}
}
return result;
}