//
// cocos2d::CCSpriteBatchNode::insertChild from 0xd89004 to 0xd8930c (776 bytes)
//
// 3 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0xd891f4
// > cocos2d::CCSpriteBatchNode::insertChild @ 0xd892ec
// > ??> @ 0x76300
//
// 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::insertChild(
cocos2d::CCSpriteBatchNode *this,
cocos2d::CCSprite *a2,
unsigned int a3)
{
int v6; // w23
__int64 v7; // x0
__int64 v8; // x9
__int64 v9; // x6
__int64 v10; // x7
__int64 v11; // x4
__int64 v12; // x5
__int64 v13; // x10
__int64 v14; // x11
__int64 v15; // x12
__int64 v16; // x13
__int64 v17; // x14
__int64 v18; // x15
__int64 v19; // x2
unsigned int v20; // w19
__int64 v21; // x23
__int64 v22; // x1
cocos2d::CCSprite **v23; // x23
__int64 v24; // x2
__int64 v25; // x1
cocos2d::CCSprite *v26; // x0
__int64 v27; // x22
unsigned __int64 v28; // x22
cocos2d::CCSprite *v29; // x19
__int64 v30; // x0
int v31; // w0
unsigned int v32; // w0
cocos2d::CCSprite **v34; // x23
__int64 v35; // x2
__int64 v36; // x1
cocos2d::CCSprite *v37; // x0
__int64 v38; // x22
unsigned __int64 v39; // x22
cocos2d::CCSprite *v40; // x19
__int64 v41; // x0
int v42; // w0
unsigned int v43; // w0
_QWORD v44[12]; // [xsp+48h] [xbp+48h] BYREF
(*(void (__fastcall **)(cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))(*(_QWORD *)a2 + 1120LL))(a2, this);
*((_DWORD *)a2 + 90) = a3;
(*(void (__fastcall **)(cocos2d::CCSprite *, __int64))(*(_QWORD *)a2 + 1200LL))(a2, 1);
if ( *((_BYTE *)a2 + 559) )
{
if ( (*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) )
{
if ( **(_DWORD **)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) + 56) )
{
v34 = *(cocos2d::CCSprite ***)(*(_QWORD *)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2)
+ 56)
+ 16LL);
v35 = *(_QWORD *)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
v36 = *(_QWORD *)a2;
v37 = a2;
v38 = *(_QWORD *)(v35 + 16);
v39 = v38
+ 8LL * **(unsigned int **)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(v36 + 488))(v37) + 56)
- 8;
while ( v39 >= (unsigned __int64)v34 )
{
v40 = *v34;
if ( !*v34 )
break;
v41 = (__int64)*v34++;
v42 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v40 + 104LL))(v41);
v43 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v40, v42);
cocos2d::CCSpriteBatchNode::insertChild(this, v40, v43);
}
}
}
}
else
{
v6 = (*(__int64 (__fastcall **)(_QWORD))(**((_QWORD **)this + 41) + 80LL))(*((_QWORD *)this + 41));
if ( v6 == (*(unsigned int (__fastcall **)(_QWORD))(**((_QWORD **)this + 41) + 88LL))(*((_QWORD *)this + 41)) )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(this);
v7 = *((_QWORD *)this + 41);
v8 = *(_QWORD *)((char *)a2 + 468);
v9 = *(_QWORD *)((char *)a2 + 476);
v10 = *(_QWORD *)((char *)a2 + 484);
v11 = *(_QWORD *)((char *)a2 + 492);
v12 = *(_QWORD *)((char *)a2 + 500);
v13 = *(_QWORD *)((char *)a2 + 508);
v14 = *(_QWORD *)((char *)a2 + 516);
v15 = *(_QWORD *)((char *)a2 + 524);
v16 = *(_QWORD *)((char *)a2 + 532);
v17 = *(_QWORD *)((char *)a2 + 540);
v18 = *(_QWORD *)((char *)a2 + 548);
v44[0] = *(_QWORD *)((char *)a2 + 460);
v44[1] = v8;
v44[2] = v9;
v44[3] = v10;
v44[4] = v11;
v44[5] = v12;
v44[6] = v13;
v44[7] = v14;
v44[8] = v15;
v44[9] = v16;
v44[10] = v17;
v44[11] = v18;
cocos2d::CCTextureAtlas::insertQuad(v7, v44, a3);
v19 = a3;
v20 = a3 + 1;
v21 = *(_QWORD *)(*((_QWORD *)this + 43) + 56LL);
cocos2d::ccArrayInsertObjectAtIndexBatch(v21, a2, v19);
for ( ; *(_DWORD *)v21 > v20; ++*(_DWORD *)(v22 + 360) )
v22 = *(_QWORD *)(*(_QWORD *)(v21 + 16) + 8LL * v20++);
if ( (*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) )
{
if ( **(_DWORD **)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) + 56) )
{
v23 = *(cocos2d::CCSprite ***)(*(_QWORD *)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2)
+ 56)
+ 16LL);
v24 = *(_QWORD *)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
v25 = *(_QWORD *)a2;
v26 = a2;
v27 = *(_QWORD *)(v24 + 16);
v28 = v27
+ 8LL * **(unsigned int **)((*(__int64 (__fastcall **)(cocos2d::CCSprite *))(v25 + 488))(v26) + 56)
- 8;
while ( v28 >= (unsigned __int64)v23 )
{
v29 = *v23;
if ( !*v23 )
break;
v30 = (__int64)*v23++;
v31 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v29 + 104LL))(v30);
v32 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v29, v31);
cocos2d::CCSpriteBatchNode::insertChild(this, v29, v32);
}
}
}
}
return _stack_chk_guard;
}