//
// sub_100870C20 from 0x100870c20 to 0x100871021 (1025 bytes)
//
// 9 xrefs:
// > FRequestProfilePage::init @ 0x10086fc3d
// > sub_1008701D0 @ 0x1008702a0
// > sub_100870B30 @ 0x100870b3d
// > sub_100870B50 @ 0x100870b5d
// > sub_100871160 @ 0x100871167
// > sub_100871860 @ 0x100871958
// > FRequestProfilePage::textChanged @ 0x10087206a
// > FRequestProfilePage::forceReloadRequests @ 0x100872390
// > sub_1008723A0 @ 0x1008723b4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:36:50 +0000
//
void __fastcall sub_100870C20(_DWORD *a1, unsigned int a2)
{
__int64 v3; // rax
__int64 v4; // rsi
const char *v5; // r15
size_t v6; // rax
std::string::size_type v7; // rbx
char *data; // r13
unsigned int v9; // eax
std::string *v10; // r13
size_t v11; // r12
unsigned __int128 v12; // kr00_16
const char *v13; // rbx
unsigned __int64 v14; // r12
const char *v15; // rsi
size_t v16; // rdx
__int64 v17; // rax
__int64 StoredOnlineLevels; // rax
unsigned int *v19; // rax
__int64 v20; // rcx
unsigned __int64 v21; // rax
unsigned __int64 v22; // rcx
__int64 v23; // rax
const char *v24; // rsi
__int64 v25; // rax
std::string *v26; // r12
__int64 v27; // rax
const char *v28; // rsi
__int64 v29; // rax
const char *v30; // rsi
__int64 v31; // rax
size_t v32; // rax
size_t v33; // rbx
char *v34; // r15
void *v35; // rsi
char *v36; // rdx
size_t v37; // r13
char *v38; // rax
char *v39; // rdx
__int64 v40; // [rsp+0h] [rbp-70h]
_QWORD v41[2]; // [rsp+8h] [rbp-68h] BYREF
void *__p; // [rsp+18h] [rbp-58h]
std::string __dst; // [rsp+20h] [rbp-50h] BYREF
void *__src; // [rsp+38h] [rbp-38h]
unsigned int v45; // [rsp+44h] [rbp-2Ch]
v3 = GameLevelManager::sharedState();
v4 = *((unsigned __int8 *)a1 + 704);
v45 = a2;
__src = a1 + 184;
v5 = (const char *)sub_10056BBD0(v3, v4, a2, (__int64)(a1 + 184));
v6 = strlen(v5);
if ( v6 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v7 = v6;
if ( v6 >= 0x17 )
{
v11 = 26;
if ( (v6 | 7) != 0x17 )
v11 = (v6 | 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_ = v7;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v6);
data = __dst.__r_.__value_.__s.__data_;
if ( !v6 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v9 = *((unsigned __int8 *)a1 + 712);
if ( (v9 & 1) == 0 )
goto LABEL_5;
LABEL_11:
v10 = (std::string *)(a1 + 178);
if ( !*((_QWORD *)a1 + 90) )
goto LABEL_29;
goto LABEL_12;
}
}
memmove(data, v5, v7);
data[v7] = 0;
v9 = *((unsigned __int8 *)a1 + 712);
if ( (v9 & 1) != 0 )
goto LABEL_11;
LABEL_5:
v10 = (std::string *)(a1 + 178);
if ( !(v9 >> 1) )
goto LABEL_29;
LABEL_12:
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
{
v13 = (char *)a1 + 713;
v12 = __PAIR128__(
(std::string *)((char *)&__dst.__r_.__value_.__l.0 + 1),
*(_BYTE *)&__dst.__r_.__value_.__l.0 >> 1);
if ( (v9 & 1) == 0 )
goto LABEL_14;
LABEL_16:
v14 = *((_QWORD *)a1 + 90);
v15 = *((const char **)a1 + 91);
goto LABEL_17;
}
v12 = *(_OWORD *)&__dst.__r_.__value_.__r.__words[1];
v13 = (char *)a1 + 713;
if ( (v9 & 1) != 0 )
goto LABEL_16;
LABEL_14:
v14 = (unsigned __int8)v9 >> 1;
v15 = v13;
LABEL_17:
v16 = v12;
if ( v14 < (unsigned __int64)v12 )
v16 = v14;
if ( memcmp(*((const void **)&v12 + 1), v15, v16) || v14 != (_QWORD)v12 )
{
v17 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&v10->__r_.__value_.__s.0 & 1) != 0 )
v13 = *((const char **)a1 + 91);
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v17, v13);
if ( StoredOnlineLevels )
{
v19 = *(unsigned int **)(StoredOnlineLevels + 56);
v20 = *v19;
if ( *v19 )
{
v21 = *((_QWORD *)v19 + 2);
v22 = v21 + 8 * v20 - 8;
do
{
if ( !*(_QWORD *)v21 )
break;
*(_BYTE *)(*(_QWORD *)v21 + 725LL) = 0;
v21 += 8LL;
}
while ( v21 <= v22 );
}
}
sub_100870A20((__int64)a1);
}
LABEL_29:
std::string::operator=(v10, &__dst);
(*(void (__fastcall **)(_QWORD, __int64))(**((_QWORD **)a1 + 99) + 344LL))(*((_QWORD *)a1 + 99), 1);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)a1 + 104) + 344LL))(*((_QWORD *)a1 + 104), 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(**((_QWORD **)a1 + 97) + 344LL))(*((_QWORD *)a1 + 97), 0);
(*(void (__fastcall **)(_QWORD, bool))(**((_QWORD **)a1 + 103) + 344LL))(*((_QWORD *)a1 + 103), (int)v45 > 0);
v23 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&v10->__r_.__value_.__s.0 & 1) != 0 )
v24 = *((const char **)a1 + 91);
else
v24 = (char *)a1 + 713;
v25 = GameLevelManager::getStoredOnlineLevels(v23, v24);
(*(void (__fastcall **)(_QWORD, bool))(**((_QWORD **)a1 + 102) + 344LL))(*((_QWORD *)a1 + 102), v25 != 0);
v26 = v10;
v27 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&v10->__r_.__value_.__s.0 & 1) != 0 )
v28 = *((const char **)a1 + 91);
else
v28 = (char *)a1 + 713;
v40 = GameLevelManager::getStoredOnlineLevels(v27, v28);
if ( !v40 )
{
FRequestProfilePage::setupCommentsBrowser(a1, 0);
v31 = GameLevelManager::sharedState();
GameLevelManager::getFriendRequests(
v31,
*((_BYTE *)a1 + 704),
v45,
a1[226],
(unsigned __int8 *)__src,
*((unsigned __int8 *)a1 + 705));
goto LABEL_56;
}
v29 = GameLevelManager::sharedState();
if ( (*(_BYTE *)&v10->__r_.__value_.__s.0 & 1) != 0 )
v30 = *((const char **)a1 + 91);
else
v30 = (char *)a1 + 713;
__src = (void *)GameLevelManager::getPageInfo(v29, v30);
v32 = strlen((const char *)__src);
if ( v32 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v33 = v32;
if ( v32 >= 0x17 )
{
v37 = 26;
if ( (v32 | 7) != 0x17 )
v37 = (v32 | 7) + 1;
v38 = (char *)operator new(v37);
v35 = __src;
v34 = v38;
__p = v38;
v41[0] = v37 | 1;
v41[1] = v33;
LABEL_48:
memmove(v34, v35, v33);
v34[v33] = 0;
if ( (*(_BYTE *)&v26->__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_44;
LABEL_49:
v36 = *((char **)a1 + 91);
goto LABEL_50;
}
LOBYTE(v41[0]) = 2 * v32;
v34 = (char *)v41 + 1;
v35 = __src;
if ( v32 )
goto LABEL_48;
BYTE1(v41[0]) = 0;
if ( (*(_BYTE *)&v10->__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_49;
LABEL_44:
v36 = (char *)a1 + 713;
LABEL_50:
(*(void (__fastcall **)(_DWORD *, _QWORD *, char *))(*(_QWORD *)a1 + 1416LL))(a1, v41, v36);
if ( (v41[0] & 1) != 0 )
operator delete(__p);
if ( (*(_BYTE *)&v26->__r_.__value_.__s.0 & 1) != 0 )
v39 = *((char **)a1 + 91);
else
v39 = (char *)a1 + 713;
(*(void (__fastcall **)(_DWORD *, __int64, char *))(*(_QWORD *)a1 + 1400LL))(a1, v40, v39);
LABEL_56:
a1[229] = v45;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
}