//
// MessagesProfilePage::setupPageInfo from 0x1001cd684 to 0x1001cd8f4 (624 bytes)
//
// 2 xrefs:
// > sub_1001CD944 @ 0x1001cd948
// > ??> @ 0x1007ba7d0
//
// 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 MessagesProfilePage::setupPageInfo(MessagesProfilePage *a1, char *a2, const char *a3)
{
__int64 result; // x0
_QWORD *v6; // x0
__int64 v7; // x20
std::string *p_str; // x8
std::string::size_type size; // x22
std::string *v10; // x9
std::string::size_type v11; // x11
std::string *v12; // x10
__int64 v13; // x8
__int64 v14; // x23
std::string::size_type v15; // x21
std::string *v16; // x1
__int64 v17; // x0
__int64 v18; // x25
bool v19; // zf
std::string::size_type v20; // x11
std::string *v21; // x8
_BYTE *v22; // x9
_BYTE *v23; // x10
std::string::size_type v24; // x11
__int64 v25; // x8
cocos2d::CCString *v26; // x0
cocos2d::CCString *v27; // x0
cocos2d::CCString *v28; // x0
std::string __str; // [xsp+8h] [xbp-88h] BYREF
std::allocator __a[8]; // [xsp+20h] [xbp-70h] BYREF
char v31; // [xsp+37h] [xbp-59h]
std::string v32; // [xsp+38h] [xbp-58h] BYREF
result = MessagesProfilePage::isCorrect(a1, a3);
if ( !(_DWORD)result )
return result;
if ( a2[23] < 0 )
a2 = *(char **)a2;
v6 = sub_100009900(&__str, a2);
v7 = sub_10024A15C(v6);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_str = &__str;
else
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
else
size = __str.__r_.__value_.__l.__size_;
if ( size )
{
v10 = (std::string *)((char *)p_str + size);
v11 = size;
v12 = p_str;
while ( v12->__r_.__value_.__s.__data_[0] != 58 )
{
v12 = (std::string *)((char *)v12 + 1);
if ( !--v11 )
{
v12 = (std::string *)((char *)p_str + size);
break;
}
}
v13 = (char *)v12 - (char *)p_str;
if ( v12 == v10 )
v14 = -1;
else
v14 = v13;
}
else
{
v14 = -1;
}
v15 = 0;
do
{
std::string::basic_string(&v32, &__str, v15, v14 - v15, __a);
if ( SHIBYTE(v32.__r_.__value_.__r.__words[2]) < 0 )
{
if ( v15 == size && !v32.__r_.__value_.__l.__size_ )
goto LABEL_29;
v16 = (std::string *)v32.__r_.__value_.__r.__words[0];
}
else
{
if ( v15 == size && !*((_BYTE *)&v32.__r_.__value_.__s + 23) )
goto LABEL_29;
v16 = &v32;
}
sub_100009900(__a, (char *)v16);
v17 = sub_100268E48(__a);
sub_10024A2D0(v7, v17);
if ( v31 < 0 )
operator delete(*(void **)&__a[0].std::__non_trivial_if);
LABEL_29:
if ( v14 == -1 )
goto LABEL_30;
v15 = v14 + 1;
v20 = __str.__r_.__value_.__l.__size_;
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v21 = &__str;
else
v21 = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v20 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( v20 <= v15 )
{
LABEL_30:
v18 = -1;
}
else
{
v22 = (char *)v21 + v20;
v23 = (char *)v21 + v15;
v24 = ~v14 + v20;
while ( *v23 != 58 )
{
++v23;
if ( !--v24 )
{
v23 = v22;
break;
}
}
v25 = v23 - (_BYTE *)v21;
if ( v23 == v22 )
v18 = -1;
else
v18 = v25;
}
if ( SHIBYTE(v32.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v32.__r_.__value_.__l.__data_);
v19 = v14 == -1;
v14 = v18;
}
while ( !v19 );
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
result = sub_10024A36C(v7);
if ( (unsigned int)result >= 3 )
{
v26 = (cocos2d::CCString *)sub_10024A388(v7, 0);
a1->m_itemCount = cocos2d::CCString::intValue(v26);
v27 = (cocos2d::CCString *)sub_10024A388(v7, 1);
a1->m_pageStartIdx = cocos2d::CCString::intValue(v27);
v28 = (cocos2d::CCString *)sub_10024A388(v7, 2);
a1->m_pageEndIdx = cocos2d::CCString::intValue(v28);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_prevButton->setVisible)(
a1->m_prevButton,
a1->m_pageStartIdx != 0);
return ((__int64 (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_nextButton->setVisible)(
a1->m_nextButton,
a1->m_pageEndIdx + a1->m_pageStartIdx < a1->m_itemCount);
}
return result;
}