//
// GameLevelManager::getGJRewards from 0x10057fe80 to 0x1005804be (1598 bytes)
//
// 3 xrefs:
// > RewardsPage::init @ 0x1001fe3bd
// > RewardsPage::onReward @ 0x1001fe66f
// > RewardsPage::tryGetRewards @ 0x1001fef0f
//
// This function is hookable on this platform (idp: pc, 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:32:20 +0000
//
bool __fastcall GameLevelManager::getGJRewards(__int64 a1, int a2)
{
bool isDLActive; // al
__int64 v3; // rax
__int64 v4; // r14
int v5; // eax
unsigned int v6; // r15d
int v7; // ebx
unsigned int v8; // r15d
__int64 v9; // rax
const char *CString; // rbx
size_t v11; // rax
std::string::size_type v12; // r12
char *data; // r13
unsigned int v14; // r15d
std::string::size_type size; // rbx
std::string::pointer v16; // r12
__int64 v17; // rax
size_t v18; // r14
size_t v19; // rbx
char *v20; // r13
char v21; // r14
char *v22; // rbx
int v23; // eax
char v24; // r15
char *v25; // rbx
int v26; // eax
size_t v27; // r14
char *v28; // rbx
int v29; // eax
int v30; // eax
bool v31; // zf
int v32; // eax
__int64 v33; // rax
__int64 v34; // rax
const std::string::value_type *v35; // rax
const char *v36; // rbx
size_t v37; // rax
size_t v38; // r14
char *v39; // r15
size_t v40; // r12
char v42; // [rsp+0h] [rbp-110h]
std::string v43; // [rsp+18h] [rbp-F8h] BYREF
__int128 v44; // [rsp+30h] [rbp-E0h] BYREF
void *v45; // [rsp+40h] [rbp-D0h]
std::string v46; // [rsp+48h] [rbp-C8h] BYREF
char v47; // [rsp+60h] [rbp-B0h]
char v48; // [rsp+61h] [rbp-AFh] BYREF
char v49; // [rsp+62h] [rbp-AEh]
char *v50; // [rsp+70h] [rbp-A0h]
_QWORD v51[2]; // [rsp+78h] [rbp-98h] BYREF
void *v52; // [rsp+88h] [rbp-88h]
int v53; // [rsp+94h] [rbp-7Ch]
char v54[8]; // [rsp+98h] [rbp-78h] BYREF
size_t v55; // [rsp+A0h] [rbp-70h]
char *v56; // [rsp+A8h] [rbp-68h]
__int64 v57; // [rsp+B0h] [rbp-60h]
std::string __dst; // [rsp+B8h] [rbp-58h] BYREF
unsigned int v59; // [rsp+D4h] [rbp-3Ch]
int v60; // [rsp+D8h] [rbp-38h]
int v61; // [rsp+DCh] [rbp-34h]
int v62; // [rsp+E0h] [rbp-30h]
bool v63; // [rsp+E7h] [rbp-29h]
v53 = a2;
isDLActive = GameLevelManager::isDLActive(a1, "rew_state");
if ( !isDLActive )
{
v63 = 0;
GameLevelManager::addDLToActive(a1, "rew_state");
GameLevelManager::getBasePostString(&v46);
v3 = GameStatsManager::sharedState();
v4 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(v3 + 480));
v5 = sub_1007FEF90(v4);
if ( v5 > 0 )
{
v6 = 0;
v62 = 0;
v61 = 0;
v57 = v4;
v60 = v5;
while ( 1 )
{
v9 = cocos2d::CCArray::stringAtIndex(v4, v6);
CString = (const char *)cocos2d::CCString::getCString(v9);
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v12 = v11;
v59 = v6;
if ( v11 >= 0x17 )
{
v17 = v11 | 7;
v18 = 26;
if ( (v12 | 7) != 0x17 )
v18 = v17 + 1;
data = (char *)operator new(v18);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v18 | 1;
__dst.__r_.__value_.__l.__size_ = v12;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v11);
data = __dst.__r_.__value_.__s.__data_;
if ( !v11 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v14 = (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, v12);
data[v12] = 0;
v14 = (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 )
{
v4 = v57;
v7 = v60;
v8 = v59;
LABEL_44:
operator delete(__dst.__r_.__value_.__l.__data_);
goto LABEL_5;
}
size = __dst.__r_.__value_.__l.__size_;
v47 = 2;
v48 = *__dst.__r_.__value_.__l.__data_;
v49 = 0;
v16 = __dst.__r_.__value_.__l.__data_;
goto LABEL_18;
}
LABEL_10:
if ( (unsigned __int8)v14 <= 4u )
{
v4 = v57;
v7 = v60;
v8 = v59;
goto LABEL_5;
}
v47 = 2;
v48 = __dst.__r_.__value_.__s.__data_[0];
v49 = 0;
size = v14 >> 1;
v16 = __dst.__r_.__value_.__s.__data_;
LABEL_18:
v19 = size - 2;
if ( v19 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v19 >= 0x17 )
{
v27 = (v19 | 7) + 1;
if ( (v19 | 7) == 0x17 )
v27 = 26;
v20 = (char *)operator new(v27);
v56 = v20;
*(_QWORD *)v54 = v27 | 1;
v55 = v19;
}
else
{
v54[0] = 2 * v19;
v20 = &v54[1];
if ( !v19 )
{
v54[1] = 0;
v21 = v47;
LABEL_22:
v22 = &v48;
if ( atoi(&v48) != 1 )
goto LABEL_23;
goto LABEL_33;
}
}
memmove(v20, v16 + 2, v19);
v20[v19] = 0;
v21 = v47;
if ( (v47 & 1) == 0 )
goto LABEL_22;
v22 = v50;
if ( atoi(v50) != 1 )
{
LABEL_23:
v23 = atoi(v22);
v24 = v54[0] & 1;
if ( v23 != 2 )
goto LABEL_38;
if ( v24 )
{
v25 = v56;
v32 = atoi(v56);
if ( v62 >= v32 )
goto LABEL_39;
}
else
{
v25 = &v54[1];
v26 = atoi(&v54[1]);
if ( v62 >= v26 )
goto LABEL_40;
}
v62 = atoi(v25);
if ( v24 )
goto LABEL_39;
goto LABEL_40;
}
LABEL_33:
v24 = v54[0] & 1;
if ( (v54[0] & 1) != 0 )
{
v28 = v56;
v30 = atoi(v56);
if ( v61 < v30 )
{
LABEL_37:
v61 = atoi(v28);
LABEL_38:
if ( !v24 )
goto LABEL_40;
}
LABEL_39:
operator delete(v56);
goto LABEL_40;
}
v28 = &v54[1];
v29 = atoi(&v54[1]);
if ( v61 < v29 )
goto LABEL_37;
LABEL_40:
v31 = (v21 & 1) == 0;
v4 = v57;
v7 = v60;
v8 = v59;
if ( v31 )
{
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_44;
}
else
{
operator delete(v50);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_44;
}
LABEL_5:
v6 = v8 + 1;
if ( v7 == v6 )
goto LABEL_49;
}
}
v61 = 0;
v62 = 0;
LABEL_49:
v33 = sub_10088E820("%c%s%s%c%c%s", (char)"7");
cocos2d::CCString::getCString(v33);
sub_10055EFA0(&__dst);
v34 = sub_10088E820("&rewardType=%i&secret=%s&chk=%s&r1=%i&r2=%i", v42);
v35 = (const std::string::value_type *)cocos2d::CCString::getCString(v34);
std::string::append(&v46, v35);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v43.__r_.__value_.__r.__words[2] = (std::string::size_type)operator new(0x38u);
v43.__r_.__value_.__r.__words[0] = 57;
v43.__r_.__value_.__l.__size_ = 51;
strcpy(v43.__r_.__value_.__l.__data_, "https://www.boomlings.com/database/getGJRewards.php");
if ( (*(_BYTE *)&v46.__r_.__value_.__s.0 & 1) != 0 )
v36 = v46.__r_.__value_.__l.__data_;
else
v36 = v46.__r_.__value_.__s.__data_;
v37 = strlen(v36);
if ( v37 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v38 = v37;
if ( v37 >= 0x17 )
{
v40 = 26;
if ( (v37 | 7) != 0x17 )
v40 = (v37 | 7) + 1;
v39 = (char *)operator new(v40);
v52 = v39;
v51[0] = v40 | 1;
v51[1] = v38;
}
else
{
LOBYTE(v51[0]) = 2 * v37;
v39 = (char *)v51 + 1;
if ( !v37 )
{
LABEL_62:
v39[v38] = 0;
LOBYTE(v44) = 18;
strcpy((char *)&v44 + 1, "rew_state");
GameLevelManager::ProcessHttpRequest(a1, &v43, (__int64)v51, &v44, 0x34u);
if ( (v44 & 1) != 0 )
{
operator delete(v45);
if ( (v51[0] & 1) == 0 )
{
LABEL_64:
if ( (*(_BYTE *)&v43.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_65;
goto LABEL_71;
}
}
else if ( (v51[0] & 1) == 0 )
{
goto LABEL_64;
}
operator delete(v52);
if ( (*(_BYTE *)&v43.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_65:
if ( (*(_BYTE *)&v46.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_67:
isDLActive = v63;
return !isDLActive;
}
LABEL_66:
operator delete(v46.__r_.__value_.__l.__data_);
goto LABEL_67;
}
LABEL_71:
operator delete(v43.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v46.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_67;
goto LABEL_66;
}
}
memmove(v39, v36, v38);
goto LABEL_62;
}
return !isDLActive;
}