//
// GameLevelManager::getGJRewards from 0x4bc2b8 to 0x4bc546 (654 bytes)
//
// 3 xrefs:
// > RewardsPage::tryGetRewards @ 0x6168fa
// > RewardsPage::init @ 0x617bdc
// > RewardsPage::onReward @ 0x61a0ca
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:50:18 +0000
//
int __fastcall GameLevelManager::getGJRewards(GameLevelManager *this, const char *a2)
{
int v3; // r2
int v4; // r3
GameLevelManager *BasePostString; // r0
int v6; // r0
signed int v7; // r5
int v8; // r8
const char *v9; // r9
cocos2d::CCString *v10; // r0
const char *CString; // r10
size_t v12; // r0
unsigned int v13; // r3
int v14; // r3
char *v15; // r0
char *v16; // r0
char *v17; // r0
char *v18; // r0
const char *v19; // r0
char *v20; // r0
cocos2d::CCString *v21; // r0
int v22; // r10
char *v23; // r3
cocos2d::CCString *v24; // r0
char *v25; // r0
size_t v26; // r0
cocos2d::CCArray *v28; // [sp+14h] [bp-58h]
signed int v29; // [sp+18h] [bp-54h]
int v31; // [sp+24h] [bp-48h]
int v32; // [sp+24h] [bp-48h]
int v33; // [sp+24h] [bp-48h]
char *v34[3]; // [sp+28h] [bp-44h] BYREF
char v35; // [sp+34h] [bp-38h] BYREF
char v36; // [sp+35h] [bp-37h] BYREF
char *v37; // [sp+3Ch] [bp-30h]
int v38; // [sp+40h] [bp-2Ch] BYREF
unsigned int v39; // [sp+44h] [bp-28h]
int v40; // [sp+48h] [bp-24h]
char v41[4]; // [sp+4Ch] [bp-20h] BYREF
int v42; // [sp+50h] [bp-1Ch]
char *v43; // [sp+54h] [bp-18h]
char v44[4]; // [sp+58h] [bp-14h] BYREF
int v45; // [sp+5Ch] [bp-10h]
char *v46; // [sp+60h] [bp-Ch]
if ( GameLevelManager::isDLActive(this, "rew_state") )
return 0;
GameLevelManager::addDLToActive(this, "rew_state", v3, v4);
BasePostString = GameLevelManager::getBasePostString((GameLevelManager *)v34);
v6 = GameStatsManager::sharedState(BasePostString);
v28 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(v6 + 344));
v7 = 0;
v8 = 0;
v9 = nullptr;
v29 = cocos2d::CCArray::count(v28);
while ( v7 < v29 )
{
v10 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v28, v7);
CString = (const char *)cocos2d::CCString::getCString(v10);
v38 = 0;
v39 = 0;
v40 = 0;
v12 = strlen(CString);
std::string::__init(&v38, CString, v12);
if ( (v38 & 1) != 0 )
v13 = v39;
else
v13 = (int)(unsigned __int8)v38 >> 1;
if ( v13 > 2 )
{
std::string::basic_string((int *)v41, (unsigned __int8 *)&v38, 0, 1u);
if ( (v38 & 1) != 0 )
v14 = v39;
else
v14 = (int)(unsigned __int8)v38 >> 1;
std::string::basic_string((int *)v44, (unsigned __int8 *)&v38, 2u, v14 - 2);
v31 = v41[0] & 1;
if ( (v41[0] & 1) != 0 )
v15 = v43;
else
v15 = &v41[1];
if ( atoi(v15) == 1 )
{
v32 = v44[0] & 1;
if ( (v44[0] & 1) != 0 )
v16 = v46;
else
v16 = &v44[1];
if ( (int)v9 < atoi(v16) )
{
if ( v32 )
v17 = v46;
else
v17 = &v44[1];
v9 = (const char *)atoi(v17);
}
}
else
{
if ( v31 )
v18 = v43;
else
v18 = &v41[1];
if ( atoi(v18) == 2 )
{
v33 = v44[0] & 1;
v19 = (v44[0] & 1) != 0 ? v46 : &v44[1];
if ( v8 < atoi(v19) )
{
if ( v33 )
v20 = v46;
else
v20 = &v44[1];
v8 = atoi(v20);
}
}
}
std::string::~string((int)v44);
std::string::~string((int)v41);
}
++v7;
std::string::~string((int)&v38);
}
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_54 + 3,
"mfd",
"2893",
103,
98,
&a1i2r3e45s789g[9]);
v22 = cocos2d::CCString::getCString(v21);
GameLevelManager::rewardSessionToken((GameLevelManager *)&v35);
if ( (v35 & 1) != 0 )
v23 = v37;
else
v23 = &v36;
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&rewardType=%i&secret=%s&chk=%s&r1=%i&r2=%i",
a2,
v22,
v23,
v9,
v8);
v25 = (char *)cocos2d::CCString::getCString(v24);
std::string::append(v34, v25);
std::string::~string((int)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
std::string::__init(&v38, "https://www.boomlings.com/database/getGJRewards.php", 0x33u);
*(_DWORD *)v41 = 0;
v42 = 0;
if ( ((int)v34[0] & 1) == 0 )
v9 = (char *)v34 + 1;
v43 = nullptr;
if ( ((int)v34[0] & 1) != 0 )
v9 = v34[2];
v26 = strlen(v9);
std::string::__init((int *)v41, v9, v26);
*(_DWORD *)v44 = 0;
v45 = 0;
v46 = nullptr;
std::string::__init((int *)v44, "rew_state", 9u);
GameLevelManager::ProcessHttpRequest(this, &v38, (int)v41, (int)v44, 52);
std::string::~string((int)v44);
std::string::~string((int)v41);
std::string::~string((int)&v38);
std::string::~string((int)v34);
return 1;
}