//
// GameLevelManager::onRateDemonCompleted from 0x1005291f0 to 0x1005294b8 (712 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051cf5c
//
// 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
//
void __fastcall GameLevelManager::onRateDemonCompleted(_QWORD *a1, unsigned __int8 *a2, __int64 a3, double a4)
{
const char *v4; // r15
__int64 v5; // r12
size_t v6; // rax
size_t v7; // r13
char *v8; // rbx
size_t v9; // r12
GameLevelManager *v10; // rdi
char *v11; // r15
unsigned int v12; // r13d
unsigned __int64 v13; // r13
const void *v14; // r14
size_t v15; // rbx
__int64 v16; // rdi
__int64 v17; // rbx
cocos2d::CCString *v18; // rax
const char *CString; // r12
size_t v20; // rax
size_t v21; // r14
GameManager *v22; // rbx
float v23; // xmm0_4
__int64 v24; // rdi
void (__fastcall ***v25)(_QWORD, _QWORD, __int64); // rdi
size_t v26; // r13
__int64 v28; // [rsp+8h] [rbp-48h]
unsigned int SplitIntFromKey; // [rsp+8h] [rbp-48h]
size_t __dst; // [rsp+10h] [rbp-40h] BYREF
size_t v31; // [rsp+18h] [rbp-38h]
void *__p; // [rsp+20h] [rbp-30h]
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(const char **)(a3 + 16);
else
v4 = (const char *)(a3 + 1);
v5 = a1[76];
v6 = strlen(v4);
if ( v6 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_38;
v7 = v6;
if ( v6 >= 0x17 )
{
v28 = a1[76];
v9 = 26;
if ( (v6 | 7) != 0x17 )
v9 = (v6 | 7) + 1;
v8 = (char *)operator new(v9);
__p = v8;
__dst = v9 + 1;
v5 = v28;
v31 = v7;
goto LABEL_11;
}
v8 = (char *)&__dst + 1;
LOBYTE(__dst) = 2 * v6;
if ( v6 )
LABEL_11:
memmove(v8, v4, v7);
v8[v7] = 0;
v10 = (GameLevelManager *)v5;
cocos2d::CCDictionary::removeObjectForKey_1(v5, (char *)&__dst);
if ( (__dst & 1) != 0 )
{
v10 = (GameLevelManager *)__p;
operator delete(__p);
}
SplitIntFromKey = GameLevelManager::getSplitIntFromKey(v10, v4, 1);
v11 = (char *)&__dst + 1;
*(_WORD *)((char *)&__dst + 1) = 12589;
BYTE3(__dst) = 0;
v12 = *a2;
if ( (v12 & 1) != 0 )
{
v13 = *((_QWORD *)a2 + 1);
v14 = *((const void **)a2 + 2);
}
else
{
v13 = v12 >> 1;
v14 = a2 + 1;
}
v15 = 2;
if ( v13 < 2 )
v15 = v13;
if ( !((v13 != 2) | (memcmp(v14, (char *)&__dst + 1, v15) != 0)) )
{
v16 = a1[101];
if ( v16 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v16 + 8LL))(v16, SplitIntFromKey, 50);
v17 = a1[52];
v18 = (cocos2d::CCString *)sub_1007AB580("%i", (char)a1);
CString = cocos2d::CCString::getCString(v18);
v20 = strlen(CString);
if ( v20 < 0xFFFFFFFFFFFFFFF8LL )
{
v21 = v20;
if ( v20 >= 0x17 )
{
v26 = 26;
if ( (v20 | 7) != 0x17 )
v26 = (v20 | 7) + 1;
v11 = (char *)operator new(v26);
__p = v11;
__dst = v26 + 1;
v31 = v21;
}
else
{
LOBYTE(__dst) = 2 * v20;
if ( !v20 )
{
LABEL_35:
v11[v21] = 0;
cocos2d::CCDictionary::removeObjectForKey_1(v17, (char *)&__dst);
if ( (__dst & 1) != 0 )
operator delete(__p);
return;
}
}
memmove(v11, CString, v21);
goto LABEL_35;
}
LABEL_38:
sub_100006BF0(a4);
}
*(_WORD *)((char *)&__dst + 1) = 12845;
BYTE3(__dst) = 0;
if ( (v13 != 2) | (memcmp(v14, (char *)&__dst + 1, v15) != 0) )
{
v25 = (void (__fastcall ***)(_QWORD, _QWORD, __int64))a1[101];
if ( v25 )
(**v25)(v25, SplitIntFromKey, 50);
}
else
{
v22 = GameManager::sharedState();
v22->m_hasRP.value = 0;
v23 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v22->m_hasRP.seed = (int)v23;
v22->m_hasRP.random = (int)v23;
v24 = a1[101];
if ( v24 )
(*(void (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v24 + 8LL))(v24, SplitIntFromKey, 50);
}
}