//
// GameLevelManager::onRateDemonCompleted from 0x140155780 to 0x140155ace (846 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x140143bbf
// > ??> @ 0x1406ca944
//
// 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::onRateDemonCompleted(_QWORD *a1, const void **a2, _QWORD *a3)
{
_BYTE *v6; // rdi
size_t v7; // rbx
size_t v8; // r8
GameLevelManager *v9; // rcx
void *v10; // rcx
const void *v11; // rcx
unsigned __int64 v12; // r12
size_t v13; // r8
int v14; // edi
__int64 v15; // rcx
cocos2d::CCString *v16; // rax
const char *CString; // rax
void *v18; // rcx
const void *v19; // rcx
unsigned __int64 v20; // r12
size_t v21; // r8
int v22; // edi
_DWORD *v23; // rbx
float v24; // xmm0_4
__int64 v25; // rcx
void (__fastcall ***v26)(_QWORD, _QWORD, __int64); // rcx
unsigned int SplitIntFromKey; // [rsp+24h] [rbp-4Ch]
void *v28; // [rsp+28h] [rbp-48h]
void *Block[2]; // [rsp+40h] [rbp-30h] BYREF
__int64 v30; // [rsp+50h] [rbp-20h]
unsigned __int64 v31; // [rsp+58h] [rbp-18h]
v6 = a3;
if ( a3[3] > 0xFu )
v6 = (_BYTE *)*a3;
*(_OWORD *)Block = 0;
v30 = 0;
v31 = 0;
v7 = -1;
v8 = -1;
do
++v8;
while ( v6[v8] );
sub_14003A930(Block, v6, v8);
cocos2d::CCDictionary::removeObjectForKey(a1[74], Block);
if ( v31 > 0xF )
{
v10 = Block[0];
if ( v31 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(v9, v6, 1);
*(_OWORD *)Block = 0;
v30 = 2;
v31 = 15;
strcpy((char *)Block, "-1");
v11 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v11 = *a2;
v12 = (unsigned __int64)a2[2];
v13 = v12;
if ( v12 > 2 )
v13 = 2;
v14 = memcmp(v11, Block, v13);
if ( !v14 )
{
if ( v12 >= 2 )
v14 = v12 > 2;
else
v14 = -1;
}
if ( v14 )
{
*(_OWORD *)Block = 0;
v30 = 2;
v31 = 15;
strcpy((char *)Block, "-2");
v19 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v19 = *a2;
v20 = (unsigned __int64)a2[2];
v21 = v20;
if ( v20 > 2 )
v21 = 2;
v22 = memcmp(v19, Block, v21);
if ( !v22 )
{
if ( v20 >= 2 )
v22 = v20 > 2;
else
v22 = -1;
}
if ( v22 )
{
v26 = (void (__fastcall ***)(_QWORD, _QWORD, __int64))a1[101];
if ( v26 )
(**v26)(v26, SplitIntFromKey, 50);
}
else
{
v23 = (_DWORD *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v28 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = (_DWORD *)qword_1406C2ED8;
}
v23[255] = 0;
v24 = (float)((float)rand() / 32767.0) * 1000.0;
v23[254] = (int)v24;
v23[253] = (int)v24;
v25 = a1[101];
if ( v25 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v25 + 8LL))(v25, SplitIntFromKey, 50);
}
}
else
{
v15 = a1[101];
if ( v15 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v15 + 8LL))(v15, SplitIntFromKey, 50);
v16 = cocos2d::CCString::createWithFormat("%i", SplitIntFromKey);
CString = cocos2d::CCString::getCString(v16);
*(_OWORD *)Block = 0;
v30 = 0;
v31 = 0;
do
++v7;
while ( CString[v7] );
sub_14003A930(Block, CString, v7);
cocos2d::CCDictionary::removeObjectForKey(a1[51], Block);
if ( v31 > 0xF )
{
v18 = Block[0];
if ( v31 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
}
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}