//
// GameLevelManager::downloadLevel from 0x1000b93b4 to 0x1000b9830 (1148 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x10002a76c
// > DailyLevelPage::dailyStatusFinished @ 0x10024ff64
// > DailyLevelPage::downloadAndCreateNode @ 0x10025007c
// > DailyLevelPage::skipDailyLevel @ 0x10025094c
// > LevelBrowserLayer::claimRecallChest @ 0x10049b73c
//
// 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:43 +0000
//
void __fastcall GameLevelManager::downloadLevel(__int64 a1, __int64 a2, int a3, int a4)
{
__int64 v7; // x0
char *CString; // x20
__int64 v9; // x0
int v10; // w22
__int64 v11; // x0
const char *v12; // x0
int v13; // w24
__int64 v14; // x0
const std::string::value_type *v15; // x0
std::string *v16; // x0
__int64 v17; // x0
const std::string::value_type *v18; // x0
char *v19; // x8
__int64 v20; // x0
const std::string::value_type *v21; // x0
const char *v22; // x22
const std::string::value_type *v23; // x1
std::string *v24; // x0
__int64 v25; // x0
int v26; // w23
int v27; // w25
char *v28; // x0
char *v29; // x26
__int64 v30; // x0
int v31; // w27
int v32; // w28
__int64 v33; // x0
const char *v34; // x0
__int64 v35; // x0
char *v36; // x0
void **v37; // x21
size_t v38; // x0
void **v39; // x1
std::string::size_type v40; // x2
std::string *v41; // x1
void *v42[2]; // [xsp+38h] [xbp-178h] BYREF
char v43; // [xsp+4Fh] [xbp-161h]
void *v44[2]; // [xsp+50h] [xbp-160h] BYREF
char v45; // [xsp+67h] [xbp-149h]
std::string v46; // [xsp+68h] [xbp-148h] BYREF
void *__p[2]; // [xsp+80h] [xbp-130h] BYREF
char v48; // [xsp+97h] [xbp-119h]
void *v49[2]; // [xsp+98h] [xbp-118h] BYREF
char v50; // [xsp+AFh] [xbp-101h]
void *v51[2]; // [xsp+B0h] [xbp-100h] BYREF
unsigned __int8 v52; // [xsp+C7h] [xbp-E9h]
void *v53[2]; // [xsp+C8h] [xbp-E8h] BYREF
char v54; // [xsp+DFh] [xbp-D1h]
void *v55[2]; // [xsp+E0h] [xbp-D0h] BYREF
char v56; // [xsp+F7h] [xbp-B9h]
std::string v57; // [xsp+F8h] [xbp-B8h] BYREF
char __s[16]; // [xsp+110h] [xbp-A0h] BYREF
__int64 v59; // [xsp+120h] [xbp-90h]
_BYTE v60[20]; // [xsp+13Ch] [xbp-74h] BYREF
v7 = sub_1003065B0("%i_%i_%i", a2, a3, a4);
CString = (char *)cocos2d::CCString::getCString(v7);
if ( sub_1000ADBAC(a1, CString) )
return;
sub_1000ADC1C(a1, CString);
v9 = sub_1000B9948(a1, a2);
v10 = v9;
GameLevelManager::getBasePostString(v9, &v57);
v11 = sub_1003065B0("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, "7");
v12 = (const char *)cocos2d::CCString::getCString(v11);
v13 = v10 ^ 1;
v14 = sub_1003065B0("&levelID=%i&inc=%i&secret=%s", a2, v10 ^ 1u, v12);
v15 = (const std::string::value_type *)cocos2d::CCString::getCString(v14);
v16 = std::string::append(&v57, v15);
if ( (int)a2 >= 1 && a4 >= 1 )
{
v17 = sub_1003065B0("&dailyID=%i", a4);
v18 = (const std::string::value_type *)cocos2d::CCString::getCString(v17);
v16 = std::string::append(&v57, v18);
}
if ( (int)a2 >= 1
&& a4 >= 200001
&& ((sub_1000B99D0(__s, v16), v59 >= 0) ? (v19 = __s) : (v19 = *(char **)__s),
v20 = sub_1003065B0("&rchk=%s", v19),
v21 = (const std::string::value_type *)cocos2d::CCString::getCString(v20),
std::string::append(&v57, v21),
SHIBYTE(v59) < 0) )
{
operator delete(*(void **)__s);
if ( (v10 & 1) == 0 )
goto LABEL_12;
}
else if ( (v10 & 1) == 0 )
{
LABEL_12:
sub_100090EE4(10, v55);
std::string::append(&v57, "&rs=");
v22 = (const char *)v55;
if ( v56 >= 0 )
v23 = (const std::string::value_type *)v55;
else
v23 = (const std::string::value_type *)v55[0];
v24 = std::string::append(&v57, v23);
if ( v56 < 0 )
v22 = (const char *)v55[0];
v25 = GJAccountManager::sharedState(v24);
v26 = *(_DWORD *)(v25 + 352);
v27 = *(_DWORD *)(v25 + 356);
v28 = (char *)GameManager::sharedState(v25);
if ( v28[631] < 0 )
{
v28 = (char *)sub_1000097D0(__s, *((void **)v28 + 76), *((_QWORD *)v28 + 77));
}
else
{
*(_OWORD *)__s = *((_OWORD *)v28 + 38);
v59 = *((_QWORD *)v28 + 78);
}
if ( v59 >= 0 )
v29 = __s;
else
v29 = *(char **)__s;
v30 = GameManager::sharedState(v28);
v31 = *(_DWORD *)(v30 + 660);
v32 = *(_DWORD *)(v30 + 664);
v33 = sub_1003065B0("%c%s%s%c%c%s", 120, "I25", "fpAa", 112, 67, "Qg");
v34 = (const char *)cocos2d::CCString::getCString(v33);
v35 = sub_1003065B0("%i%i%s%i%s%i%s", a2, v13, v22, v26 - v27, v29, v31 - v32, v34);
v36 = (char *)cocos2d::CCString::getCString(v35);
sub_100009900(v53, v36);
if ( SHIBYTE(v59) < 0 )
operator delete(*(void **)__s);
if ( v54 >= 0 )
v37 = v53;
else
v37 = (void **)v53[0];
v38 = strlen((const char *)v37);
sub_10011BEE8(v37, v38, v60);
sub_10011C380(v60, __s);
sub_100009900(v49, __s);
sub_100009900(__p, "41274");
cocos2d::ZipUtils::base64EncodeEnc(v51, v49, __p);
if ( v48 < 0 )
operator delete(__p[0]);
if ( v50 < 0 )
operator delete(v49[0]);
std::string::append(&v57, "&chk=");
if ( (v52 & 0x80u) == 0 )
v39 = v51;
else
v39 = (void **)v51[0];
if ( (v52 & 0x80u) == 0 )
v40 = v52;
else
v40 = (std::string::size_type)v51[1];
std::string::append(&v57, (const std::string::value_type *)v39, v40);
if ( (char)v52 < 0 )
operator delete(v51[0]);
if ( v54 < 0 )
operator delete(v53[0]);
if ( v56 < 0 )
operator delete(v55[0]);
}
sub_100009900(&v46, "https://www.boomlings.com/database/downloadGJLevel22.php");
if ( (v57.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v41 = &v57;
else
v41 = (std::string *)v57.__r_.__value_.__r.__words[0];
sub_100009900(v44, (char *)v41);
sub_100009900(v42, CString);
GameLevelManager::ProcessHttpRequest(a1, &v46, (char *)v44, (const std::string::value_type *)v42, 4);
if ( v43 < 0 )
operator delete(v42[0]);
if ( v45 < 0 )
operator delete(v44[0]);
if ( SHIBYTE(v46.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v46.__r_.__value_.__l.__data_);
if ( SHIBYTE(v57.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v57.__r_.__value_.__l.__data_);
}