//
// cocos2d::CCSpriteBatchNode::appendChild from 0x100176940 to 0x100176b06 (454 bytes)
//
// 3 xrefs:
// > cocos2d::CCSpriteBatchNode::addChild @ 0x100176931
// > cocos2d::CCSpriteBatchNode::appendChild @ 0x100176aeb
// > cocos2d::CCSprite::addChild @ 0x1002899e4
//
// 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
//
void __fastcall cocos2d::CCSpriteBatchNode::appendChild(cocos2d::CCSpriteBatchNode *a1, cocos2d::CCSprite *a2)
{
int v2; // r15d
unsigned int v3; // r15d
cocos2d::ccArray *data; // r15
unsigned int v5; // edx
__int128 v6; // xmm0
__int128 v7; // xmm1
__int128 v8; // xmm2
cocos2d::CCSprite **v9; // r15
__int64 v10; // r12
unsigned __int64 i; // r14
cocos2d::ccV3F_C4B_T2F_Quad v12; // [rsp+0h] [rbp-80h] BYREF
a1->m_bReorderChildDirty = 1;
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))a2->setBatchNode)(a2, a1);
((void (__fastcall *)(cocos2d::CCSprite *, __int64))a2->setDirty)(a2, 1);
if ( !a2->m_bDontDraw )
{
v2 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getTotalQuads)(a1->m_pobTextureAtlas);
if ( v2 == ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getCapacity)(a1->m_pobTextureAtlas) )
{
v3 = (4
* ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getCapacity)(a1->m_pobTextureAtlas)
+ 4)
/ 3;
if ( ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))a1->m_pobTextureAtlas->getCapacity)(a1->m_pobTextureAtlas) < v3 )
cocos2d::CCTextureAtlas::resizeCapacity(a1->m_pobTextureAtlas, v3);
}
data = a1->m_pobDescendants->data;
sub_100667840(data, a2);
v5 = data->num - 1;
a2->m_uAtlasIndex = v5;
*(_OWORD *)&v12.br.vertices.z = *(_OWORD *)&a2->m_sQuad.br.vertices.z;
*(_OWORD *)&v12.tr.texCoords.u = *(_OWORD *)&a2->m_sQuad.tr.texCoords.u;
v6 = *(_OWORD *)&a2->m_sQuad.tl.vertices.x;
v7 = *(_OWORD *)&a2->m_sQuad.tl.texCoords.u;
v8 = *(_OWORD *)&a2->m_sQuad.bl.vertices.z;
*(_OWORD *)&v12.tr.vertices.x = *(_OWORD *)&a2->m_sQuad.tr.vertices.x;
*(_OWORD *)&v12.bl.vertices.z = v8;
*(_OWORD *)&v12.tl.texCoords.u = v7;
*(_OWORD *)&v12.tl.vertices.x = v6;
cocos2d::CCTextureAtlas::insertQuad(a1->m_pobTextureAtlas, &v12, v5);
}
if ( ((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) )
{
if ( **(_DWORD **)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56) )
{
v9 = *(cocos2d::CCSprite ***)(*(_QWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
+ 16LL);
v10 = *(_QWORD *)(*(_QWORD *)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56) + 16LL);
for ( i = v10
+ 8LL * **(unsigned int **)(((__int64 (__fastcall *)(cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
- 8; (unsigned __int64)v9 <= i; ++v9 )
{
if ( !*v9 )
break;
cocos2d::CCSpriteBatchNode::appendChild(a1, *v9);
}
}
}
}