//
// GameLevelManager::cleanupDailyLevels from 0x140224050 to 0x14022431b (715 bytes)
//
// 2 xrefs:
// > GameLevelManager::encodeDataTo @ 0x140224bcb
// > ??> @ 0x14091bcc8
//
// 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:25 +0000
//
// Hidden C++ exception states: #wind=1
unsigned int __fastcall GameLevelManager::cleanupDailyLevels(__int64 a1)
{
cocos2d::CCArray *v2; // r13
int v3; // r14d
int v4; // r15d
int v5; // r12d
unsigned int v6; // ebp
unsigned int result; // eax
__m128i si128; // xmm6
unsigned int v9; // eax
cocos2d::CCString *v10; // rax
const char *CString; // rax
const char *v12; // rbx
size_t v13; // r8
__int64 v14; // rdi
void *v15; // rcx
int v16; // eax
int v17; // ecx
bool v18; // sf
bool v19; // of
size_t v20; // r8
void *v21; // rcx
__int128 v22; // [rsp+30h] [rbp-68h] BYREF
__m128i v23; // [rsp+40h] [rbp-58h]
v2 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 944));
v3 = 0;
v4 = 0;
v5 = 0;
v6 = 0;
result = cocos2d::CCArray::count(v2);
if ( result )
{
si128 = _mm_load_si128((const __m128i *)&Size);
do
{
v9 = cocos2d::CCArray::count(v2);
v10 = cocos2d::CCArray::objectAtIndex(v2, v9 + ~v6);
CString = cocos2d::CCString::getCString(v10);
v12 = CString;
v22 = 0;
v23 = 0;
v13 = -1;
do
++v13;
while ( CString[v13] );
sub_14003D230(&v22, CString, v13);
v14 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 944), &v22);
if ( v23.m128i_i64[1] > 0xFuLL )
{
v15 = (void *)v22;
if ( (unsigned __int64)(v23.m128i_i64[1] + 1) >= 0x1000 )
{
v15 = *(void **)(v22 - 8);
if ( (unsigned __int64)(v22 - (_QWORD)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
v23 = si128;
LOBYTE(v22) = 0;
v16 = *(_DWORD *)(v14 + 992) - *(_DWORD *)(v14 + 996);
if ( v16 <= 0 )
{
LABEL_25:
v19 = __OFSUB__(v16, v3);
v18 = v16 - v3 < 0;
if ( v16 < v3 )
v16 = v3;
v3 = v16;
LABEL_28:
if ( v18 != v19 )
{
LABEL_29:
*(_WORD *)(v14 + 1184) = 257;
if ( *(_DWORD *)(v14 + 936) - *(_DWORD *)(v14 + 940) <= 0 && !*(_QWORD *)(v14 + 1648) )
{
v22 = 0;
v23 = 0;
v20 = -1;
do
++v20;
while ( v12[v20] );
sub_14003D230(&v22, v12, v20);
cocos2d::CCDictionary::removeObjectForKey(*(_QWORD *)(a1 + 944), &v22);
if ( v23.m128i_i64[1] > 0xFuLL )
{
v21 = (void *)v22;
if ( (unsigned __int64)(v23.m128i_i64[1] + 1) >= 0x1000 )
{
v21 = *(void **)(v22 - 8);
if ( (unsigned __int64)(v22 - (_QWORD)v21 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v21);
}
}
goto LABEL_37;
}
goto LABEL_37;
}
if ( v16 > 200000 )
goto LABEL_14;
if ( v16 <= 100000 )
{
v17 = *(_DWORD *)(a1 + 960);
}
else
{
if ( v16 <= 100000 )
{
if ( v16 > 100000 != 2 )
goto LABEL_37;
LABEL_14:
v17 = *(_DWORD *)(a1 + 984);
goto LABEL_15;
}
v17 = *(_DWORD *)(a1 + 972);
}
LABEL_15:
if ( v16 != v17 )
goto LABEL_37;
if ( v16 <= 100000 )
goto LABEL_25;
if ( v16 <= 200000 )
{
v19 = __OFSUB__(v16, v4);
v18 = v16 - v4 < 0;
if ( v16 < v4 )
v16 = v4;
v4 = v16;
goto LABEL_28;
}
if ( v16 < v5 )
goto LABEL_29;
v5 = *(_DWORD *)(v14 + 992) - *(_DWORD *)(v14 + 996);
LABEL_37:
++v6;
result = cocos2d::CCArray::count(v2);
}
while ( v6 < result );
}
return result;
}