//
// FRequestProfilePage::loadPage from 0x100790da0 to 0x100791191 (1009 bytes)
//
// 5 xrefs:
// > FRequestProfilePage::init @ 0x100790826
// > FRequestProfilePage::onPrevPage @ 0x100790cfd
// > FRequestProfilePage::onNextPage @ 0x100790d1d
// > FRequestProfilePage::forceReloadRequests @ 0x100791d00
// > sub_100791D10 @ 0x100791d24
//
// 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 FRequestProfilePage::loadPage(FRequestProfilePage *a1, int a2)
{
double v2; // xmm0_8
GameLevelManager *v4; // rax
bool m_sent; // si
const char *FriendRequestKey; // r15
size_t v7; // rax
std::string::size_type v8; // rbx
char *data; // r12
unsigned int sizex2; // eax
size_t v11; // r13
std::size_t size; // rcx
unsigned __int128 v13; // kr00_16
std::array *p_shortStorage; // rbx
unsigned __int64 v15; // r12
char *longStorage; // rsi
size_t v17; // rdx
GameLevelManager *v18; // rax
cocos2d::CCArray *StoredOnlineLevels; // rax
cocos2d::ccArray *v20; // rax
__int64 num; // rcx
unsigned __int64 arr; // rax
unsigned __int64 v23; // rcx
GameLevelManager *v24; // rax
std::array *v25; // rsi
cocos2d::CCArray *v26; // rax
GameLevelManager *v27; // rax
std::array *v28; // rsi
GameLevelManager *v29; // rax
std::array *v30; // rsi
GameLevelManager *v31; // rax
const char *PageInfo; // r13
size_t v33; // rax
size_t v34; // rbx
char *v35; // r12
std::array *v36; // rdx
size_t v37; // r15
std::array *v38; // rdx
cocos2d::CCArray *v39; // [rsp+0h] [rbp-70h]
_QWORD v40[2]; // [rsp+8h] [rbp-68h] BYREF
void *__p; // [rsp+18h] [rbp-58h]
std::string __dst; // [rsp+20h] [rbp-50h] BYREF
int v43; // [rsp+3Ch] [rbp-34h]
std::string *p_m_key; // [rsp+40h] [rbp-30h]
v4 = GameLevelManager::sharedState();
m_sent = a1->m_sent;
v43 = a2;
FriendRequestKey = GameLevelManager::getFriendRequestKey(v4, m_sent, a2);
v7 = strlen(FriendRequestKey);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v8 = v7;
if ( v7 >= 0x17 )
{
v11 = 26;
if ( (v7 | 7) != 0x17 )
v11 = (v7 | 7) + 1;
data = (char *)operator new(v11);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v11 + 1;
__dst.__r_.__value_.__l.__size_ = v8;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v7);
data = __dst.__r_.__value_.__s.__data_;
if ( !v7 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
sizex2 = a1->m_key.m_data.m_short.sizex2;
if ( (sizex2 & 1) == 0 )
goto LABEL_5;
LABEL_11:
size = a1->m_key.m_data.m_long.size;
p_m_key = (std::string *)&a1->m_key;
if ( !size )
goto LABEL_28;
goto LABEL_12;
}
}
memmove(data, FriendRequestKey, v8);
data[v8] = 0;
sizex2 = a1->m_key.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
goto LABEL_11;
LABEL_5:
p_m_key = (std::string *)&a1->m_key;
if ( !(sizex2 >> 1) )
goto LABEL_28;
LABEL_12:
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
{
p_shortStorage = &a1->m_key.m_data.m_short.shortStorage;
v13 = __PAIR128__(
(std::string *)((char *)&__dst.__r_.__value_.__l.0 + 1),
*(_BYTE *)&__dst.__r_.__value_.__l.0 >> 1);
if ( (sizex2 & 1) == 0 )
goto LABEL_14;
LABEL_16:
v15 = a1->m_key.m_data.m_long.size;
longStorage = a1->m_key.m_data.m_long.longStorage;
goto LABEL_17;
}
v13 = *(_OWORD *)&__dst.__r_.__value_.__r.__words[1];
p_shortStorage = &a1->m_key.m_data.m_short.shortStorage;
if ( (sizex2 & 1) != 0 )
goto LABEL_16;
LABEL_14:
v15 = (unsigned __int8)sizex2 >> 1;
longStorage = (char *)p_shortStorage;
LABEL_17:
v17 = v13;
if ( v15 < (unsigned __int64)v13 )
v17 = v15;
if ( memcmp(*((const void **)&v13 + 1), longStorage, v17) || v15 != (_QWORD)v13 )
{
v18 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
p_shortStorage = (std::array *)a1->m_key.m_data.m_long.longStorage;
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v18, p_shortStorage->__elems_);
if ( StoredOnlineLevels )
{
v20 = StoredOnlineLevels->data;
num = v20->num;
if ( v20->num )
{
arr = (unsigned __int64)v20->arr;
v23 = arr + 8 * num - 8;
do
{
if ( !*(_QWORD *)arr )
break;
*(_BYTE *)(*(_QWORD *)arr + 689LL) = 0;
arr += 8LL;
}
while ( arr <= v23 );
}
}
}
LABEL_28:
std::string::operator=(p_m_key, &__dst);
((void (__fastcall *)(LoadingCircle *, __int64))a1->m_circle->setVisible)(a1->m_circle, 1);
((void (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))a1->m_refreshButton->setVisible)(a1->m_refreshButton, 0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, _QWORD))a1->m_errorLabel->setVisible)(a1->m_errorLabel, 0);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_prevButton->setVisible)(a1->m_prevButton, v43 > 0);
v24 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
v25 = (std::array *)a1->m_key.m_data.m_long.longStorage;
else
v25 = &a1->m_key.m_data.m_short.shortStorage;
v26 = GameLevelManager::getStoredOnlineLevels(v24, v25->__elems_);
((void (__fastcall *)(CCMenuItemSpriteExtra *, bool))a1->m_nextButton->setVisible)(a1->m_nextButton, v26 != nullptr);
v27 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
v28 = (std::array *)a1->m_key.m_data.m_long.longStorage;
else
v28 = &a1->m_key.m_data.m_short.shortStorage;
v39 = GameLevelManager::getStoredOnlineLevels(v27, v28->__elems_);
if ( !v39 )
{
FRequestProfilePage::setupCommentsBrowser(a1, nullptr);
v31 = GameLevelManager::sharedState();
GameLevelManager::getFriendRequests(v31, a1->m_sent, v43, a1->m_itemCount);
goto LABEL_55;
}
v29 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
v30 = (std::array *)a1->m_key.m_data.m_long.longStorage;
else
v30 = &a1->m_key.m_data.m_short.shortStorage;
PageInfo = GameLevelManager::getPageInfo(v29, v30->__elems_);
v33 = strlen(PageInfo);
if ( v33 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v34 = v33;
if ( v33 >= 0x17 )
{
v37 = 26;
if ( (v33 | 7) != 0x17 )
v37 = (v33 | 7) + 1;
v35 = (char *)operator new(v37);
__p = v35;
v40[0] = v37 | 1;
v40[1] = v34;
LABEL_47:
memmove(v35, PageInfo, v34);
v35[v34] = 0;
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_43;
LABEL_48:
v36 = (std::array *)a1->m_key.m_data.m_long.longStorage;
goto LABEL_49;
}
LOBYTE(v40[0]) = 2 * v33;
v35 = (char *)v40 + 1;
if ( v33 )
goto LABEL_47;
BYTE1(v40[0]) = 0;
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_48;
LABEL_43:
v36 = &a1->m_key.m_data.m_short.shortStorage;
LABEL_49:
((void (__fastcall *)(FRequestProfilePage *, _QWORD *, std::array *))a1->setupPageInfo)(a1, v40, v36);
if ( (v40[0] & 1) != 0 )
operator delete(__p);
if ( (*(_BYTE *)&p_m_key->__r_.__value_.__s.0 & 1) != 0 )
v38 = (std::array *)a1->m_key.m_data.m_long.longStorage;
else
v38 = &a1->m_key.m_data.m_short.shortStorage;
((void (__fastcall *)(FRequestProfilePage *, cocos2d::CCArray *, std::array *))a1->loadFRequestsFinished)(
a1,
v39,
v38);
LABEL_55:
a1->m_page = v43;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
}