//
// GameLevelManager::getMainLevel from 0x14021bba0 to 0x14021bf77 (983 bytes)
//
// 17 xrefs:
// > GameManager::verifyCoinUnlocks @ 0x14027985f
// > GameManager::verifyCoinUnlocks @ 0x140279947
// > GameManager::recountUserStats @ 0x1402807e8
// > GameManager::dataLoaded @ 0x140283f76
// > GameManager::dataLoaded @ 0x140284087
// > GameManager::dataLoaded @ 0x1402846f1
// > GameManager::dataLoaded @ 0x140284785
// > GameManager::dataLoaded @ 0x140284819
// > GameStatsManager::getTotalCollectedCurrency @ 0x1402e7303
// > GameStatsManager::getTotalCollectedCurrency @ 0x1402e7446
// > GameStatsManager::getTotalCollectedCurrency @ 0x1402e75b6
// > LevelAreaInnerLayer::init @ 0x1403dfb7a
// > LevelAreaInnerLayer::playStep1 @ 0x1403e1763
// > LevelSelectLayer::init @ 0x140441c32
// > SecretLayer2::init @ 0x1405792be
// > SecretLayer2::onSecretLevel @ 0x14057a1db
// > ??> @ 0x14091ba34
//
// 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:23 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GameLevelManager::getMainLevel(__int64 a1, unsigned int a2, unsigned __int8 a3)
{
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // rbx
size_t v9; // r8
__int64 v10; // rdi
void *v11; // rcx
__int64 Level; // rax
__int64 v13; // rsi
cocos2d::CCString *v14; // rax
const char *v15; // rax
void *v16; // rcx
void **v17; // rdx
int v18; // ebx
float v19; // xmm0_4
void **v20; // rdx
int v21; // ebx
float v22; // xmm0_4
void **v23; // rdx
float v24; // xmm0_4
void *Src[4]; // [rsp+38h] [rbp-51h] BYREF
void *v27[4]; // [rsp+58h] [rbp-31h] BYREF
void *v28[4]; // [rsp+78h] [rbp-11h] BYREF
void *Block[2]; // [rsp+98h] [rbp+Fh] BYREF
__m128i si128; // [rsp+A8h] [rbp+1Fh]
v6 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
si128 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003D230(Block, CString, v9);
v10 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 840), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v11 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v11);
}
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
Level = LevelTools::getLevel(a2, a3);
v13 = Level;
if ( v10 )
{
sub_14003F4F0((__int64)Src, Level + 408);
if ( (void **)(v10 + 408) != Src )
{
v17 = Src;
if ( Src[3] > (void *)0xF )
v17 = (void **)Src[0];
sub_1400405A0((void **)(v10 + 408), v17, (size_t)Src[2]);
}
sub_14003D310((__int64)Src);
v18 = *(_DWORD *)(v13 + 1020) - *(_DWORD *)(v13 + 1024);
*(_DWORD *)(v10 + 1028) = v18;
v19 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v10 + 1024) = (int)v19;
*(_DWORD *)(v10 + 1020) = v18 + (int)v19;
*(_DWORD *)(v10 + 1036) = *(_DWORD *)(v13 + 1036);
*(_DWORD *)(v10 + 1188) = *(_DWORD *)(v13 + 1188);
sub_14003F4F0((__int64)v27, v13 + 344);
if ( (void **)(v10 + 344) != v27 )
{
v20 = v27;
if ( v27[3] > (void *)0xF )
v20 = (void **)v27[0];
sub_1400405A0((void **)(v10 + 344), v20, (size_t)v27[2]);
}
sub_14003D310((__int64)v27);
*(_DWORD *)(v10 + 676) = *(_DWORD *)(v13 + 676);
*(_BYTE *)(v10 + 1072) = *(_BYTE *)(v13 + 1072);
v21 = *(_DWORD *)(v13 + 1004) - *(_DWORD *)(v13 + 1008);
*(_DWORD *)(v10 + 1012) = v21;
v22 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v10 + 1008) = (int)v22;
*(_DWORD *)(v10 + 1004) = v21 + (int)v22;
*(_DWORD *)(v10 + 672) = *(_DWORD *)(v13 + 672);
sub_14003F4F0((__int64)v28, v13 + 1264);
if ( (void **)(v10 + 1264) != v28 )
{
v23 = v28;
if ( v28[3] > (void *)0xF )
v23 = (void **)v28[0];
sub_1400405A0((void **)(v10 + 1264), v23, (size_t)v28[2]);
}
sub_14003D310((__int64)v28);
*(_DWORD *)(v10 + 336) = a2;
v24 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v10 + 332) = (int)v24;
*(_DWORD *)(v10 + 328) = a2 + (int)v24;
*(_DWORD *)(v10 + 1336) = *(_DWORD *)(v13 + 1336);
*(_DWORD *)(v10 + 972) = *(_DWORD *)(v13 + 972);
}
else
{
v10 = LevelTools::getLevel(a2, 0);
v14 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, a2);
v15 = cocos2d::CCString::getCString(v14);
*(_OWORD *)Block = 0;
si128 = 0;
do
++v8;
while ( v15[v8] );
sub_14003D230(Block, v15, v8);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 840), v10, Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v16 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v16);
}
}
return v10;
}