//
// cocos2d::extension::CCTableView::_addCellIfNecessary from 0x5a9932 to 0x5a99e4 (178 bytes)
//
// 2 xrefs:
// > cocos2d::extension::CCTableView::updateCellAtIndex @ 0x5a9ff2
// > cocos2d::extension::CCTableView::insertCellAtIndex @ 0x5aa49a
//
// 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 cocos2d::extension::CCTableView::_addCellIfNecessary(
cocos2d::extension::CCTableView *a1,
cocos2d::extension::CCTableViewCell *a2)
{
cocos2d::CCNode *v4; // r6
cocos2d::CCNode *Container; // r0
_DWORD *m_nLuaID; // r5
unsigned int Idx; // r0
int v8; // r3
_DWORD *v9; // r2
_DWORD *v10; // r4
unsigned int v11; // r6
_DWORD *v12; // r1
int v13; // r0
_BOOL4 v14; // r7
int v15; // r0
v4 = a2->getParent(a2);
if ( v4 != cocos2d::extension::CCScrollView::getContainer(a1) )
{
Container = cocos2d::extension::CCScrollView::getContainer(a1);
Container->addChild(Container, a2);
}
cocos2d::extension::CCArrayForObjectSorting::insertSortedObject(
(cocos2d::extension::CCArrayForObjectSorting *)a1[1].m_eObjType,
&a2->cocos2d::extension::CCSortableObject);
m_nLuaID = (_DWORD *)a1[1].m_nLuaID;
Idx = cocos2d::extension::CCTableViewCell::getIdx(a2);
v8 = 1;
v9 = (_DWORD *)m_nLuaID[2];
v10 = m_nLuaID + 1;
v11 = Idx;
while ( v9 )
{
v10 = v9;
if ( Idx >= v9[4] )
{
v12 = (_DWORD *)v9[3];
v8 = 0;
}
else
{
v12 = (_DWORD *)v9[2];
v8 = 1;
}
v9 = v12;
}
if ( !v8 )
{
v13 = (int)v10;
LABEL_13:
if ( *(_DWORD *)(v13 + 16) >= v11 )
return;
goto LABEL_14;
}
if ( v10 != (_DWORD *)m_nLuaID[3] )
{
v13 = sub_762018(v10);
goto LABEL_13;
}
LABEL_14:
v14 = v10 == m_nLuaID + 1 || v11 < v10[4];
v15 = operator new(0x14u);
*(_DWORD *)(v15 + 16) = v11;
sub_7620E8(v14, v15, v10, m_nLuaID + 1);
++m_nLuaID[5];
}