//
// GameLevelManager::saveLevel from 0x1000acfe0 to 0x1000ad5fc (1564 bytes)
//
// 7 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x10002a744
// > GameLevelManager::gotoLevelPage @ 0x1000ad738
// > sub_1000B9B2C @ 0x1000ba350
// > sub_1000B9B2C @ 0x1000ba40c
// > sub_1000B9B2C @ 0x1000ba454
// > sub_1000B9B2C @ 0x1000ba4a4
// > sub_1000B9B2C @ 0x1000ba4f4
//
// 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 10:58:37 +0000
//
void __fastcall GameLevelManager::saveLevel(_QWORD *a1, __int64 a2)
{
int v4; // w24
int v5; // w25
int v6; // w23
_DWORD *SavedLevel_1; // x0
_DWORD *v8; // x21
bool v9; // zf
int v10; // w22
float v11; // s0
int v12; // w22
float v13; // s0
int v14; // w22
float v15; // s0
int v16; // w22
float v17; // s0
int v18; // w27
float v19; // s0
int v20; // w27
float v21; // s0
int v22; // w27
int v23; // w8
__int64 v24; // x9
int v25; // w8
int v26; // w8
_BOOL4 v27; // w22
int v28; // w22
float v29; // s0
__int64 v30; // x20
__int64 v31; // x0
char *CString; // x0
__int64 v33; // x20
__int64 v34; // x0
char *v35; // x0
std::string v36; // [xsp+10h] [xbp-D0h] BYREF
void *__p[2]; // [xsp+28h] [xbp-B8h] BYREF
char v38; // [xsp+3Fh] [xbp-A1h]
void *__dst[2]; // [xsp+40h] [xbp-A0h] BYREF
__int64 v40; // [xsp+50h] [xbp-90h]
std::string __str; // [xsp+60h] [xbp-80h] BYREF
v4 = *(_DWORD *)(a2 + 920);
v5 = *(_DWORD *)(a2 + 924);
v6 = *(unsigned __int8 *)(a2 + 649);
SavedLevel_1 = (_DWORD *)GameLevelManager::getSavedLevel_1((__int64)a1, a2);
v8 = SavedLevel_1;
if ( v4 <= v5 )
{
if ( v6 )
v9 = SavedLevel_1 == nullptr;
else
v9 = 1;
if ( v9 )
{
if ( !SavedLevel_1 )
goto LABEL_58;
goto LABEL_12;
}
}
else if ( !SavedLevel_1 )
{
goto LABEL_57;
}
if ( SavedLevel_1[82] - SavedLevel_1[83] != *(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332) )
goto LABEL_56;
LABEL_12:
v10 = SavedLevel_1[199] - SavedLevel_1[200];
*(_DWORD *)(a2 + 804) = v10;
v11 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 800) = (int)v11;
*(_DWORD *)(a2 + 796) = v10 + (int)v11;
*(_DWORD *)(a2 + 1532) = v8[383];
v12 = v8[202] - v8[203];
*(_DWORD *)(a2 + 816) = v12;
v13 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 812) = (int)v13;
*(_DWORD *)(a2 + 808) = v12 + (int)v13;
v14 = v8[205] - v8[206];
*(_DWORD *)(a2 + 828) = v14;
v15 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 824) = (int)v15;
*(_DWORD *)(a2 + 820) = v14 + (int)v15;
v16 = v8[208] - v8[209];
*(_DWORD *)(a2 + 840) = v16;
v17 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 836) = (int)v17;
*(_DWORD *)(a2 + 832) = v16 + (int)v17;
*(_BYTE *)(a2 + 848) = *((_BYTE *)v8 + 848);
*(_DWORD *)(a2 + 844) = v8[211];
if ( *((char *)v8 + 1231) < 0 )
sub_1000097D0(&__str, *((void **)v8 + 151), *((_QWORD *)v8 + 152));
else
__str = *(std::string *)(v8 + 302);
std::string::operator=((std::string *)(a2 + 1208), &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v18 = v8[215] - v8[214];
*(_DWORD *)(a2 + 852) = v18;
v19 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 856) = (int)v19;
*(_DWORD *)(a2 + 860) = v18 + (int)v19;
*(_DWORD *)(a2 + 888) = v8[222];
v20 = v8[216] - v8[217];
*(_DWORD *)(a2 + 872) = v20;
v21 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 868) = (int)v21;
*(_DWORD *)(a2 + 864) = v20 + (int)v21;
v22 = v8[219] - v8[220];
*(_DWORD *)(a2 + 884) = v22;
v23 = (int)(float)(vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0);
*(_DWORD *)(a2 + 880) = v23;
*(_DWORD *)(a2 + 876) = v22 + v23;
*(_OWORD *)(a2 + 1296) = *((_OWORD *)v8 + 81);
std::string::operator=((std::string *)(a2 + 1312), (const std::string *)(v8 + 328));
*(_OWORD *)(a2 + 1336) = *(_OWORD *)(v8 + 334);
std::string::operator=((std::string *)(a2 + 1352), (const std::string *)(v8 + 338));
*(_DWORD *)(a2 + 1376) = v8[344];
*(_WORD *)(a2 + 1432) = *((_WORD *)v8 + 716);
*(_DWORD *)(a2 + 1436) = v8[359];
*(_BYTE *)(a2 + 1528) = *((_BYTE *)v8 + 1528);
*(_DWORD *)(a2 + 1536) = v8[384];
std::string::operator=((std::string *)(a2 + 1544), (const std::string *)(v8 + 386));
std::string::operator=((std::string *)(a2 + 1568), (const std::string *)(v8 + 392));
std::string::operator=((std::string *)(a2 + 1592), (const std::string *)(v8 + 398));
std::string::operator=((std::string *)(a2 + 1616), (const std::string *)(v8 + 404));
*(_OWORD *)(a2 + 1640) = *(_OWORD *)(v8 + 410);
*(_DWORD *)(a2 + 1656) = v8[414];
std::string::operator=((std::string *)(a2 + 1664), (const std::string *)(v8 + 416));
std::string::operator=((std::string *)(a2 + 1688), (const std::string *)(v8 + 422));
*(_BYTE *)(a2 + 1712) = *((_BYTE *)v8 + 1712);
*(_DWORD *)(a2 + 1748) = v8[437];
std::string::operator=((std::string *)(a2 + 1784), (const std::string *)(v8 + 446));
*(_DWORD *)(a2 + 1808) = v8[452];
std::string::operator=((std::string *)(a2 + 1816), (const std::string *)(v8 + 454));
*(_DWORD *)(a2 + 1840) = v8[460];
*(_BYTE *)(a2 + 1844) = *((_BYTE *)v8 + 1844);
*(_DWORD *)(a2 + 1848) = v8[462];
if ( v8[197] == *(_DWORD *)(a2 + 788) )
{
std::string::operator=((std::string *)(a2 + 1720), (const std::string *)(v8 + 430));
*(_BYTE *)(a2 + 1744) = *((_BYTE *)v8 + 1744);
}
if ( (*((_BYTE *)v8 + 769) & 1) != 0 || v8[215] > v8[214] )
goto LABEL_24;
v24 = *((char *)v8 + 1495);
if ( v24 < 0 )
v24 = *((_QWORD *)v8 + 185);
if ( v24 )
LABEL_24:
*(_BYTE *)(a2 + 769) = *((_BYTE *)v8 + 769);
v25 = v8[158];
if ( v25 > *(_DWORD *)(a2 + 632) )
*(_DWORD *)(a2 + 632) = v25;
if ( *((_BYTE *)v8 + 912) == 1 )
*(_BYTE *)(a2 + 912) = 1;
v26 = v8[229];
if ( v26 >= 1 )
*(_DWORD *)(a2 + 916) = v26;
if ( *((_BYTE *)v8 + 650) == 1 )
*(_BYTE *)(a2 + 650) = 1;
if ( *(char *)(a2 + 439) < 0 )
{
sub_1000097D0(__dst, *(void **)(a2 + 416), *(_QWORD *)(a2 + 424));
}
else
{
*(_OWORD *)__dst = *(_OWORD *)(a2 + 416);
v40 = *(_QWORD *)(a2 + 432);
}
sub_100009900(__p, "-");
v27 = sub_1000045BC(__dst, __p);
if ( v38 < 0 )
operator delete(__p[0]);
if ( SHIBYTE(v40) < 0 )
{
operator delete(__dst[0]);
if ( !v27 )
goto LABEL_47;
}
else if ( !v27 )
{
goto LABEL_47;
}
if ( *((char *)v8 + 439) < 0 )
sub_1000097D0(&v36, *((void **)v8 + 52), *((_QWORD *)v8 + 53));
else
v36 = *(std::string *)(v8 + 104);
std::string::operator=((std::string *)(a2 + 416), &v36);
if ( SHIBYTE(v36.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v36.__r_.__value_.__l.__data_);
LABEL_47:
if ( *(_DWORD *)(a2 + 588) == *(_DWORD *)(a2 + 592) )
{
v28 = v8[147] - v8[148];
*(_DWORD *)(a2 + 596) = v28;
v29 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
*(_DWORD *)(a2 + 592) = (int)v29;
*(_DWORD *)(a2 + 588) = v28 + (int)v29;
}
if ( v8[197] == *(_DWORD *)(a2 + 788) )
{
if ( (*(char *)(a2 + 1495) & 0x8000000000000000LL) != 0 )
{
if ( !*(_QWORD *)(a2 + 1480) )
{
LABEL_55:
std::string::operator=((std::string *)(a2 + 1472), (const std::string *)(v8 + 368));
std::string::operator=((std::string *)(a2 + 1496), (const std::string *)(v8 + 374));
*(_QWORD *)(a2 + 1520) = *((_QWORD *)v8 + 190);
goto LABEL_56;
}
}
else if ( !*(_BYTE *)(a2 + 1495) )
{
goto LABEL_55;
}
if ( v8[381] <= *(_DWORD *)(a2 + 1524) )
goto LABEL_56;
goto LABEL_55;
}
LABEL_56:
if ( v4 > v5 )
{
LABEL_57:
v30 = a1[106];
v31 = sub_1003065B0("%i", *(_DWORD *)(a2 + 920) - *(_DWORD *)(a2 + 924));
CString = (char *)cocos2d::CCString::getCString(v31);
sub_100009900(__dst, CString);
cocos2d::CCDictionary::setObject(v30, a2, __dst);
goto LABEL_62;
}
LABEL_58:
if ( v6 )
v33 = a1[117];
else
v33 = a1[95];
v34 = sub_1003065B0("%i", *(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332));
v35 = (char *)cocos2d::CCString::getCString(v34);
sub_100009900(__dst, v35);
cocos2d::CCDictionary::setObject(v33, a2, __dst);
LABEL_62:
if ( SHIBYTE(v40) < 0 )
operator delete(__dst[0]);
}