//
// MessagesProfilePage::setupPageInfo from 0x10022f8d0 to 0x10022fd60 (1168 bytes)
//
// 2 xrefs:
// > sub_10022FE30 @ 0x10022fe3c
// > ??> @ 0x1008e1788
//
// 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
//
char __fastcall MessagesProfilePage::setupPageInfo(MessagesProfilePage *a1, __int64 a2, const char *a3, double a4)
{
const char *v5; // rsi
unsigned int v6; // eax
const char *v7; // r14
const char *v8; // rdi
size_t v9; // rax
size_t v10; // r15
char *v11; // rbx
size_t v12; // r12
char *v13; // rax
unsigned __int64 v14; // r15
__int64 v15; // r14
unsigned __int64 v16; // rsi
char *v17; // rdx
unsigned __int64 v18; // rcx
bool v19; // zf
unsigned __int64 v20; // r12
char *v21; // r13
size_t v22; // r12
char *v23; // rbx
char v24; // al
const char *v25; // r12
size_t v26; // r15
size_t v27; // rax
size_t v28; // r13
char *v29; // rbx
size_t v30; // r15
__int64 v31; // rax
__int64 v32; // rbx
char *v33; // rax
unsigned __int64 v34; // rsi
__int64 v35; // r8
char *v36; // rdx
unsigned __int64 v37; // rdi
cocos2d::CCString *v38; // rax
MessagesProfilePage *v39; // rbx
cocos2d::CCString *v40; // rax
cocos2d::CCString *v41; // rax
unsigned __int64 v44; // [rsp+8h] [rbp-88h]
__int64 v45; // [rsp+10h] [rbp-80h]
_QWORD v46[2]; // [rsp+18h] [rbp-78h] BYREF
void *__p; // [rsp+28h] [rbp-68h]
char __s[8]; // [rsp+30h] [rbp-60h] BYREF
size_t v49; // [rsp+38h] [rbp-58h]
void *v50; // [rsp+40h] [rbp-50h]
__int64 v51; // [rsp+48h] [rbp-48h]
size_t __dst; // [rsp+50h] [rbp-40h] BYREF
unsigned __int64 v53; // [rsp+58h] [rbp-38h]
void *v54; // [rsp+60h] [rbp-30h]
v5 = a3;
LOBYTE(v6) = MessagesProfilePage::isCorrect(a1, a3);
if ( !(_BYTE)v6 )
return v6;
if ( (*(_BYTE *)a2 & 1) != 0 )
v7 = *(const char **)(a2 + 16);
else
v7 = (const char *)(a2 + 1);
v8 = v7;
v9 = strlen(v7);
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v10 = v9;
if ( v9 >= 0x17 )
{
v12 = 26;
if ( (v9 | 7) != 0x17 )
v12 = (v9 | 7) + 1;
v11 = (char *)operator new(v12);
v54 = v11;
__dst = v12 + 1;
v53 = v10;
goto LABEL_12;
}
LOBYTE(__dst) = 2 * v9;
v11 = (char *)&__dst + 1;
if ( v9 )
{
LABEL_12:
v8 = v11;
v5 = v7;
memmove(v11, v7, v10);
}
v11[v10] = 0;
v45 = sub_10071F9E0(v8, v5);
if ( (__dst & 1) != 0 )
{
v13 = (char *)v54;
v14 = v53;
v15 = -1;
if ( !v53 )
goto LABEL_23;
LABEL_17:
v16 = v14;
v17 = v13;
while ( *v17 != 58 )
{
++v17;
if ( !--v16 )
{
v17 = &v13[v14];
break;
}
}
v15 = -1;
if ( v17 != &v13[v14] )
v15 = v17 - v13;
goto LABEL_23;
}
v14 = (unsigned __int8)__dst >> 1;
v13 = (char *)&__dst + 1;
v15 = -1;
if ( (unsigned __int8)__dst >> 1 )
goto LABEL_17;
LABEL_23:
v18 = 0;
v44 = v14;
do
{
if ( (__dst & 1) != 0 )
{
v20 = v53;
if ( v53 < v18 )
LABEL_75:
sub_1000547C0();
v21 = (char *)v54;
}
else
{
v20 = (unsigned __int8)__dst >> 1;
v21 = (char *)&__dst + 1;
if ( v18 > v20 )
goto LABEL_75;
}
v22 = v20 - v18;
if ( v22 >= v15 - v18 )
v22 = v15 - v18;
if ( v22 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v51 = v18;
if ( v22 >= 0x17 )
{
v26 = (v22 | 7) + 1;
if ( (v22 | 7) == 0x17 )
v26 = 26;
v23 = (char *)operator new(v26);
v50 = v23;
*(_QWORD *)__s = v26 | 1;
v49 = v22;
v14 = v44;
}
else
{
__s[0] = 2 * v22;
v23 = &__s[1];
if ( !v22 )
{
__s[1] = 0;
v24 = __s[0];
if ( (__s[0] & 1) == 0 )
goto LABEL_36;
goto LABEL_43;
}
}
memmove(v23, &v21[v51], v22);
v23[v22] = 0;
v24 = __s[0];
if ( (__s[0] & 1) == 0 )
{
LABEL_36:
if ( !v24 && v51 == v14 )
goto LABEL_56;
v25 = &__s[1];
goto LABEL_46;
}
LABEL_43:
if ( !v49 && v51 == v14 )
goto LABEL_56;
v25 = (const char *)v50;
LABEL_46:
v27 = strlen(v25);
if ( v27 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a4);
v28 = v27;
if ( v27 >= 0x17 )
{
v30 = (v27 | 7) + 1;
if ( (v27 | 7) == 0x17 )
v30 = 26;
v29 = (char *)operator new(v30);
__p = v29;
v46[0] = v30 | 1;
v46[1] = v28;
v14 = v44;
LABEL_53:
memmove(v29, v25, v28);
goto LABEL_54;
}
LOBYTE(v46[0]) = 2 * v27;
v29 = (char *)v46 + 1;
if ( v27 )
goto LABEL_53;
LABEL_54:
v29[v28] = 0;
v31 = sub_1007AB360(v46);
sub_10071FCD0(v45, v31);
if ( (v46[0] & 1) != 0 )
operator delete(__p);
LABEL_56:
v32 = -1;
if ( v15 == -1 )
goto LABEL_57;
if ( (__dst & 1) != 0 )
{
v33 = (char *)v54;
v34 = v53;
v35 = v15 + 1;
v51 = v15 + 1;
if ( v53 <= v15 + 1 )
goto LABEL_57;
}
else
{
v34 = (unsigned __int8)__dst >> 1;
v33 = (char *)&__dst + 1;
v35 = v15 + 1;
v51 = v15 + 1;
if ( v34 <= v15 + 1 )
goto LABEL_57;
}
v36 = &v33[v35];
v37 = v34 + ~v15;
while ( *v36 != 58 )
{
++v36;
if ( !--v37 )
{
v36 = &v33[v34];
break;
}
}
v32 = v36 - v33;
if ( v36 == &v33[v34] )
v32 = -1;
LABEL_57:
if ( (__s[0] & 1) != 0 )
operator delete(v50);
v19 = v15 == -1;
v15 = v32;
v18 = v51;
}
while ( !v19 );
if ( (__dst & 1) != 0 )
operator delete(v54);
v6 = sub_100720070(v45);
if ( v6 >= 3 )
{
v38 = (cocos2d::CCString *)sub_1007200C0(v45, 0);
v39 = a1;
a1->m_itemCount = cocos2d::CCString::intValue(v38);
v40 = (cocos2d::CCString *)sub_1007200C0(v45, 1);
a1->m_pageStartIdx = cocos2d::CCString::intValue(v40);
v41 = (cocos2d::CCString *)sub_1007200C0(v45, 2);
a1->m_pageEndIdx = cocos2d::CCString::intValue(v41);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))v39->m_prevButton->setVisible)(
v39->m_prevButton,
v39->m_pageStartIdx != 0);
LOBYTE(v6) = ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *, bool))v39->m_nextButton->setVisible)(
v39->m_nextButton,
v39->m_pageStartIdx + v39->m_pageEndIdx < v39->m_itemCount);
}
return v6;
}