//
// GameLevelManager::getMainLevel from 0x814c4c to 0x814ff4 (936 bytes)
//
// 23 xrefs:
// > GameManager::verifyStarUnlocks @ 0x714b4c
// > GameManager::verifySyncedCoins @ 0x714bc0
// > GameManager::verifySyncedCoins @ 0x714c80
// > GameManager::verifyCoinUnlocks @ 0x723268
// > GameManager::verifyCoinUnlocks @ 0x723328
// > GameManager::recountUserStats @ 0x7268b4
// > GameManager::dataLoaded @ 0x727db8
// > GameManager::dataLoaded @ 0x727ff8
// > GameManager::dataLoaded @ 0x72801c
// > GameManager::dataLoaded @ 0x728040
// > LevelSelectLayer::init @ 0x8c53f0
// > GameStatsManager::getTotalCollectedCurrency @ 0x8ce498
// > GameStatsManager::getTotalCollectedCurrency @ 0x8ce4c0
// > GameStatsManager::getTotalCollectedCurrency @ 0x8ce518
// > GameStatsManager::awardOldSpecialStats @ 0x8ea340
// > SecretLayer2::onSecretLevel @ 0xa8c138
// > SecretLayer2::init @ 0xa90c00
// > GJWorldNode::init @ 0xaa7358
// > GJWorldNode::unlockActiveItem @ 0xaa89c4
// > GJWorldNode::onLevel @ 0xaa9d9c
// > LevelAreaInnerLayer::playStep1 @ 0xb5b89c
// > LevelAreaInnerLayer::init @ 0xb5ca78
// > ??> @ 0x83b00
//
// This function is hookable on this platform (idp: arm, 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 12:54:54 +0000
//
__int64 __fastcall GameLevelManager::getMainLevel(GameLevelManager *this, const char *a2, unsigned __int8 a3)
{
unsigned int v4; // w23
__int64 v6; // x19
size_t v7; // x0
__int64 v8; // x19
__int64 Level; // x0
__int64 v10; // x20
size_t v11; // x1
__int64 *v12; // x0
int v13; // w24
float v14; // s0
size_t v15; // x1
__int64 *v16; // x0
int v17; // w24
float v18; // s0
size_t v19; // x1
__int64 *v20; // x0
float v21; // s0
__int64 v23; // x20
const char *v24; // x0
size_t v25; // x0
char *LevelKey; // [xsp+58h] [xbp+58h]
char *v27; // [xsp+58h] [xbp+58h]
__int64 v28; // [xsp+60h] [xbp+60h] BYREF
size_t v29; // [xsp+68h] [xbp+68h]
void *v30; // [xsp+70h] [xbp+70h]
v4 = (unsigned int)a2;
v6 = *((_QWORD *)this + 93);
v28 = 0;
LevelKey = (char *)GameLevelManager::getLevelKey(this, a2);
v29 = 0;
v30 = nullptr;
v7 = strlen(LevelKey);
std::string::__init(&v28, LevelKey, v7);
v8 = cocos2d::CCDictionary::objectForKey(v6, &v28);
if ( (v28 & 1) != 0 )
operator delete(v30);
Level = LevelTools::getLevel((LevelTools *)v4, a3);
v10 = Level;
if ( v8 )
{
v28 = 0;
v29 = 0;
v30 = nullptr;
if ( (*(_BYTE *)(Level + 392) & 1) != 0 )
{
std::string::__init(&v28, *(void **)(Level + 408), *(_QWORD *)(Level + 400));
}
else
{
v11 = *(_QWORD *)(Level + 400);
v28 = *(_QWORD *)(Level + 392);
v29 = v11;
v30 = *(void **)(Level + 408);
}
v12 = (__int64 *)(v8 + 392);
if ( (__int64 *)(v8 + 392) != &v28 )
{
if ( (v28 & 1) != 0 )
std::string::assign(v12, v30, v29);
else
std::string::assign(v12, (char *)&v28 + 1, (unsigned __int8)v28 >> 1);
}
if ( (v28 & 1) != 0 )
operator delete(v30);
v13 = *(_DWORD *)(v10 + 948) - *(_DWORD *)(v10 + 952);
*(_DWORD *)(v8 + 956) = v13;
v14 = (float)((float)rand() * 4.6566e-10) * 1000.0;
*(_DWORD *)(v8 + 952) = (int)v14;
*(_DWORD *)(v8 + 948) = v13 + (int)v14;
*(_DWORD *)(v8 + 964) = *(_DWORD *)(v10 + 964);
*(_DWORD *)(v8 + 1108) = *(_DWORD *)(v10 + 1108);
v28 = 0;
v29 = 0;
v30 = nullptr;
if ( (*(_BYTE *)(v10 + 344) & 1) != 0 )
{
std::string::__init(&v28, *(void **)(v10 + 360), *(_QWORD *)(v10 + 352));
}
else
{
v15 = *(_QWORD *)(v10 + 352);
v28 = *(_QWORD *)(v10 + 344);
v29 = v15;
v30 = *(void **)(v10 + 360);
}
v16 = (__int64 *)(v8 + 344);
if ( (__int64 *)(v8 + 344) != &v28 )
{
if ( (v28 & 1) != 0 )
std::string::assign(v16, v30, v29);
else
std::string::assign(v16, (char *)&v28 + 1, (unsigned __int8)v28 >> 1);
}
if ( (v28 & 1) != 0 )
operator delete(v30);
*(_DWORD *)(v8 + 604) = *(_DWORD *)(v10 + 604);
*(_BYTE *)(v8 + 1000) = *(_BYTE *)(v10 + 1000);
v17 = *(_DWORD *)(v10 + 932) - *(_DWORD *)(v10 + 936);
*(_DWORD *)(v8 + 940) = v17;
v18 = (float)((float)rand() * 4.6566e-10) * 1000.0;
*(_DWORD *)(v8 + 936) = (int)v18;
*(_DWORD *)(v8 + 932) = v17 + (int)v18;
*(_DWORD *)(v8 + 600) = *(_DWORD *)(v10 + 600);
v28 = 0;
v29 = 0;
v30 = nullptr;
if ( (*(_BYTE *)(v10 + 1176) & 1) != 0 )
{
std::string::__init(&v28, *(void **)(v10 + 1192), *(_QWORD *)(v10 + 1184));
}
else
{
v19 = *(_QWORD *)(v10 + 1184);
v28 = *(_QWORD *)(v10 + 1176);
v29 = v19;
v30 = *(void **)(v10 + 1192);
}
v20 = (__int64 *)(v8 + 1176);
if ( (__int64 *)(v8 + 1176) != &v28 )
{
if ( (v28 & 1) != 0 )
std::string::assign(v20, v30, v29);
else
std::string::assign(v20, (char *)&v28 + 1, (unsigned __int8)v28 >> 1);
}
if ( (v28 & 1) != 0 )
operator delete(v30);
*(_DWORD *)(v8 + 336) = v4;
v21 = (float)((float)rand() * 4.6566e-10) * 1000.0;
*(_DWORD *)(v8 + 332) = (int)v21;
*(_DWORD *)(v8 + 328) = v4 + (int)v21;
*(_DWORD *)(v8 + 1232) = *(_DWORD *)(v10 + 1232);
*(_DWORD *)(v8 + 900) = *(_DWORD *)(v10 + 900);
}
else
{
v8 = LevelTools::getLevel((LevelTools *)v4, 0);
v23 = *((_QWORD *)this + 93);
v24 = (const char *)GameLevelManager::getLevelKey(this, (const char *)v4);
v28 = 0;
v27 = (char *)v24;
v29 = 0;
v30 = nullptr;
v25 = strlen(v24);
std::string::__init(&v28, v27, v25);
cocos2d::CCDictionary::setObject(v23, (cocos2d::CCObject *)v8);
if ( (v28 & 1) != 0 )
operator delete(v30);
}
return v8;
}