//
// LevelBrowserLayer::setupPageInfo from 0x6e8e88 to 0x6e931c (1172 bytes)
//
// 4 xrefs:
// > `non-virtual thunk to'LevelBrowserLayer::setupPageInfo @ 0x6e9320
// > ??> @ 0x76458
// > ??> @ 0x115db68
// > ??> @ 0x11efb38
//
// 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
//
__int64 __fastcall LevelBrowserLayer::setupPageInfo(LevelBrowserLayer *a1, char **a2, char *a3)
{
_BOOL4 m_unk2; // w3
cocos2d::CCArray *v6; // x0
cocos2d::CCArray *v7; // x28
__int64 v8; // x20
__int64 v9; // x3
unsigned __int64 v10; // x19
__int64 v11; // x26
const std::string *v12; // x1
cocos2d::CCObject *v13; // x0
void *v14; // x0
char *v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
char *v20; // x0
void *v21; // x0
cocos2d::CCString *v22; // x0
int v23; // w0
LevelBrowserLayer *v24; // x19
cocos2d::CCString *v25; // x0
cocos2d::CCString *v26; // x0
CCMenuItemSpriteExtra *m_rightArrow; // x2
LevelBrowserLayer *v28; // x19
GJSearchObject *m_searchObject; // x0
CCMenuItemSpriteExtra *m_pageBtn; // x19
void (__fastcall *setVisible)(cocos2d::CCNode *__hidden, bool); // x20
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x19
int v35; // w1
LevelBrowserLayer *v36[13]; // [xsp+0h] [xbp+0h] BYREF
LevelBrowserLayer *v37; // [xsp+68h] [xbp+68h]
char v38; // [xsp+88h] [xbp+88h] BYREF
__int64 v39; // [xsp+90h] [xbp+90h] BYREF
char *v40; // [xsp+98h] [xbp+98h] BYREF
__int64 v41; // [xsp+A0h] [xbp+A0h] BYREF
m_unk2 = a1->m_unk2;
v37 = a1;
if ( m_unk2 || !LevelBrowserLayer::isCorrect(a1, a3) )
return _stack_chk_guard;
v6 = (cocos2d::CCArray *)sub_D153B8((int)&v39, *a2);
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v8 = sub_D168E0((unsigned int)v36 + 144, ":", 0, 1u);
v9 = v8;
v10 = 0;
v11 = *(_QWORD *)(v39 - 24);
v36[12] = (LevelBrowserLayer *)&v38;
while ( 1 )
{
sub_D14F84(&v40, &v39, v10, v9);
if ( v11 != v10 || *((_QWORD *)v40 - 3) )
{
sub_D153B8((int)&v41, v40);
v13 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v41, v12);
cocos2d::CCArray::addObject(v7, v13);
v14 = (void *)(v41 - 24);
if ( (__int64 *)(v41 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v41 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v41 - 8);
*(_DWORD *)(v41 - 8) = v19 - 1;
}
if ( v19 <= 0 )
break;
}
}
if ( v8 == -1 )
goto LABEL_22;
LABEL_10:
v10 = v8 + 1;
v8 = sub_D168E0((int)&v39, ":", (int)v8 + 1, 1u);
v15 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v40 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v15);
}
v9 = v8 - v10;
if ( *(_QWORD *)(v39 - 24) < v10 )
sub_D13C5C(
"%s: __pos (which is %zu) > this->size() (which is %zu)",
"basic_string::substr",
v10,
*(_QWORD *)(v39 - 24));
}
operator delete(v14);
if ( v8 != -1 )
goto LABEL_10;
LABEL_22:
v20 = v40 - 24;
if ( v40 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v40 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v40 - 2);
*((_DWORD *)v40 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v20);
}
v21 = (void *)(v39 - 24);
if ( (__int64 *)(v39 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)(v39 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *(_DWORD *)(v39 - 8);
*(_DWORD *)(v39 - 8) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v21);
}
if ( (unsigned int)cocos2d::CCArray::count(v7) > 2 )
{
v22 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v7, 0);
v23 = cocos2d::CCString::intValue(v22);
v24 = v37;
v37->m_itemCount = v23;
v25 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v7, 1u);
v24->m_pageStartIdx = cocos2d::CCString::intValue(v25);
v26 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v7, 2u);
v24->m_pageEndIdx = cocos2d::CCString::intValue(v26);
((void (__fastcall *)(CCMenuItemSpriteExtra *))v37->m_leftArrow->setVisible)(v37->m_leftArrow);
m_rightArrow = v37->m_rightArrow;
if ( v37->m_pageStartIdx + v37->m_pageEndIdx < v37->m_itemCount )
m_rightArrow->setVisible(v37->m_rightArrow, 1);
else
m_rightArrow->setVisible(v37->m_rightArrow, 0);
v28 = v37;
LevelBrowserLayer::updateLevelsLabel(v37);
m_searchObject = v28->m_searchObject;
if ( m_searchObject )
m_searchObject->m_total = v28->m_itemCount;
m_pageBtn = v37->m_pageBtn;
setVisible = m_pageBtn->setVisible;
if ( !v37->m_rightArrow->isVisible(v37->m_rightArrow) )
((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v37->m_leftArrow->isVisible)(v37->m_leftArrow);
((void (__fastcall *)(CCMenuItemSpriteExtra *))setVisible)(m_pageBtn);
}
return _stack_chk_guard;
}