//
// GameLevelManager::tryGetUsername from 0x14021d970 to 0x14021ddd6 (1126 bytes)
//
// 16 xrefs:
// > ReportPopup::createForComment @ 0x1400bfc44
// > ReportPopup::createForFriendRequest @ 0x1400c00e3
// > CommentOptionsPopup::init @ 0x1400c211d
// > ThreadViewPopup::senderNameFor @ 0x1400e4e5c
// > NewThreadPopup::init @ 0x1400ef2fe
// > NewThreadPopup::threadSendFinished @ 0x1400f364d
// > CommentCell::loadFromComment @ 0x14015208c
// > GJGameLevel::create @ 0x1402630ba
// > FriendRequestPopup::init @ 0x1403a1993
// > FriendRequestPopup::onBlock @ 0x1403a2cdc
// > LevelBrowserLayer::getSearchTitle @ 0x1403e5d3e
// > ProfilePage::init @ 0x140550ec1
// > ProfilePage::onCopyName @ 0x1405560f6
// > ProfilePage::onInfo @ 0x140556335
// > ShareCommentLayer::init @ 0x14062e184
// > ??> @ 0x14091bab8
//
// 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 11:28:23 +0000
//
// Hidden C++ exception states: #wind=4
__int64 __fastcall GameLevelManager::tryGetUsername(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v3; // rbx
unsigned int v6; // r14d
unsigned int v7; // r15d
unsigned int v8; // r12d
cocos2d::CCString *v9; // rax
int v10; // esi
__int64 v11; // rcx
unsigned __int64 v12; // rsi
__int64 v13; // r9
__int64 v14; // rcx
__int64 v15; // r8
size_t *v16; // r8
void *v17; // rdx
__int64 v18; // rcx
struct cocos2d::CCObject *v19; // rax
void *v20; // rdx
__int64 v21; // rcx
__int64 *v22; // rdx
__int64 *v23; // rax
__int64 *v24; // r8
void *v25; // rcx
void **v26; // rcx
_QWORD *v27; // r14
unsigned __int8 v29; // [rsp+30h] [rbp-39h]
void *v30; // [rsp+38h] [rbp-31h]
void *v31; // [rsp+38h] [rbp-31h]
void *v32; // [rsp+38h] [rbp-31h]
void *Block[2]; // [rsp+48h] [rbp-21h] BYREF
__int128 v34; // [rsp+58h] [rbp-11h]
__int128 v35; // [rsp+68h] [rbp-1h] BYREF
__int128 v36; // [rsp+78h] [rbp+Fh]
v3 = (int)a3;
v6 = HIBYTE(a3);
v7 = HIWORD(a3);
v8 = a3 >> 8;
if ( !a3 )
{
*(_OWORD *)a2 = 0;
*(_QWORD *)(a2 + 16) = 1;
*(_QWORD *)(a2 + 24) = 15;
*(_BYTE *)a2 = 45;
*(_BYTE *)(a2 + 1) = 0;
return a2;
}
v9 = cocos2d::CCDictionary::valueForKey(*(cocos2d::CCDictionary **)(a1 + 1072), (int)a3);
v10 = cocos2d::CCString::intValue(v9);
v29 = v3;
v11 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v30 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v30);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v29 = v3;
v11 = *(_QWORD *)&qword_14090BFB0;
}
GameLevelManager::userNameForUserID(v11, Block, v10);
v12 = v34;
if ( (unsigned __int64)v34 < 2 )
{
v13 = *(_QWORD *)(a1 + 1112);
v14 = *(_QWORD *)(v13
+ 16
* (*(_QWORD *)(a1 + 1136)
& (0x100000001B3LL
* ((unsigned __int8)v6
^ (0x100000001B3LL
* ((unsigned __int8)v7
^ (0x100000001B3LL * ((unsigned __int8)v8 ^ (0x100000001B3LL * (v29 ^ 0xCBF29CE484222325uLL)))))))))
+ 8);
v15 = *(_QWORD *)(a1 + 1096);
if ( v14 != v15 )
{
if ( (_DWORD)v3 == *(_DWORD *)(v14 + 16) )
{
LABEL_12:
if ( v14 )
v15 = v14;
if ( v15 != *(_QWORD *)(a1 + 1096) )
{
v16 = (size_t *)(v15 + 24);
if ( Block != (void **)v16 )
{
v17 = v16;
if ( v16[3] > 0xF )
v17 = (void *)*v16;
sub_1400405A0(Block, v17, v16[2]);
v12 = v34;
}
}
if ( v12 < 2 )
{
v18 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v31 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v31);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v18 = *(_QWORD *)&qword_14090BFB0;
}
v19 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v18 + 1232), v3);
if ( v19 && Block != (void **)((char *)v19 + 320) )
{
v20 = (char *)v19 + 320;
if ( *((_QWORD *)v19 + 43) > 0xFu )
v20 = *((void **)v19 + 40);
sub_1400405A0(Block, v20, *((_QWORD *)v19 + 42));
v12 = v34;
}
if ( v12 < 2 )
{
v21 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v32 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480(v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v21 = qword_14090BFE0;
}
v22 = *(__int64 **)(v21 + 960);
v23 = (__int64 *)v22[1];
v24 = v22;
if ( !*((_BYTE *)v23 + 25) )
{
do
{
if ( *((_DWORD *)v23 + 8) >= (int)v3 )
{
v22 = v23;
v23 = (__int64 *)*v23;
}
else
{
v23 = (__int64 *)v23[2];
}
}
while ( !*((_BYTE *)v23 + 25) );
v24 = *(__int64 **)(v21 + 960);
}
if ( *((_BYTE *)v22 + 25) || (int)v3 < *((_DWORD *)v22 + 8) || v22 == v24 )
{
v35 = 0;
*(_QWORD *)&v36 = 0;
*((_QWORD *)&v36 + 1) = 15;
LOBYTE(v35) = 0;
}
else
{
sub_14003F4F0((__int64)&v35, (__int64)(v22 + 5));
}
if ( *((_QWORD *)&v34 + 1) > 0xFu )
{
v25 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v34 + 1) + 1LL) >= 0x1000 )
{
v25 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v25 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v25);
}
*(_OWORD *)Block = v35;
v34 = v36;
v12 = v36;
}
}
goto LABEL_46;
}
while ( v14 != *(_QWORD *)(v13
+ 16
* (*(_QWORD *)(a1 + 1136)
& (0x100000001B3LL
* ((unsigned __int8)v6
^ (0x100000001B3LL
* ((unsigned __int8)v7
^ (0x100000001B3LL
* ((unsigned __int8)v8 ^ (0x100000001B3LL * (v29 ^ 0xCBF29CE484222325uLL)))))))))) )
{
v14 = *(_QWORD *)(v14 + 8);
if ( (_DWORD)v3 == *(_DWORD *)(v14 + 16) )
goto LABEL_12;
}
}
v14 = 0;
goto LABEL_12;
}
LABEL_46:
if ( !v12 )
{
if ( *((_QWORD *)&v34 + 1) )
{
v26 = Block;
if ( *((_QWORD *)&v34 + 1) > 0xFu )
v26 = (void **)Block[0];
*(_QWORD *)&v34 = 1;
*(_BYTE *)v26 = 45;
*((_BYTE *)v26 + 1) = 0;
}
else
{
v27 = sub_14003D460(0x10u);
*(_QWORD *)&v34 = 1;
*((_QWORD *)&v34 + 1) = 15;
*(_WORD *)v27 = 45;
Block[0] = v27;
}
}
*(_QWORD *)(a2 + 16) = 0;
*(_QWORD *)(a2 + 24) = 0;
*(_OWORD *)a2 = *(_OWORD *)Block;
*(_OWORD *)(a2 + 16) = v34;
return a2;
}