//
// GameLevelManager::userNameForUserID from 0x10052e360 to 0x10052e4da (378 bytes)
//
// 5 xrefs:
// > CommentCell::loadFromComment @ 0x1002478b5
// > LevelBrowserLayer::getSearchTitle @ 0x10049034c
// > LevelBrowserLayer::getSearchTitle @ 0x1004903de
// > GameLevelManager::tryGetUsername @ 0x10052e71c
// > GJGameLevel::create @ 0x10052ffd3
//
// 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
//
_QWORD *__fastcall GameLevelManager::userNameForUserID(_QWORD *a1, __int64 a2, int a3, double a4)
{
__int64 v4; // r14
cocos2d::CCString *v5; // rax
const char *CString; // r12
size_t v7; // rax
size_t v8; // r15
char *v9; // r13
size_t v10; // r14
cocos2d::CCString *v11; // r14
const char *v12; // r15
size_t v13; // rax
size_t v14; // r14
char *v15; // r12
char *v16; // r12
size_t v17; // r13
char v19; // [rsp+0h] [rbp-50h]
__int64 v20; // [rsp+8h] [rbp-48h]
_QWORD __dst[2]; // [rsp+10h] [rbp-40h] BYREF
void *__p; // [rsp+20h] [rbp-30h]
if ( a3 <= 0 )
goto LABEL_17;
v4 = *(_QWORD *)(a2 + 536);
v5 = (cocos2d::CCString *)sub_1007AB580("%i", v19);
CString = cocos2d::CCString::getCString(v5);
v7 = strlen(CString);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_24;
v8 = v7;
if ( v7 >= 0x17 )
{
v20 = v4;
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
v9 = (char *)operator new(v10);
__p = v9;
__dst[0] = v10 + 1;
v4 = v20;
__dst[1] = v8;
goto LABEL_9;
}
LOBYTE(__dst[0]) = 2 * v7;
v9 = (char *)__dst + 1;
if ( v7 )
LABEL_9:
memmove(v9, CString, v8);
v9[v8] = 0;
v11 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(v4, (char *)__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( v11 )
{
v12 = cocos2d::CCString::getCString(v11);
v13 = strlen(v12);
if ( v13 < 0xFFFFFFFFFFFFFFF8LL )
{
v14 = v13;
if ( v13 >= 0x17 )
{
v17 = 26;
if ( (v13 | 7) != 0x17 )
v17 = (v13 | 7) + 1;
v15 = (char *)operator new(v17);
a1[2] = v15;
*a1 = v17 + 1;
a1[1] = v14;
}
else
{
*(_BYTE *)a1 = 2 * v13;
v15 = (char *)a1 + 1;
if ( !v13 )
goto LABEL_22;
}
memmove(v15, v12, v14);
LABEL_22:
v16 = &v15[v14];
goto LABEL_23;
}
LABEL_24:
sub_100006BF0(a4);
}
LABEL_17:
*(_WORD *)a1 = 11522;
v16 = (char *)a1 + 2;
LABEL_23:
*v16 = 0;
return a1;
}