//
// GameLevelManager::onUpdateUserScoreCompleted from 0x140157650 to 0x140157971 (801 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x14014334b
// > ??> @ 0x1406ca968
//
// 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
//
// Hidden C++ exception states: #wind=6
void __fastcall GameLevelManager::onUpdateUserScoreCompleted(
char *a1,
const wchar_t *a2,
__int64 a3,
struct __crt_locale_pointers *a4)
{
void *v7; // rcx
const wchar_t *v8; // rcx
unsigned __int64 v9; // r14
size_t v10; // r8
int v11; // edi
__int64 v12; // rcx
const wchar_t *v13; // rcx
unsigned __int64 v14; // r14
size_t v15; // r8
int v16; // edi
GameLevelManager *v17; // rcx
const char *v18; // rcx
int v19; // esi
_DWORD *v20; // rdi
float v21; // xmm0_4
__int64 v22; // rax
void (__fastcall ***v23)(_QWORD); // rcx
__int64 v24; // rcx
void *v25; // [rsp+20h] [rbp-60h]
void *v26; // [rsp+20h] [rbp-60h]
void *v27; // [rsp+20h] [rbp-60h]
__int128 Buf2; // [rsp+38h] [rbp-48h] BYREF
__int64 v29; // [rsp+48h] [rbp-38h]
__int64 v30; // [rsp+50h] [rbp-30h]
void *Block[2]; // [rsp+58h] [rbp-28h] BYREF
__int64 v32; // [rsp+68h] [rbp-18h]
unsigned __int64 v33; // [rsp+70h] [rbp-10h]
v32 = 10;
v33 = 15;
Block[0] = *(void **)"user_score";
Block[1] = (void *)*(unsigned __int16 *)"re";
BYTE2(Block[1]) = 0;
cocos2d::CCDictionary::removeObjectForKey(*((_QWORD *)a1 + 73), Block);
if ( v33 > 0xF )
{
v7 = Block[0];
if ( v33 + 1 >= 0x1000 )
{
v7 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v7 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v7);
}
v32 = 0;
v33 = 15;
LOBYTE(Block[0]) = 0;
Buf2 = 0;
v29 = 2;
v30 = 15;
strcpy((char *)&Buf2, "-1");
v8 = a2;
if ( *((_QWORD *)a2 + 3) > 0xFu )
v8 = *(const wchar_t **)a2;
v9 = *((_QWORD *)a2 + 2);
v10 = v9;
if ( v9 > 2 )
v10 = 2;
v11 = memcmp(v8, &Buf2, v10);
if ( !v11 )
{
if ( v9 >= 2 )
v11 = v9 > 2;
else
v11 = -1;
}
if ( v11 )
{
Buf2 = 0;
v29 = 2;
v30 = 15;
strcpy((char *)&Buf2, "-9");
v13 = a2;
if ( *((_QWORD *)a2 + 3) > 0xFu )
v13 = *(const wchar_t **)a2;
v14 = *((_QWORD *)a2 + 2);
v15 = v14;
if ( v14 > 2 )
v15 = 2;
v16 = memcmp(v13, &Buf2, v15);
if ( !v16 )
{
if ( v14 >= 2 )
v16 = v14 > 2;
else
v16 = -1;
}
if ( v16 )
{
v18 = (const char *)a2;
if ( *((_QWORD *)a2 + 3) > 0xFu )
v18 = *(const char **)a2;
v19 = atoi(v18);
v20 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v26 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v20 = (_DWORD *)qword_1406C2ED8;
}
v20[165] = v19;
v21 = (float)((float)rand() / 32767.0) * 1000.0;
v20[164] = (int)v21;
v20[163] = v19 + (int)v21;
}
else
{
v17 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v25 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v17 = (GameLevelManager *)qword_1406C2EC0;
}
GameLevelManager::submitUserInfo(v17);
}
v22 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v27 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v22 = qword_1406C2ED8;
}
*(_BYTE *)(v22 + 648) = 1;
v23 = *((void (__fastcall ****)(_QWORD))a1 + 97);
if ( v23 )
(**v23)(v23);
v24 = *((_QWORD *)a1 + 92);
if ( v24 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v24 + 16LL))(v24);
}
else
{
v12 = *((_QWORD *)a1 + 97);
if ( v12 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v12 + 8LL))(v12);
}
sub_14003A830((__int64)a2);
sub_14003A830(a3);
}