//
// GameLevelManager::getGJRewards from 0x140166020 to 0x140166782 (1890 bytes)
//
// 5 xrefs:
// > RewardsPage::init @ 0x1403cd2ed
// > RewardsPage::onReward @ 0x1403cd476
// > RewardsPage::tryGetRewards @ 0x1403cd7d5
// > ??> @ 0x1406cacc8
// > ??> @ 0x1406cacd4
//
// 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
//
// Hidden C++ exception states: #wind=11
bool GameLevelManager::getGJRewards(GameLevelManager *a1, int a2)
{
__int64 v3; // rbx
void *v4; // rcx
__int64 v6; // rax
__int64 v7; // rcx
void *v8; // rcx
__int64 v9; // rcx
int v10; // r14d
int v11; // r15d
cocos2d::CCArray *v12; // r12
signed int v13; // esi
signed int v14; // ebx
size_t i; // rdi
cocos2d::CCString *v16; // rax
const char *CString; // rax
size_t v18; // r8
void **v19; // rdx
void **v20; // rdx
const char *v21; // rcx
const char *v22; // rcx
const char *v23; // rcx
const char *v24; // rcx
const char *v25; // rcx
const char *v26; // rcx
char *v27; // rcx
char *v28; // rcx
void *v29; // rcx
__int64 v30; // rax
cocos2d::CCString *v31; // rax
const char *v32; // rax
size_t v33; // r8
const char *v34; // rax
const char *v35; // rsi
const char *v36; // rbx
cocos2d::CCString *v37; // rax
const char *v38; // rax
cocos2d::CCString *v39; // rax
char *v40; // rax
size_t v41; // r8
_QWORD *v42; // rdx
void *v43; // rcx
void *v44; // [rsp+40h] [rbp-C0h]
void *v45; // [rsp+40h] [rbp-C0h]
void *Block[2]; // [rsp+58h] [rbp-A8h] BYREF
unsigned __int64 v48; // [rsp+68h] [rbp-98h]
unsigned __int64 v49; // [rsp+70h] [rbp-90h]
char *v50[2]; // [rsp+78h] [rbp-88h] BYREF
__int64 v51; // [rsp+88h] [rbp-78h]
unsigned __int64 v52; // [rsp+90h] [rbp-70h]
char *String[2]; // [rsp+98h] [rbp-68h] BYREF
__int64 v54; // [rsp+A8h] [rbp-58h]
unsigned __int64 v55; // [rsp+B0h] [rbp-50h]
void *v56[2]; // [rsp+B8h] [rbp-48h] BYREF
__int64 v57; // [rsp+C8h] [rbp-38h]
unsigned __int64 v58; // [rsp+D0h] [rbp-30h]
__int128 v59; // [rsp+D8h] [rbp-28h] BYREF
__int64 v60; // [rsp+E8h] [rbp-18h]
__int64 v61; // [rsp+F0h] [rbp-10h]
_QWORD Src[4]; // [rsp+F8h] [rbp-8h] BYREF
_QWORD v63[4]; // [rsp+118h] [rbp+18h] BYREF
Block[1] = (void *)101;
v48 = 9;
v49 = 15;
Block[0] = (void *)0x746174735F776572LL;
v3 = cocos2d::CCDictionary::objectForKey(a1->m_downloadObjects, Block);
if ( v49 > 0xF )
{
v4 = Block[0];
if ( v49 + 1 >= 0x1000 )
{
v4 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v4 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v4);
}
if ( v3 )
return 0;
Block[1] = (void *)101;
v48 = 9;
v49 = 15;
Block[0] = (void *)0x746174735F776572LL;
v6 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(a1->m_downloadObjects, v6, Block);
if ( v49 > 0xF )
{
v8 = Block[0];
if ( v49 + 1 >= 0x1000 )
{
v8 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
GameLevelManager::getBasePostString(v7, Src);
v9 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v44 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v9 = qword_1406C2EE8;
}
v10 = 0;
v11 = 0;
v12 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(v9 + 536));
v13 = cocos2d::CCArray::count(v12);
v14 = 0;
for ( i = -1; v14 < v13; ++v14 )
{
v16 = cocos2d::CCArray::stringAtIndex(v12, v14);
CString = cocos2d::CCString::getCString(v16);
*(_OWORD *)Block = 0;
v48 = 0;
v49 = 0;
v18 = -1;
do
++v18;
while ( CString[v18] );
sub_14003A930(Block, CString, v18);
if ( v48 > 2 )
{
*(_OWORD *)String = 0;
v54 = 0;
v55 = 0;
v19 = Block;
if ( v49 > 0xF )
v19 = (void **)Block[0];
sub_14003A930(String, v19, v48 != 0);
*(_OWORD *)v50 = 0;
v51 = 0;
v52 = 0;
if ( v48 < 2 )
sub_14003BCC0(0);
v20 = Block;
if ( v49 > 0xF )
v20 = (void **)Block[0];
sub_14003A930(v50, (char *)v20 + 2, v48 - 2);
v21 = (const char *)String;
if ( v55 > 0xF )
v21 = String[0];
if ( atoi(v21) == 1 )
{
v22 = (const char *)v50;
if ( v52 > 0xF )
v22 = v50[0];
if ( v10 <= atoi(v22) )
{
v23 = (const char *)v50;
if ( v52 > 0xF )
v23 = v50[0];
v10 = atoi(v23);
}
}
else
{
v24 = (const char *)String;
if ( v55 > 0xF )
v24 = String[0];
if ( atoi(v24) == 2 )
{
v25 = (const char *)v50;
if ( v52 > 0xF )
v25 = v50[0];
if ( v11 <= atoi(v25) )
{
v26 = (const char *)v50;
if ( v52 > 0xF )
v26 = v50[0];
v11 = atoi(v26);
}
}
}
if ( v52 > 0xF )
{
v27 = v50[0];
if ( v52 + 1 >= 0x1000 )
{
v27 = *((char **)v50[0] - 1);
if ( (unsigned __int64)(v50[0] - v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v27);
}
v51 = 0;
v52 = 15;
LOBYTE(v50[0]) = 0;
if ( v55 > 0xF )
{
v28 = String[0];
if ( v55 + 1 >= 0x1000 )
{
v28 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v28 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v28);
}
v54 = 0;
v55 = 15;
LOBYTE(String[0]) = 0;
}
if ( v49 > 0xF )
{
v29 = Block[0];
if ( v49 + 1 >= 0x1000 )
{
v29 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v29 - 8) > 0x1F )
goto LABEL_73;
}
j_j_free(v29);
}
}
v30 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v45 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v30 = qword_1406C2ED8;
}
v31 = cocos2d::CCString::createWithFormat("%i", *(_DWORD *)(v30 + 888) - *(_DWORD *)(v30 + 892));
v32 = cocos2d::CCString::getCString(v31);
*(_OWORD *)v56 = 0;
v57 = 0;
v58 = 0;
v33 = -1;
do
++v33;
while ( v32[v33] );
sub_14003A930(v56, v32, v33);
*(_OWORD *)Block = 0;
v48 = 5;
v49 = 15;
strcpy((char *)Block, "59182");
cocos2d::ZipUtils::base64EncodeEnc(v63, v56, Block);
v34 = (const char *)sub_140142B90(&v59, 5u);
v35 = v34;
if ( *((_QWORD *)v34 + 3) > 0xFu )
v35 = *(const char **)v34;
v36 = (const char *)v63;
if ( v63[3] > 0xFu )
v36 = (const char *)v63[0];
v37 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, (const char *)&word_140531E88);
v38 = cocos2d::CCString::getCString(v37);
v39 = cocos2d::CCString::createWithFormat(
"&rewardType=%i&secret=%s&chk=%s%s&r1=%i&r2=%i",
a2,
v38,
v35,
v36,
v10,
v11);
v40 = (char *)cocos2d::CCString::getCString(v39);
v41 = -1;
do
++v41;
while ( v40[v41] );
sub_140041270(Src, v40, v41);
sub_14003A830((__int64)&v59);
String[1] = (char *)101;
v54 = 9;
v55 = 15;
String[0] = (char *)0x746174735F776572LL;
v42 = Src;
if ( Src[3] > 0xFu )
v42 = (_QWORD *)Src[0];
v59 = 0;
v60 = 0;
v61 = 0;
do
++i;
while ( *((_BYTE *)v42 + i) );
sub_14003A930(&v59, v42, i);
*(_OWORD *)v50 = 0;
v51 = 0;
v52 = 15;
v50[0] = (char *)sub_14003AA10(0x40u);
v51 = 51;
v52 = 63;
strcpy(v50[0], "https://www.boomlings.com/database/getGJRewards.php");
GameLevelManager::ProcessHttpRequest(a1, (__int64)v50, (const char *)&v59, (const char *)String, 46);
sub_14003A830((__int64)v63);
if ( v58 > 0xF )
{
v43 = v56[0];
if ( v58 + 1 >= 0x1000 )
{
v43 = *((void **)v56[0] - 1);
if ( (unsigned __int64)((char *)v56[0] - (char *)v43 - 8) > 0x1F )
LABEL_73:
invalid_parameter_noinfo_noreturn();
}
j_j_free(v43);
}
v57 = 0;
v58 = 15;
LOBYTE(v56[0]) = 0;
sub_14003A830((__int64)Src);
return 1;
}