//
// cocos2d::extension::CCTableView::_addCellIfNecessary from 0x100419b90 to 0x100419c76 (230 bytes)
//
// 2 xrefs:
// > cocos2d::extension::CCTableView::updateCellAtIndex @ 0x1004199cc
// > cocos2d::extension::CCTableView::insertCellAtIndex @ 0x100419df2
//
// 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:30:12 +0000
//
void __fastcall cocos2d::extension::CCTableView::_addCellIfNecessary(__int64 a1, __int64 a2)
{
__int64 v2; // r15
__int64 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 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 512LL))(a2);
if ( v2 != cocos2d::extension::CCScrollView::getContainer(a1) )
{
Container = cocos2d::extension::CCScrollView::getContainer(a1);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)Container + 456LL))(Container, a2);
}
cocos2d::extension::CCArrayForObjectSorting::insertSortedObject(*(_QWORD *)(a1 + 624), (const void *)(a2 + 320));
v4 = *(__int64 ***)(a1 + 592);
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_10001B680(v4[1], (__int64 *)v10);
v4[2] = (__int64 *)((char *)v4[2] + 1);
}
}