//
// GameLevelManager::onRateStarsCompleted from 0x140154150 to 0x14015433c (492 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x140143218
// > ??> @ 0x1406ca8d8
//
// 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=4
void __fastcall GameLevelManager::onRateStarsCompleted(__int64 a1, const void **a2, const char *a3)
{
const char *v6; // rcx
const void *v7; // rcx
unsigned __int64 v8; // r15
size_t v9; // r8
int v10; // ebp
size_t v11; // rbx
cocos2d::CCString *v12; // rax
const char *CString; // rax
void *v14; // rcx
GameStatsManager *v15; // rcx
int v16; // [rsp+20h] [rbp-78h]
void *v17; // [rsp+20h] [rbp-78h]
__int128 Buf2; // [rsp+38h] [rbp-60h] BYREF
__int64 v19; // [rsp+48h] [rbp-50h]
unsigned __int64 v20; // [rsp+50h] [rbp-48h]
v6 = a3;
if ( *((_QWORD *)a3 + 3) > 0xFu )
v6 = *(const char **)a3;
v16 = atoi(v6);
Buf2 = 0;
v19 = 2;
v20 = 15;
strcpy((char *)&Buf2, "-1");
v7 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v7 = *a2;
v8 = (unsigned __int64)a2[2];
v9 = v8;
if ( v8 > 2 )
v9 = 2;
v10 = memcmp(v7, &Buf2, v9);
v11 = -1;
if ( !v10 )
{
if ( v8 >= 2 )
v10 = v8 > 2;
else
v10 = -1;
}
if ( v10 )
{
v15 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v17 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v15 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::incrementStat(v15, "11", 1);
}
else
{
v12 = cocos2d::CCString::createWithFormat("%i", v16);
CString = cocos2d::CCString::getCString(v12);
Buf2 = 0;
v19 = 0;
v20 = 0;
do
++v11;
while ( CString[v11] );
sub_14003A930(&Buf2, CString, v11);
cocos2d::CCDictionary::removeObjectForKey(*(_QWORD *)(a1 + 400), &Buf2);
if ( v20 > 0xF )
{
v14 = (void *)Buf2;
if ( v20 + 1 >= 0x1000 )
{
v14 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
}
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}