//
// cocos2d::extension::CCTableView::_addCellIfNecessary from 0x10042cf20 to 0x10042d006 (230 bytes)
//
// 2 xrefs:
// > cocos2d::extension::CCTableView::updateCellAtIndex @ 0x10042cd5c
// > cocos2d::extension::CCTableView::insertCellAtIndex @ 0x10042d182
//
// 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::extension::CCTableView::_addCellIfNecessary(
cocos2d::extension::CCTableView *a1,
cocos2d::extension::CCTableViewCell *a2)
{
cocos2d::CCNode *v2; // r15
cocos2d::CCNode *Container; // rax
__int64 **v4; // r14
unsigned int Idx; // ebx
__int64 *v6; // rax
__int64 *v7; // r12
__int64 *v8; // r15
unsigned int v9; // eax
_DWORD *v10; // rax
__int64 *v11; // rcx
v2 = (cocos2d::CCNode *)((__int64 (__fastcall *)(cocos2d::extension::CCTableViewCell *))a2->getParent)(a2);
if ( v2 != cocos2d::extension::CCScrollView::getContainer(a1) )
{
Container = cocos2d::extension::CCScrollView::getContainer(a1);
((void (__fastcall *)(cocos2d::CCNode *, cocos2d::extension::CCTableViewCell *))Container->addChild)(Container, a2);
}
cocos2d::extension::CCArrayForObjectSorting::insertSortedObject(
*(cocos2d::extension::CCArrayForObjectSorting **)&a1[1].m_uOrderOfArrival,
&a2->cocos2d::extension::CCSortableObject);
v4 = *(__int64 ***)&a1[1].m_nTag;
Idx = cocos2d::extension::CCTableViewCell::getIdx(a2);
v6 = v4[1];
if ( v6 )
{
while ( 1 )
{
while ( 1 )
{
v8 = v6;
v9 = *((_DWORD *)v6 + 7);
if ( Idx >= v9 )
break;
v6 = (__int64 *)*v8;
v7 = v8;
if ( !*v8 )
goto LABEL_10;
}
if ( Idx <= v9 )
break;
v6 = (__int64 *)v8[1];
if ( !v6 )
{
v7 = v8 + 1;
goto LABEL_10;
}
}
}
else
{
v7 = (__int64 *)(v4 + 1);
v8 = (__int64 *)(v4 + 1);
LABEL_10:
v10 = operator new(0x20u);
v10[7] = Idx;
*(_OWORD *)v10 = 0;
*((_QWORD *)v10 + 2) = v8;
*v7 = (__int64)v10;
v11 = (__int64 *)**v4;
if ( v11 )
*v4 = v11;
sub_100054DD0(v4[1], (__int64 *)v10);
v4[2] = (__int64 *)((char *)v4[2] + 1);
}
}