//
// GameLevelManager::getGJRewards from 0x82bb1c to 0x82c05c (1344 bytes)
//
// 4 xrefs:
// > RewardsPage::tryGetRewards @ 0xa84b04
// > RewardsPage::init @ 0xa86350
// > RewardsPage::onReward @ 0xa8a018
// > ??> @ 0xd6348
//
// 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:55:06 +0000
//
__int64 __fastcall GameLevelManager::getGJRewards(GameLevelManager *this, unsigned int a2)
{
_BOOL4 isDLActive; // w1
__int64 result; // x0
__int64 *BasePostString; // x0
__int64 v5; // x0
cocos2d::CCArray *v6; // x25
int v7; // w24
unsigned int v8; // w21
int v9; // w28
char *v10; // x3
unsigned int v11; // w0
cocos2d::CCString *v12; // x0
const char *CString; // x0
const char *v14; // x23
size_t v15; // x0
size_t v16; // x20
unsigned __int64 v17; // x22
unsigned __int64 v18; // x3
int v19; // w20
int v20; // w0
cocos2d::CCString *v21; // x0
__int64 v22; // x20
char *v23; // x3
cocos2d::CCString *v24; // x0
size_t v25; // x0
const char *v26; // x1
size_t v27; // x0
int v29; // w0
int v31; // w0
int v32; // w0
int v33; // w0
int v36; // [xsp+84h] [xbp+84h]
char *v37; // [xsp+88h] [xbp+88h]
char *v38; // [xsp+88h] [xbp+88h]
__int64 v39[2]; // [xsp+90h] [xbp+90h] BYREF
void *v40; // [xsp+A0h] [xbp+A0h]
void *v41[2]; // [xsp+A8h] [xbp+A8h] BYREF
void *v42; // [xsp+B8h] [xbp+B8h]
unsigned __int64 v43; // [xsp+C0h] [xbp+C0h] BYREF
unsigned __int64 v44; // [xsp+C8h] [xbp+C8h]
void *v45; // [xsp+D0h] [xbp+D0h]
__int64 v46[2]; // [xsp+D8h] [xbp+D8h] BYREF
void *v47; // [xsp+E8h] [xbp+E8h]
__int64 v48[2]; // [xsp+F0h] [xbp+F0h] BYREF
void *v49; // [xsp+100h] [xbp+100h]
isDLActive = GameLevelManager::isDLActive(this, "rew_state");
result = 0;
if ( !isDLActive )
{
GameLevelManager::addDLToActive(this, "rew_state");
BasePostString = GameLevelManager::getBasePostString(v39);
v5 = GameStatsManager::sharedState((GameStatsManager *)BasePostString);
v6 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(v5 + 480));
v7 = cocos2d::CCArray::count(v6);
if ( v7 > 0 )
{
v8 = 0;
v9 = 0;
v36 = 0;
while ( 1 )
{
v12 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v6, v8);
CString = (const char *)cocos2d::CCString::getCString(v12);
v43 = 0;
v14 = CString;
v44 = 0;
v45 = nullptr;
v15 = strlen(CString);
v16 = v15;
if ( v15 > 0xFFFFFFFFFFFFFFEFLL )
sub_62C79C();
if ( v15 <= 0x16 )
{
LOBYTE(v43) = 2 * v15;
v10 = (char *)&v43 + 1;
if ( v15 )
goto LABEL_12;
BYTE1(v43) = 0;
v11 = (unsigned __int8)v43;
if ( (v43 & 1) == 0 )
goto LABEL_13;
LABEL_6:
if ( v44 > 2 )
goto LABEL_14;
LABEL_7:
operator delete(v45);
LABEL_8:
if ( v7 == ++v8 )
goto LABEL_23;
}
else
{
v17 = (v15 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v10 = (char *)operator new(v17);
v45 = v10;
v44 = v16;
v43 = v17 | 1;
LABEL_12:
*((_BYTE *)memcpy(v10, v14, v16) + v16) = 0;
v11 = (unsigned __int8)v43;
if ( (v43 & 1) != 0 )
goto LABEL_6;
LABEL_13:
if ( v11 <= 5 )
goto LABEL_8;
LABEL_14:
std::string::basic_string(v46, (__int64)&v43, 0, 1u);
v18 = (unsigned __int8)v43 >> 1;
if ( (v43 & 1) != 0 )
v18 = v44;
std::string::basic_string(v48, (__int64)&v43, 2u, v18 - 2);
v19 = v46[0] & 1;
if ( v19 )
{
v20 = atoi((const char *)v47);
if ( v20 != 1 )
goto LABEL_18;
}
else
{
v20 = atoi((const char *)v46 + 1);
if ( v20 != 1 )
{
LABEL_18:
if ( v20 == 2 )
{
if ( v48[0] & 1 )
{
v31 = atoi((const char *)v49);
if ( v36 < v31 )
v36 = v31;
goto LABEL_38;
}
v33 = atoi((const char *)v48 + 1);
if ( v36 >= v33 )
v33 = v36;
v36 = v33;
}
else if ( (v48[0] & 1) != 0 )
{
goto LABEL_38;
}
goto LABEL_20;
}
}
if ( v48[0] & 1 )
{
v29 = atoi((const char *)v49);
if ( v9 < v29 )
v9 = v29;
LABEL_38:
operator delete(v49);
if ( (v46[0] & 1) == 0 )
goto LABEL_21;
goto LABEL_39;
}
v32 = atoi((const char *)v48 + 1);
if ( v9 < v32 )
v9 = v32;
LABEL_20:
if ( !v19 )
goto LABEL_21;
LABEL_39:
operator delete(v47);
LABEL_21:
if ( (v43 & 1) != 0 )
goto LABEL_7;
if ( v7 == ++v8 )
goto LABEL_23;
}
}
}
v36 = 0;
v9 = 0;
LABEL_23:
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
v22 = cocos2d::CCString::getCString(v21);
GameLevelManager::rewardSessionToken(v41);
v23 = (char *)v41 + 1;
if ( ((__int64)v41[0] & 1) != 0 )
v23 = (char *)v42;
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&rewardType=%i&secret=%s&chk=%s&r1=%i&r2=%i",
(const char *)a2,
v22,
v23,
(unsigned int)v9,
(unsigned int)v36);
v37 = (char *)cocos2d::CCString::getCString(v24);
v25 = strlen(v37);
std::string::append((__int64)v39, v37, v25);
if ( ((__int64)v41[0] & 1) != 0 )
operator delete(v42);
v43 = 0;
v44 = 0;
v45 = nullptr;
std::string::__init((__int64 *)&v43, "https://www.boomlings.com/database/getGJRewards.php", 0x33u);
v26 = (char *)v39 + 1;
if ( (v39[0] & 1) != 0 )
v26 = (const char *)v40;
v38 = (char *)v26;
v46[0] = 0;
v46[1] = 0;
v47 = nullptr;
v27 = strlen(v26);
std::string::__init(v46, v38, v27);
v48[0] = 0;
v48[1] = 0;
v49 = nullptr;
std::string::__init(v48, "rew_state", 9u);
GameLevelManager::ProcessHttpRequest(this, (__int64 *)&v43, (__int64)v46, (char *)v48, 52);
if ( (v48[0] & 1) != 0 )
operator delete(v49);
if ( (v46[0] & 1) != 0 )
operator delete(v47);
if ( (v43 & 1) != 0 )
operator delete(v45);
if ( (v39[0] & 1) != 0 )
operator delete(v40);
return 1;
}
return result;
}