//
// GameLevelManager::getGJRewards from 0x100558a60 to 0x10055917f (1823 bytes)
//
// 3 xrefs:
// > RewardsPage::init @ 0x10021addd
// > RewardsPage::onReward @ 0x10021b05f
// > RewardsPage::tryGetRewards @ 0x10021b84f
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
bool __fastcall GameLevelManager::getGJRewards(GameLevelManager *a1, int a2)
{
__m128 v2; // xmm0
bool isDLActive; // al
GameStatsManager *v4; // rax
cocos2d::CCArray *v5; // r12
unsigned int v6; // esi
cocos2d::CCString *v7; // rax
const char *CString; // r15
size_t v9; // rax
std::string::size_type v10; // rbx
char *data; // r13
unsigned int v12; // r12d
std::string::size_type size; // r15
std::string::pointer v14; // rbx
__int64 v15; // rax
size_t v16; // r14
size_t v17; // r15
char *v18; // r13
size_t v19; // r14
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v20; // r14
const char *v21; // rbx
int v22; // eax
char v23; // r15
char *v24; // rbx
int v25; // eax
char *v26; // rbx
int v27; // eax
int v28; // eax
int v29; // eax
cocos2d::CCString *v30; // rax
const char *v31; // rbx
size_t v32; // rax
std::string::size_type v33; // r14
char *v34; // r15
size_t v35; // r12
cocos2d::CCString *v36; // rax
cocos2d::CCObject *v37; // r12
cocos2d::CCString *v38; // rax
const char *v39; // rax
const char *v40; // rbx
size_t v41; // rax
size_t v42; // r14
char *v43; // r15
size_t v44; // r12
char v46; // [rsp+0h] [rbp-120h]
__int128 v47; // [rsp+8h] [rbp-118h] BYREF
void *v48; // [rsp+18h] [rbp-108h]
std::string v49; // [rsp+20h] [rbp-100h] BYREF
char v50; // [rsp+38h] [rbp-E8h] BYREF
_BYTE v51[23]; // [rsp+39h] [rbp-E7h] BYREF
std::string v52; // [rsp+50h] [rbp-D0h] BYREF
GameLevelManager *v53; // [rsp+68h] [rbp-B8h]
_QWORD v54[2]; // [rsp+70h] [rbp-B0h] BYREF
void *v55; // [rsp+80h] [rbp-A0h]
unsigned int v56; // [rsp+8Ch] [rbp-94h]
int v57; // [rsp+90h] [rbp-90h]
int v58; // [rsp+94h] [rbp-8Ch]
cocos2d::CCArray *v59; // [rsp+98h] [rbp-88h]
std::string v60; // [rsp+A0h] [rbp-80h] BYREF
char v61[8]; // [rsp+B8h] [rbp-68h] BYREF
size_t v62; // [rsp+C0h] [rbp-60h]
char *v63; // [rsp+C8h] [rbp-58h]
std::string __dst; // [rsp+D0h] [rbp-50h] BYREF
int v65; // [rsp+ECh] [rbp-34h]
char v66[4]; // [rsp+F0h] [rbp-30h]
bool v67; // [rsp+F7h] [rbp-29h]
v58 = a2;
isDLActive = GameLevelManager::isDLActive(a1, "rew_state");
if ( !isDLActive )
{
v67 = 0;
GameLevelManager::addDLToActive(a1, "rew_state");
GameLevelManager::getBasePostString(&v52, v2);
v4 = GameStatsManager::sharedState();
v5 = cocos2d::CCDictionary::allKeys(v4->m_dailyChests);
v57 = sub_100720070(v5);
v53 = a1;
if ( v57 > 0 )
{
v6 = 0;
*(_DWORD *)v66 = 0;
v65 = 0;
v59 = v5;
while ( 1 )
{
v56 = v6;
v7 = cocos2d::CCArray::stringAtIndex(v5, v6);
CString = cocos2d::CCString::getCString(v7);
v9 = strlen(CString);
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v2.i64);
v10 = v9;
if ( v9 >= 0x17 )
{
v15 = v9 | 7;
v16 = 26;
if ( (v10 | 7) != 0x17 )
v16 = v15 + 1;
data = (char *)operator new(v16);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v16 | 1;
__dst.__r_.__value_.__l.__size_ = v10;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v9);
data = __dst.__r_.__value_.__s.__data_;
if ( !v9 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v12 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_16;
goto LABEL_10;
}
}
memmove(data, CString, v10);
data[v10] = 0;
v12 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_16:
if ( __dst.__r_.__value_.__l.__size_ >= 3 )
{
size = __dst.__r_.__value_.__l.__size_;
v60.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)2;
*(_WORD *)((char *)&v60.__r_.__value_.__l.0 + 1) = (unsigned __int8)*__dst.__r_.__value_.__l.__data_;
v14 = __dst.__r_.__value_.__l.__data_;
LABEL_18:
v17 = size - 2;
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v2.i64);
if ( v17 >= 0x17 )
{
v19 = (v17 | 7) + 1;
if ( (v17 | 7) == 0x17 )
v19 = 26;
v18 = (char *)operator new(v19);
v63 = v18;
*(_QWORD *)v61 = v19 | 1;
v62 = v17;
}
else
{
v61[0] = 2 * v17;
v18 = &v61[1];
if ( !v17 )
{
LABEL_27:
v18[v17] = 0;
v20 = v60.__r_.__value_.__s.0;
v5 = v59;
if ( (*(_BYTE *)&v60.__r_.__value_.__s.0 & 1) != 0 )
{
v21 = v60.__r_.__value_.__l.__data_;
if ( atoi(v60.__r_.__value_.__l.__data_) == 1 )
goto LABEL_34;
LABEL_29:
v22 = atoi(v21);
v23 = v61[0] & 1;
if ( v22 != 2 )
goto LABEL_39;
if ( v23 )
{
v24 = v63;
v29 = atoi(v63);
if ( *(int *)v66 >= v29 )
goto LABEL_40;
}
else
{
v24 = &v61[1];
v25 = atoi(&v61[1]);
if ( *(int *)v66 >= v25 )
goto LABEL_41;
}
*(_DWORD *)v66 = atoi(v24);
if ( !v23 )
goto LABEL_41;
goto LABEL_40;
}
v21 = v60.__r_.__value_.__s.__data_;
if ( atoi(v60.__r_.__value_.__s.__data_) != 1 )
goto LABEL_29;
LABEL_34:
v23 = v61[0] & 1;
if ( (v61[0] & 1) != 0 )
{
v26 = v63;
v28 = atoi(v63);
if ( v65 < v28 )
goto LABEL_38;
goto LABEL_40;
}
v26 = &v61[1];
v27 = atoi(&v61[1]);
if ( v65 >= v27 )
goto LABEL_41;
LABEL_38:
v65 = atoi(v26);
LABEL_39:
if ( v23 )
LABEL_40:
operator delete(v63);
LABEL_41:
if ( (*(_BYTE *)&v20 & 1) != 0 )
operator delete(v60.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_5;
LABEL_44:
operator delete(__dst.__r_.__value_.__l.__data_);
goto LABEL_5;
}
}
memmove(v18, v14 + 2, v17);
goto LABEL_27;
}
v5 = v59;
goto LABEL_44;
}
LABEL_10:
if ( (unsigned __int8)v12 > 4u )
{
v60.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)2;
*(_WORD *)((char *)&v60.__r_.__value_.__l.0 + 1) = (unsigned __int8)__dst.__r_.__value_.__s.__data_[0];
size = v12 >> 1;
v14 = __dst.__r_.__value_.__s.__data_;
goto LABEL_18;
}
v5 = v59;
LABEL_5:
v6 = v56 + 1;
if ( v57 == v56 + 1 )
goto LABEL_49;
}
}
v65 = 0;
*(_DWORD *)v66 = 0;
LABEL_49:
GameManager::sharedState();
v30 = (cocos2d::CCString *)sub_1007AB580("%i", v46);
v31 = cocos2d::CCString::getCString(v30);
v32 = strlen(v31);
if ( v32 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(*(double *)v2.i64);
v33 = v32;
if ( v32 >= 0x17 )
{
v35 = 26;
if ( (v32 | 7) != 0x17 )
v35 = (v32 | 7) + 1;
v34 = (char *)operator new(v35);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v34;
__dst.__r_.__value_.__r.__words[0] = v35 | 1;
__dst.__r_.__value_.__l.__size_ = v33;
}
else
{
v34 = __dst.__r_.__value_.__s.__data_;
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v32);
if ( !v32 )
{
LABEL_57:
v34[v33] = 0;
strcpy((char *)&v47, "\n59182");
cocos2d::ZipUtils::base64EncodeEnc(&v60, &__dst, &v47, *(double *)v2.i64);
if ( (v47 & 1) != 0 )
operator delete(v48);
v36 = (cocos2d::CCString *)sub_1007AB580("%c%s%s%c%c%s", (char)"7");
v37 = v53;
cocos2d::CCString::getCString(v36);
sub_10051A8B0(v61, 5, *(double *)v2.i64);
v38 = (cocos2d::CCString *)sub_1007AB580("&rewardType=%i&secret=%s&chk=%s%s&r1=%i&r2=%i", v66[0]);
v39 = cocos2d::CCString::getCString(v38);
std::string::append(&v52, v39);
if ( (v61[0] & 1) != 0 )
operator delete(v63);
v49.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x38u);
v49.__r_.__value_.__r.__words[0] = 57;
v49.__r_.__value_.__l.__size_ = 51;
strcpy(v49.__r_.__value_.__l.__data_, "https://www.boomlings.com/database/getGJRewards.php");
if ( (*(_BYTE *)&v52.__r_.__value_.__s.0 & 1) != 0 )
v40 = v52.__r_.__value_.__l.__data_;
else
v40 = v52.__r_.__value_.__s.__data_;
v41 = strlen(v40);
if ( v41 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(2.057594829120962e-81);
v42 = v41;
if ( v41 >= 0x17 )
{
v44 = 26;
if ( (v41 | 7) != 0x17 )
v44 = (v41 | 7) + 1;
v43 = (char *)operator new(v44);
v55 = v43;
v54[0] = v44 | 1;
v54[1] = v42;
v37 = v53;
}
else
{
LOBYTE(v54[0]) = 2 * v41;
v43 = (char *)v54 + 1;
if ( !v41 )
{
LABEL_72:
v43[v42] = 0;
v50 = 18;
strcpy(v51, "rew_state");
GameLevelManager::ProcessHttpRequest(v37, &v49, (__int64)v54, (__int64)&v50, 46);
if ( (v50 & 1) != 0 )
{
operator delete(*(void **)&v51[15]);
if ( (v54[0] & 1) == 0 )
{
LABEL_74:
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_75;
goto LABEL_83;
}
}
else if ( (v54[0] & 1) == 0 )
{
goto LABEL_74;
}
operator delete(v55);
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_75:
if ( (*(_BYTE *)&v60.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_76;
goto LABEL_84;
}
LABEL_83:
operator delete(v49.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v60.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_76:
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_77;
goto LABEL_85;
}
LABEL_84:
operator delete(v60.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_77:
if ( (*(_BYTE *)&v52.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_79:
isDLActive = v67;
return !isDLActive;
}
LABEL_78:
operator delete(v52.__r_.__value_.__l.__data_);
goto LABEL_79;
}
LABEL_85:
operator delete(__dst.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v52.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_79;
goto LABEL_78;
}
}
memmove(v43, v40, v42);
goto LABEL_72;
}
}
memmove(v34, v31, v33);
goto LABEL_57;
}
return !isDLActive;
}