//
// cocos2d::CCSpriteBatchNode::insertChild from 0x100156fb0 to 0x1001572f1 (833 bytes)
//
// 2 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x1001570aa
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x1001572d6
//
// 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::insertChild(__int64 a1, _DWORD *a2, unsigned int a3)
{
__int64 result; // rax
__int64 *v6; // r15
__int64 v7; // r12
unsigned __int64 i; // r12
__int64 v9; // r14
int v10; // eax
unsigned int v11; // eax
int v12; // r12d
__int64 v13; // rcx
__int64 v14; // r8
__int64 v15; // r9
unsigned int v16; // r12d
__int128 v17; // xmm0
__int128 v18; // xmm1
__int128 v19; // xmm2
int *v20; // r12
int v21; // eax
__int64 v22; // rcx
__int64 v23; // rdx
unsigned int v24; // esi
int j; // r15d
__int64 v26; // rdx
int v27; // eax
__int64 v28; // rcx
__int64 *v29; // r15
__int64 v30; // r12
unsigned __int64 k; // r12
__int64 v32; // r14
int v33; // eax
unsigned int v34; // eax
_OWORD v35[8]; // [rsp+0h] [rbp-80h] BYREF
(*(void (__fastcall **)(_DWORD *, __int64))(*(_QWORD *)a2 + 1120LL))(a2, a1);
a2[90] = a3;
(*(void (__fastcall **)(_DWORD *, __int64))(*(_QWORD *)a2 + 1200LL))(a2, 1);
if ( *((_BYTE *)a2 + 559) )
{
result = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2);
if ( result )
{
result = *(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
if ( *(_DWORD *)result )
{
v6 = *(__int64 **)(*(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56) + 16LL);
v7 = *(_QWORD *)(*(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56) + 16LL);
result = **(unsigned int **)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
for ( i = v7 + 8 * result - 8; (unsigned __int64)v6 <= i; ++v6 )
{
v9 = *v6;
if ( !*v6 )
break;
v10 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 104LL))(*v6);
v11 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v9, v10);
result = cocos2d::CCSpriteBatchNode::insertChild(a1, v9, v11);
}
}
}
}
else
{
v12 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 328) + 80LL))(*(_QWORD *)(a1 + 328));
if ( v12 == (*(unsigned int (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 328) + 88LL))(*(_QWORD *)(a1 + 328)) )
{
v16 = (4 * (*(unsigned int (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 328) + 88LL))(*(_QWORD *)(a1 + 328)) + 4)
/ 3;
if ( (*(unsigned int (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 328) + 88LL))(*(_QWORD *)(a1 + 328)) < v16 )
cocos2d::CCTextureAtlas::resizeCapacity(*(_QWORD *)(a1 + 328), v16);
}
v35[5] = *(_OWORD *)(a2 + 135);
v35[4] = *(_OWORD *)(a2 + 131);
v17 = *(_OWORD *)(a2 + 115);
v18 = *(_OWORD *)(a2 + 119);
v19 = *(_OWORD *)(a2 + 123);
v35[3] = *(_OWORD *)(a2 + 127);
v35[2] = v19;
v35[1] = v18;
v35[0] = v17;
((void (__fastcall *)(_QWORD, _OWORD *, _QWORD, __int64, __int64, __int64))cocos2d::CCTextureAtlas::insertQuad)(
*(_QWORD *)(a1 + 328),
v35,
a3,
v13,
v14,
v15);
v20 = *(int **)(*(_QWORD *)(a1 + 344) + 56LL);
sub_100746F70(v20, a2, a3);
v21 = *v20;
LODWORD(v22) = a3 + 1;
if ( a3 + 1 < *v20 )
{
v23 = *((_QWORD *)v20 + 2);
v22 = (unsigned int)v22;
v24 = v21 - a3 - 2;
for ( j = ((_BYTE)v21 + ~(_BYTE)a3) & 3; j; --j )
++*(_DWORD *)(*(_QWORD *)(v23 + 8 * v22++) + 360LL);
if ( v24 >= 3 )
{
v26 = v23 + 8 * v22 + 24;
v27 = v21 - v22;
v28 = 0;
do
{
++*(_DWORD *)(*(_QWORD *)(v26 + 8 * v28 - 24) + 360LL);
++*(_DWORD *)(*(_QWORD *)(v26 + 8 * v28 - 16) + 360LL);
++*(_DWORD *)(*(_QWORD *)(v26 + 8 * v28 - 8) + 360LL);
++*(_DWORD *)(*(_QWORD *)(v26 + 8 * v28) + 360LL);
v28 += 4;
}
while ( v27 != (_DWORD)v28 );
}
}
result = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2);
if ( result )
{
result = *(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
if ( *(_DWORD *)result )
{
v29 = *(__int64 **)(*(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56) + 16LL);
v30 = *(_QWORD *)(*(_QWORD *)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56) + 16LL);
result = **(unsigned int **)((*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)a2 + 488LL))(a2) + 56);
for ( k = v30 + 8 * result - 8; (unsigned __int64)v29 <= k; ++v29 )
{
v32 = *v29;
if ( !*v29 )
break;
v33 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v32 + 104LL))(*v29);
v34 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(a1, v32, v33);
result = cocos2d::CCSpriteBatchNode::insertChild(a1, v32, v34);
}
}
}
}
return result;
}