//
// GameLevelManager::onRateDemonCompleted from 0x140235d50 to 0x1402360c2 (882 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x14021a548
// > ??> @ 0x14091bfd4
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:28:32 +0000
//
// 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
__int64 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
size_t v20; // r8
int v21; // edi
_DWORD *v22; // rbx
float v23; // xmm0_4
__int64 v24; // rcx
void (__fastcall ***v25)(_QWORD, _QWORD, __int64); // rcx
unsigned int SplitIntFromKey; // [rsp+30h] [rbp-50h]
void *v27; // [rsp+38h] [rbp-48h]
void *Block[2]; // [rsp+50h] [rbp-30h] BYREF
__int64 v29; // [rsp+60h] [rbp-20h]
unsigned __int64 v30; // [rsp+68h] [rbp-18h]
v6 = a3;
if ( a3[3] > 0xFu )
v6 = (_BYTE *)*a3;
*(_OWORD *)Block = 0;
v29 = 0;
v30 = 0;
v7 = -1;
v8 = -1;
do
++v8;
while ( v6[v8] );
sub_14003D230(Block, v6, v8);
cocos2d::CCDictionary::removeObjectForKey(a1[150], Block);
if ( v30 > 0xF )
{
v10 = Block[0];
if ( v30 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v10);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(v9, v6, 1);
*(_OWORD *)Block = 0;
v29 = 2;
v30 = 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;
v29 = 2;
v30 = 15;
strcpy((char *)Block, "-2");
v19 = a2;
if ( (unsigned __int64)a2[3] > 0xF )
v19 = *a2;
v20 = v12;
if ( v12 > 2 )
v20 = 2;
v21 = memcmp(v19, Block, v20);
if ( !v21 )
{
if ( v12 >= 2 )
v21 = v12 > 2;
else
v21 = -1;
}
if ( v21 )
{
v25 = (void (__fastcall ***)(_QWORD, _QWORD, __int64))a1[186];
if ( v25 )
(**v25)(v25, SplitIntFromKey, 56);
}
else
{
v22 = (_DWORD *)qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v27 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v22 = (_DWORD *)qword_14090BFD0;
}
v22[268] = 0;
v23 = (float)((float)rand() / 32767.0) * 1000.0;
v22[267] = (int)v23;
v22[266] = (int)v23;
v24 = a1[186];
if ( v24 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v24 + 8LL))(v24, SplitIntFromKey, 56);
}
}
else
{
v15 = a1[186];
if ( v15 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v15 + 8LL))(v15, SplitIntFromKey, 56);
v16 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, SplitIntFromKey);
CString = cocos2d::CCString::getCString(v16);
*(_OWORD *)Block = 0;
v29 = 0;
v30 = 0;
do
++v7;
while ( CString[v7] );
sub_14003D230(Block, CString, v7);
cocos2d::CCDictionary::removeObjectForKey(a1[114], Block);
if ( v30 > 0xF )
{
v18 = Block[0];
if ( v30 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v18);
}
}
sub_14003D310((__int64)a2);
sub_14003D310((__int64)a3);
}