//
// GameLevelManager::createAndGetScores from 0x100532d10 to 0x100532fdb (715 bytes)
//
// 3 xrefs:
// > GameLevelManager::onGetLeaderboardScoresCompleted @ 0x10052091a
// > GameLevelManager::onGetUsersCompleted @ 0x100525f12
// > GameLevelManager::onGetLevelLeaderboardCompleted @ 0x100529656
//
// 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 GameLevelManager::createAndGetScores(__int64 a1, __int64 a2, int a3, __m128 a4)
{
const char *v4; // rbx
size_t v5; // rax
size_t v6; // r14
char *v7; // r15
size_t v8; // r12
__int64 v9; // rbx
unsigned int v10; // r13d
cocos2d::CCString *v11; // rax
const char *CString; // r15
size_t v13; // rax
size_t v14; // r14
char *v15; // rbx
char v16; // r12
__int64 v17; // rax
size_t v18; // r12
cocos2d::CCDictionary *v19; // rax
GJUserScore *v20; // r14
int m_userID; // r15d
int m_accountID; // ebx
std::string *p_m_userName; // r14
__int64 v25; // [rsp+0h] [rbp-A0h]
__int128 v26; // [rsp+10h] [rbp-90h] BYREF
void *v27; // [rsp+20h] [rbp-80h]
__m128 v28; // [rsp+30h] [rbp-70h] BYREF
void *longStorage; // [rsp+40h] [rbp-60h]
__int64 v30; // [rsp+50h] [rbp-50h]
int v31; // [rsp+5Ch] [rbp-44h]
__int128 __dst; // [rsp+60h] [rbp-40h] BYREF
void *__p; // [rsp+70h] [rbp-30h]
v31 = a3;
v30 = sub_10071F9E0(a1, a2);
if ( (*(_BYTE *)a2 & 1) != 0 )
v4 = *(const char **)(a2 + 16);
else
v4 = (const char *)(a2 + 1);
v5 = strlen(v4);
if ( v5 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_38:
sub_100006BF0(*(double *)a4.i64);
v6 = v5;
if ( v5 >= 0x17 )
{
v8 = 26;
if ( (v5 | 7) != 0x17 )
v8 = (v5 | 7) + 1;
v7 = (char *)operator new(v8);
__p = v7;
*(_QWORD *)&__dst = v8 + 1;
*((_QWORD *)&__dst + 1) = v6;
goto LABEL_11;
}
LOBYTE(__dst) = 2 * v5;
v7 = (char *)&__dst + 1;
if ( v5 )
LABEL_11:
memmove(v7, v4, v6);
v7[v6] = 0;
v9 = sub_10052DD30((unsigned __int8 *)&__dst, "|", *(double *)a4.i64);
if ( (__dst & 1) != 0 )
operator delete(__p);
if ( (unsigned int)sub_100720070(v9) )
{
v10 = 0;
v25 = v9;
do
{
v11 = (cocos2d::CCString *)sub_1007200C0(v9, v10);
CString = cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_38;
v14 = v13;
if ( v13 >= 0x17 )
{
v17 = v13 | 7;
v18 = 26;
if ( (v14 | 7) != 0x17 )
v18 = v17 + 1;
v15 = (char *)operator new(v18);
__p = v15;
*(_QWORD *)&__dst = v18 + 1;
*((_QWORD *)&__dst + 1) = v14;
}
else
{
LOBYTE(__dst) = 2 * v13;
v15 = (char *)&__dst + 1;
if ( !v13 )
{
BYTE1(__dst) = 0;
v16 = __dst;
if ( (__dst & 1) != 0 )
goto LABEL_26;
goto LABEL_21;
}
}
memmove(v15, CString, v14);
v15[v14] = 0;
v16 = __dst;
if ( (__dst & 1) != 0 )
{
LABEL_26:
sub_100006B70(&v26, __p, *((unsigned __int64 *)&__dst + 1), *(double *)a4.i64);
goto LABEL_27;
}
LABEL_21:
v27 = __p;
a4.i64[0] = __dst;
v26 = __dst;
LABEL_27:
v19 = GameLevelManager::responseToDict((__int64)&v26, 0, *(double *)a4.i64);
v20 = GJUserScore::create(v19);
if ( (v26 & 1) != 0 )
operator delete(v27);
if ( v20 )
{
v20->m_scoreType = v31;
sub_10071FCD0(v30, v20);
m_userID = v20->m_userID;
m_accountID = v20->m_accountID;
if ( (v20->m_userName.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(
&v28,
v20->m_userName.m_data.m_long.longStorage,
v20->m_userName.m_data.m_long.size,
*(double *)a4.i64);
}
else
{
p_m_userName = &v20->m_userName;
longStorage = p_m_userName->m_data.m_long.longStorage;
a4 = *(__m128 *)&p_m_userName->m_data.m_short.sizex2;
v28 = *(__m128 *)&p_m_userName->m_data.m_short.sizex2;
}
GameLevelManager::storeUserName(a1, m_userID, m_accountID, (__int64)&v28, *(double *)a4.i64);
if ( (v28.i8[0] & 1) != 0 )
operator delete(longStorage);
}
if ( (v16 & 1) != 0 )
operator delete(__p);
++v10;
v9 = v25;
}
while ( v10 < (unsigned int)sub_100720070(v25) );
}
return v30;
}