//
// cocos2d::extension::CCTableView::_addCellIfNecessary from 0x180015840 to 0x180015971 (305 bytes)
//
// 4 xrefs:
// > cocos2d::extension::CCTableView::updateCellAtIndex @ 0x18001536d
// > cocos2d::extension::CCTableView::insertCellAtIndex @ 0x18001552f
// > ??> @ 0x18002fdf8
// > ??> @ 0x18004a830
//
// 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
//
// Hidden C++ exception states: #wind=1
void __fastcall cocos2d::extension::CCTableView::_addCellIfNecessary(
cocos2d::extension::CCTableView *this,
struct cocos2d::extension::CCTableViewCell *a2)
{
__int64 v4; // rbx
struct cocos2d::extension::CCSortableObject *v5; // rdx
unsigned int v6; // ebx
_QWORD *v7; // rdi
__int64 *v8; // rsi
__int64 *v9; // rax
__int64 *v10; // rcx
_DWORD *v11; // rax
__int128 v12; // [rsp+20h] [rbp-38h] BYREF
__int128 v13; // [rsp+30h] [rbp-28h]
v4 = *((_QWORD *)this + 56);
if ( (*(__int64 (__fastcall **)(struct cocos2d::extension::CCTableViewCell *))(*(_QWORD *)a2 + 488LL))(a2) != v4 )
(*(void (__fastcall **)(_QWORD, struct cocos2d::extension::CCTableViewCell *))(**((_QWORD **)this + 56) + 448LL))(
*((_QWORD *)this + 56),
a2);
v5 = (struct cocos2d::extension::CCTableViewCell *)((char *)a2 + 320);
if ( !a2 )
v5 = nullptr;
cocos2d::extension::CCArrayForObjectSorting::insertSortedObject(
*((cocos2d::extension::CCArrayForObjectSorting **)this + 78),
v5);
v6 = *((_DWORD *)a2 + 82);
v7 = *((_QWORD **)this + 74);
v8 = (__int64 *)*v7;
v9 = *(__int64 **)(*v7 + 8LL);
*(_QWORD *)&v13 = v9;
DWORD2(v13) = 0;
v10 = v8;
while ( !*((_BYTE *)v9 + 25) )
{
*(_QWORD *)&v13 = v9;
if ( *((_DWORD *)v9 + 7) >= v6 )
{
DWORD2(v13) = 1;
v10 = v9;
v9 = (__int64 *)*v9;
}
else
{
DWORD2(v13) = 0;
v9 = (__int64 *)v9[2];
}
}
if ( *((_BYTE *)v10 + 25) || v6 < *((_DWORD *)v10 + 7) )
{
if ( v7[1] == 0x7FFFFFFFFFFFFFFLL )
sub_1800054D0();
v11 = operator new(0x20u);
v11[7] = v6;
*(_QWORD *)v11 = v8;
*((_QWORD *)v11 + 1) = v8;
*((_QWORD *)v11 + 2) = v8;
*((_WORD *)v11 + 12) = 0;
v12 = v13;
sub_180004DA0(v7, (__int64)&v12, (__int64)v11);
}
}