//
// LevelBrowserLayer::setupPageInfo from 0x1004908b0 to 0x100490e5d (1453 bytes)
//
// 3 xrefs:
// > sub_100490F50 @ 0x100490f5c
// > ??> @ 0x100918670
// > ??> @ 0x100942a50
//
// 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 LevelBrowserLayer::setupPageInfo(LevelBrowserLayer *a1, __int64 a2, const char *a3, double a4)
{
const char *v5; // rsi
const char *v6; // r14
const char *v7; // rdi
size_t v8; // rax
size_t v9; // r15
char *v10; // r12
size_t v11; // rbx
char *v12; // rax
__int64 v13; // r14
unsigned __int64 v14; // rsi
char *v15; // rdx
unsigned __int64 v16; // rbx
bool v17; // zf
unsigned __int64 v18; // r12
char *v19; // r13
size_t v20; // r12
char *v21; // r15
char v22; // al
const char *v23; // r12
unsigned __int64 v24; // r14
size_t v25; // rbx
size_t v26; // rax
size_t v27; // r13
char *v28; // r15
__int64 v29; // r12
unsigned __int64 v30; // r14
size_t v31; // rbx
__int64 v32; // rax
__int64 v33; // r15
__int64 v34; // rbx
char *v35; // rax
unsigned __int64 v36; // rsi
char *v37; // rdx
unsigned __int64 v38; // rdi
cocos2d::CCString *v39; // rax
int v40; // eax
cocos2d::CCString *v41; // rax
int v42; // eax
cocos2d::CCString *v43; // rax
int v44; // eax
cocos2d::CCString *v45; // rax
const char *CString; // rax
LevelBrowserLayer *v47; // rdx
GJSearchObject *m_searchObject; // rax
CCMenuItemSpriteExtra *m_pageBtn; // r14
LevelBrowserLayer *v50; // rbx
char v51; // cl
unsigned __int8 v52; // al
__int64 v53; // [rsp+0h] [rbp-90h]
_QWORD v54[2]; // [rsp+8h] [rbp-88h] BYREF
void *__p; // [rsp+18h] [rbp-78h]
const char *v56; // [rsp+20h] [rbp-70h]
unsigned __int64 v57; // [rsp+28h] [rbp-68h]
char __s[8]; // [rsp+30h] [rbp-60h] BYREF
size_t v59; // [rsp+38h] [rbp-58h]
void *v60; // [rsp+40h] [rbp-50h]
size_t __dst; // [rsp+48h] [rbp-48h] BYREF
unsigned __int64 v62; // [rsp+50h] [rbp-40h]
void *v63; // [rsp+58h] [rbp-38h]
LevelBrowserLayer *v64; // [rsp+60h] [rbp-30h]
if ( a1->m_unk2 )
return;
v64 = a1;
v5 = a3;
if ( !LevelBrowserLayer::isCorrect(a1, a3) )
return;
if ( (*(_BYTE *)a2 & 1) != 0 )
v6 = *(const char **)(a2 + 16);
else
v6 = (const char *)(a2 + 1);
v7 = v6;
v8 = strlen(v6);
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v9 = v8;
if ( v8 >= 0x17 )
{
v11 = 26;
if ( (v8 | 7) != 0x17 )
v11 = (v8 | 7) + 1;
v10 = (char *)operator new(v11);
v63 = v10;
__dst = v11 + 1;
v62 = v9;
goto LABEL_13;
}
LOBYTE(__dst) = 2 * v8;
v10 = (char *)&__dst + 1;
if ( v8 )
{
LABEL_13:
v7 = v10;
v5 = v6;
memmove(v10, v6, v9);
}
v10[v9] = 0;
v53 = sub_10071F9E0(v7, v5);
if ( (__dst & 1) != 0 )
{
v12 = (char *)v63;
v13 = -1;
v57 = v62;
if ( !v62 )
goto LABEL_24;
LABEL_18:
v14 = v57;
v15 = v12;
while ( *v15 != 58 )
{
++v15;
if ( !--v14 )
{
v15 = &v12[v57];
break;
}
}
v13 = -1;
if ( v15 != &v12[v57] )
v13 = v15 - v12;
goto LABEL_24;
}
v12 = (char *)&__dst + 1;
v13 = -1;
v57 = (unsigned __int8)__dst >> 1;
if ( (unsigned __int8)__dst >> 1 )
goto LABEL_18;
LABEL_24:
v16 = 0;
do
{
if ( (__dst & 1) != 0 )
{
v18 = v62;
if ( v62 < v16 )
LABEL_80:
sub_1000547C0();
v19 = (char *)v63;
}
else
{
v18 = (unsigned __int8)__dst >> 1;
v19 = (char *)&__dst + 1;
if ( v16 > v18 )
goto LABEL_80;
}
v20 = v18 - v16;
if ( v20 >= v13 - v16 )
v20 = v13 - v16;
if ( v20 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
if ( v20 >= 0x17 )
{
v56 = (const char *)v13;
v24 = v16;
v25 = (v20 | 7) + 1;
if ( (v20 | 7) == 0x17 )
v25 = 26;
v21 = (char *)operator new(v25);
v60 = v21;
*(_QWORD *)__s = v25 | 1;
v59 = v20;
v16 = v24;
v13 = (__int64)v56;
}
else
{
__s[0] = 2 * v20;
v21 = &__s[1];
if ( !v20 )
{
__s[1] = 0;
v22 = __s[0];
if ( (__s[0] & 1) == 0 )
goto LABEL_37;
goto LABEL_44;
}
}
memmove(v21, &v19[v16], v20);
v21[v20] = 0;
v22 = __s[0];
if ( (__s[0] & 1) == 0 )
{
LABEL_37:
if ( !v22 && v16 == v57 )
goto LABEL_57;
v23 = &__s[1];
goto LABEL_47;
}
LABEL_44:
if ( !v59 && v16 == v57 )
goto LABEL_57;
v23 = (const char *)v60;
LABEL_47:
v26 = strlen(v23);
if ( v26 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v27 = v26;
if ( v26 >= 0x17 )
{
v56 = v23;
v29 = v13;
v30 = v16;
v31 = (v26 | 7) + 1;
if ( (v26 | 7) == 0x17 )
v31 = 26;
v28 = (char *)operator new(v31);
__p = v28;
v54[0] = v31 | 1;
v54[1] = v27;
v16 = v30;
v13 = v29;
v23 = v56;
LABEL_54:
memmove(v28, v23, v27);
goto LABEL_55;
}
LOBYTE(v54[0]) = 2 * v26;
v28 = (char *)v54 + 1;
if ( v26 )
goto LABEL_54;
LABEL_55:
v28[v27] = 0;
v32 = sub_1007AB360(v54);
sub_10071FCD0(v53, v32);
if ( (v54[0] & 1) != 0 )
operator delete(__p);
LABEL_57:
v33 = v16;
v34 = -1;
if ( v13 == -1 )
goto LABEL_58;
if ( (__dst & 1) != 0 )
{
v35 = (char *)v63;
v36 = v62;
v33 = v13 + 1;
if ( v62 <= v13 + 1 )
goto LABEL_58;
}
else
{
v36 = (unsigned __int8)__dst >> 1;
v35 = (char *)&__dst + 1;
v33 = v13 + 1;
if ( v36 <= v13 + 1 )
goto LABEL_58;
}
v37 = &v35[v33];
v38 = v36 + ~v13;
while ( *v37 != 58 )
{
++v37;
if ( !--v38 )
{
v37 = &v35[v36];
break;
}
}
v34 = v37 - v35;
if ( v37 == &v35[v36] )
v34 = -1;
LABEL_58:
if ( (__s[0] & 1) != 0 )
operator delete(v60);
v17 = v13 == -1;
v13 = v34;
v16 = v33;
}
while ( !v17 );
if ( (__dst & 1) != 0 )
operator delete(v63);
if ( (unsigned int)sub_100720070(v53) >= 3 )
{
v39 = (cocos2d::CCString *)sub_1007200C0(v53, 0);
v40 = cocos2d::CCString::intValue(v39);
v64->m_itemCount = v40;
v41 = (cocos2d::CCString *)sub_1007200C0(v53, 1);
v42 = cocos2d::CCString::intValue(v41);
v64->m_pageStartIdx = v42;
v43 = (cocos2d::CCString *)sub_1007200C0(v53, 2);
v44 = cocos2d::CCString::intValue(v43);
v64->m_pageEndIdx = v44;
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))v64->m_leftArrow->setVisible)(
v64->m_leftArrow,
v64->m_pageStartIdx != 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))v64->m_rightArrow->setVisible)(
v64->m_rightArrow,
v64->m_pageStartIdx + v64->m_pageEndIdx < v64->m_itemCount);
v45 = (cocos2d::CCString *)sub_1007AB580("%i to %i of %i", v53);
CString = cocos2d::CCString::getCString(v45);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))v64->m_countText->setString)(
v64->m_countText,
CString);
cocos2d::CCLabelBMFont::limitLabelWidth(v64->m_countText, 100.0, 0.60000002, 0.0);
LevelBrowserLayer::updatePageLabel(v64);
v47 = v64;
m_searchObject = v64->m_searchObject;
if ( m_searchObject )
m_searchObject->m_total = v64->m_itemCount;
m_pageBtn = v47->m_pageBtn;
v50 = v47;
v51 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v47->m_rightArrow->isVisible)(v47->m_rightArrow);
v52 = 1;
if ( !v51 )
v52 = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *))v50->m_leftArrow->isVisible)(v50->m_leftArrow);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))m_pageBtn->setVisible)(m_pageBtn, v52);
}
}