//
// GameLevelManager::onGetGJRewardsCompleted from 0x10052c1a0 to 0x10052cbea (2634 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051e336
//
// 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:31:48 +0000
//
__int64 __fastcall GameLevelManager::onGetGJRewardsCompleted(__int64 a1, unsigned __int8 *a2)
{
char v4; // al
const void *v5; // rdi
unsigned __int64 v6; // rcx
const std::string::value_type *v7; // rsi
size_t v8; // rdx
__int64 v9; // rdx
__int64 v10; // r15
__int64 v11; // rdi
__int64 v13; // rax
const char *CString; // r13
size_t v15; // rax
size_t v16; // r12
char *v17; // rbx
size_t v18; // r14
__int64 v19; // rax
const char *v20; // r12
size_t v21; // rax
size_t v22; // r13
char *v23; // r15
unsigned int v24; // r12d
char *v25; // r14
__int64 v26; // r12
char *v27; // r13
size_t v28; // rbx
size_t v29; // r12
size_t v30; // rbx
__int64 v31; // rax
const std::string::value_type *v32; // rax
const char *data; // rbx
unsigned int v34; // eax
size_t v35; // rax
std::string::size_type v36; // r14
char *v37; // r12
size_t v38; // rbx
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v39; // bl
std::string::pointer v40; // r12
unsigned __int128 v41; // kr00_16
size_t v42; // rdx
void *v43; // r13
char *v44; // rsi
bool v45; // zf
char v46; // r15
void *v47; // r14
__int64 v48; // r15
__int64 v49; // rdi
__int64 v50; // rdi
__int64 v51; // rax
int v52; // r12d
_DWORD *v53; // rbx
float v54; // xmm0_4
__int64 v55; // rax
__int64 v56; // rax
__int64 v57; // rax
const char *v58; // rax
__int64 v59; // rax
__int64 v60; // rax
char v61; // bl
__int64 v62; // rdi
int v63; // ebx
__int64 v64; // rax
__int64 v65; // rax
int v66; // r13d
__int64 v67; // rax
const char *v68; // rax
__int64 v69; // rax
unsigned int v70; // r12d
__int64 v71; // rax
__int64 v72; // rax
const char *v73; // rax
__int64 v74; // rax
unsigned int v75; // ebx
__int64 v76; // rax
__int64 v77; // r15
__int64 v78; // rdi
__int64 v79; // r15
void (__fastcall ***v80)(_QWORD, _QWORD); // rdi
void *v81[3]; // [rsp+10h] [rbp-1A0h] BYREF
__int128 v82; // [rsp+28h] [rbp-188h] BYREF
void *v83; // [rsp+38h] [rbp-178h]
__int128 v84; // [rsp+40h] [rbp-170h] BYREF
void *v85; // [rsp+50h] [rbp-160h]
__int128 v86; // [rsp+60h] [rbp-150h] BYREF
void *v87; // [rsp+70h] [rbp-140h]
__int128 v88; // [rsp+80h] [rbp-130h] BYREF
void *v89; // [rsp+90h] [rbp-120h]
__int64 v90; // [rsp+98h] [rbp-118h] BYREF
size_t v91; // [rsp+A0h] [rbp-110h]
void *v92; // [rsp+A8h] [rbp-108h]
std::string v93; // [rsp+B0h] [rbp-100h] BYREF
int v94; // [rsp+CCh] [rbp-E4h]
int v95; // [rsp+D0h] [rbp-E0h]
unsigned int v96; // [rsp+D4h] [rbp-DCh]
std::string __s1; // [rsp+D8h] [rbp-D8h] BYREF
__int128 v98; // [rsp+F0h] [rbp-C0h] BYREF
void *v99; // [rsp+100h] [rbp-B0h]
__int128 __dst; // [rsp+110h] [rbp-A0h] BYREF
void *__p; // [rsp+120h] [rbp-90h]
__int64 v102; // [rsp+128h] [rbp-88h]
__int128 __s2; // [rsp+130h] [rbp-80h] BYREF
void *v104; // [rsp+140h] [rbp-70h]
_BYTE v105[32]; // [rsp+160h] [rbp-50h] BYREF
GameLevelManager::removeDLFromActive(a1, "rew_state");
LOBYTE(__s2) = 4;
*(_WORD *)((char *)&__s2 + 1) = 12589;
BYTE3(__s2) = 0;
v4 = *a2;
v5 = a2 + 1;
v6 = *a2 >> 1;
if ( (*a2 & 1) != 0 )
v5 = *((const void **)a2 + 2);
v7 = (char *)&__s2 + 1;
if ( (v4 & 1) != 0 )
v6 = *((_QWORD *)a2 + 1);
v8 = 2;
if ( v6 < 2 )
v8 = v6;
if ( (v6 != 2) | (memcmp(v5, (char *)&__s2 + 1, v8) != 0) )
{
v7 = "|";
v10 = sub_10053FBE0(a2, "|");
if ( (unsigned int)sub_1007FEF90(v10) > 1 )
{
v102 = a1;
v13 = cocos2d::CCArray::stringAtIndex(v10, 0);
CString = (const char *)cocos2d::CCString::getCString(v13);
v15 = strlen(CString);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v16 = v15;
if ( v15 >= 0x17 )
{
v18 = 26;
if ( (v15 | 7) != 0x17 )
v18 = (v15 | 7) + 1;
v17 = (char *)operator new(v18);
__p = v17;
*(_QWORD *)&__dst = v18 + 1;
*((_QWORD *)&__dst + 1) = v16;
}
else
{
LOBYTE(__dst) = 2 * v15;
v17 = (char *)&__dst + 1;
if ( !v15 )
{
LABEL_19:
v17[v16] = 0;
v19 = cocos2d::CCArray::stringAtIndex(v10, 1);
v20 = (const char *)cocos2d::CCString::getCString(v19);
v21 = strlen(v20);
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v22 = v21;
v23 = (char *)&v90 + 1;
if ( v21 >= 0x17 )
{
v28 = 26;
if ( (v21 | 7) != 0x17 )
v28 = (v21 | 7) + 1;
v23 = (char *)operator new(v28);
v92 = v23;
v90 = v28 | 1;
v91 = v22;
}
else
{
LOBYTE(v90) = 2 * v21;
if ( !v21 )
{
BYTE1(v90) = 0;
v24 = (unsigned __int8)__dst;
if ( (__dst & 1) == 0 )
goto LABEL_23;
goto LABEL_29;
}
}
memmove(v23, v20, v22);
v23[v22] = 0;
v24 = (unsigned __int8)__dst;
if ( (__dst & 1) == 0 )
{
LABEL_23:
v25 = (char *)&__s2 + 1;
if ( (unsigned __int8)v24 >= 0xAu )
{
v26 = v24 >> 1;
v27 = (char *)&__dst + 1;
goto LABEL_31;
}
goto LABEL_121;
}
LABEL_29:
v26 = *((_QWORD *)&__dst + 1);
v25 = (char *)&__s2 + 1;
if ( *((_QWORD *)&__dst + 1) > 4u )
{
v27 = (char *)__p;
LABEL_31:
v29 = v26 - 5;
if ( v29 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v29 >= 0x17 )
{
v30 = 26;
if ( (v29 | 7) != 0x17 )
v30 = (v29 | 7) + 1;
v25 = (char *)operator new(v30);
v104 = v25;
*(_QWORD *)&__s2 = v30 | 1;
*((_QWORD *)&__s2 + 1) = v29;
}
else
{
LOBYTE(__s2) = 2 * v29;
if ( !v29 )
{
BYTE1(__s2) = 0;
if ( (__dst & 1) == 0 )
goto LABEL_36;
goto LABEL_35;
}
}
memmove(v25, v27 + 5, v29);
v25[v29] = 0;
if ( (__dst & 1) == 0 )
{
LABEL_36:
__p = v104;
__dst = __s2;
if ( (__s2 & 1) != 0 )
{
sub_10001AD30(&v93, __p, *((unsigned __int64 *)&__dst + 1));
}
else
{
v93.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&v93.__r_.__value_.__l.0 = __dst;
}
v31 = sub_10088E820("%c%s%s%c%c%s", (char)"tg");
v32 = (const std::string::value_type *)cocos2d::CCString::getCString(v31);
std::string::append(&v93, v32);
if ( (*(_BYTE *)&v93.__r_.__value_.__s.0 & 1) != 0 )
data = v93.__r_.__value_.__l.__data_;
else
data = v93.__r_.__value_.__s.__data_;
v34 = strlen(data);
sub_100872DB0(data, v34, v105);
sub_100873590(v105, &__s2);
v35 = strlen((const char *)&__s2);
if ( v35 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v36 = v35;
if ( v35 >= 0x17 )
{
v38 = 26;
if ( (v35 | 7) != 0x17 )
v38 = (v35 | 7) + 1;
v37 = (char *)operator new(v38);
__s1.__r_.__value_.__r.__words[2] = (std::string::size_type)v37;
__s1.__r_.__value_.__r.__words[0] = v38 | 1;
__s1.__r_.__value_.__l.__size_ = v36;
}
else
{
__s1.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v35);
v37 = __s1.__r_.__value_.__s.__data_;
if ( !v35 )
{
LABEL_55:
v37[v36] = 0;
v39 = __s1.__r_.__value_.__s.0;
v40 = __s1.__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
v41 = *(_OWORD *)&__s1.__r_.__value_.__r.__words[1];
else
v41 = __PAIR128__(
(std::string *)((char *)&__s1.__r_.__value_.__l.0 + 1),
*(_BYTE *)&__s1.__r_.__value_.__l.0 >> 1);
v42 = (unsigned __int8)v90 >> 1;
v94 = (unsigned __int8)v90;
if ( (v90 & 1) != 0 )
v42 = v91;
v43 = v92;
v44 = (char *)&v90 + 1;
if ( (v90 & 1) != 0 )
v44 = (char *)v92;
v45 = v42 == (_QWORD)v41;
if ( v42 >= (unsigned __int64)v41 )
v42 = v41;
v46 = v45 & (memcmp(*((const void **)&v41 + 1), v44, v42) == 0);
if ( (*(_BYTE *)&v39 & 1) != 0 )
operator delete(v40);
if ( !v46 )
{
v50 = *(_QWORD *)(v102 + 1408);
v47 = v43;
if ( v50 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v50 + 8LL))(v50);
LABEL_111:
if ( (*(_BYTE *)&v93.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v93.__r_.__value_.__l.__data_);
if ( (v94 & 1) == 0 )
{
LABEL_113:
if ( (__dst & 1) == 0 )
return __stack_chk_guard;
LABEL_114:
operator delete(__p);
return __stack_chk_guard;
}
}
else if ( (v94 & 1) == 0 )
{
goto LABEL_113;
}
operator delete(v47);
if ( (__dst & 1) == 0 )
return __stack_chk_guard;
goto LABEL_114;
}
strcpy((char *)&v82, "\n59182");
cocos2d::ZipUtils::base64DecodeEnc(&__s1, (unsigned __int8 *)&__dst, &v82);
v47 = v43;
if ( (v82 & 1) != 0 )
operator delete(v83);
v48 = sub_10053FBE0(&__s1, ":");
if ( (unsigned int)sub_1007FEF90(v48) <= 0xB )
{
v49 = *(_QWORD *)(v102 + 1408);
if ( !v49 )
goto LABEL_109;
LABEL_81:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v49 + 8LL))(v49);
LABEL_109:
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s1.__r_.__value_.__l.__data_);
goto LABEL_111;
}
v51 = cocos2d::CCArray::stringAtIndex(v48, 1);
v52 = cocos2d::CCString::intValue(v51);
if ( v52 <= 0 )
{
v49 = *(_QWORD *)(v102 + 1408);
if ( !v49 )
goto LABEL_109;
goto LABEL_81;
}
v53 = (_DWORD *)GameManager::sharedState();
v53[167] = v52;
v54 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
v53[166] = (int)v54;
v53[165] = (int)v54 + v52;
v55 = cocos2d::CCArray::stringAtIndex(v48, 2);
LODWORD(v53) = cocos2d::CCString::intValue(v55);
v56 = GameManager::sharedState();
if ( (_DWORD)v53 != *(_DWORD *)(v56 + 896) - *(_DWORD *)(v56 + 900) )
{
v49 = *(_QWORD *)(v102 + 1408);
if ( !v49 )
goto LABEL_109;
goto LABEL_81;
}
v57 = cocos2d::CCArray::stringAtIndex(v48, 3);
v58 = (const char *)cocos2d::CCString::getCString(v57);
sub_10000E4E0(v81, v58);
v59 = GameManager::sharedState();
if ( (*(_BYTE *)(v59 + 608) & 1) != 0 )
{
sub_10001AD30(&v98, *(const void **)(v59 + 624), *(_QWORD *)(v59 + 616));
}
else
{
v60 = v59 + 608;
v99 = *(void **)(v60 + 16);
v98 = *(_OWORD *)v60;
}
v61 = sub_1001914B0((unsigned __int8 *)v81, (unsigned __int8 *)&v98);
if ( (v98 & 1) != 0 )
operator delete(v99);
if ( v61 )
{
v62 = cocos2d::CCArray::stringAtIndex(v48, 4);
v63 = cocos2d::CCString::intValue(v62);
v64 = GJAccountManager::sharedState(v62, 4);
if ( v63 == *(_DWORD *)(v64 + 352) - *(_DWORD *)(v64 + 356) )
{
v65 = cocos2d::CCArray::stringAtIndex(v48, 5);
v66 = cocos2d::CCString::intValue(v65);
v67 = cocos2d::CCArray::stringAtIndex(v48, 6);
v68 = (const char *)cocos2d::CCString::getCString(v67);
sub_10000E4E0(&v98, v68);
v69 = cocos2d::CCArray::stringAtIndex(v48, 7);
v70 = cocos2d::CCString::intValue(v69);
v71 = cocos2d::CCArray::stringAtIndex(v48, 8);
v95 = cocos2d::CCString::intValue(v71);
v72 = cocos2d::CCArray::stringAtIndex(v48, 9);
v73 = (const char *)cocos2d::CCString::getCString(v72);
sub_10000E4E0(&v88, v73);
v74 = cocos2d::CCArray::stringAtIndex(v48, 10);
v75 = cocos2d::CCString::intValue(v74);
v76 = cocos2d::CCArray::stringAtIndex(v48, 11);
v96 = cocos2d::CCString::intValue(v76);
v77 = GameStatsManager::sharedState();
if ( (v98 & 1) != 0 )
{
sub_10001AD30(&v84, v99, *((unsigned __int64 *)&v98 + 1));
}
else
{
v85 = v99;
v84 = v98;
}
GameStatsManager::storeRewardState(v77, 1u, v70, v66, &v84);
if ( (v84 & 1) != 0 )
operator delete(v85);
v79 = GameStatsManager::sharedState();
if ( (v88 & 1) != 0 )
{
sub_10001AD30(&v86, v89, *((unsigned __int64 *)&v88 + 1));
}
else
{
v87 = v89;
v86 = v88;
}
GameStatsManager::storeRewardState(v79, 2u, v75, v95, &v86);
if ( (v86 & 1) != 0 )
operator delete(v87);
v80 = *(void (__fastcall ****)(_QWORD, _QWORD))(v102 + 1408);
if ( v80 )
(**v80)(v80, v96);
if ( (v88 & 1) != 0 )
operator delete(v89);
if ( (v98 & 1) != 0 )
operator delete(v99);
goto LABEL_107;
}
v78 = *(_QWORD *)(v102 + 1408);
if ( !v78 )
{
LABEL_107:
if ( ((__int64)v81[0] & 1) != 0 )
operator delete(v81[2]);
goto LABEL_109;
}
}
else
{
v78 = *(_QWORD *)(v102 + 1408);
if ( !v78 )
goto LABEL_107;
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v78 + 8LL))(v78);
goto LABEL_107;
}
}
memcpy(v37, &__s2, v36);
goto LABEL_55;
}
LABEL_35:
operator delete(__p);
goto LABEL_36;
}
LABEL_121:
sub_100056810();
}
}
memmove(v17, CString, v16);
goto LABEL_19;
}
}
v11 = *(_QWORD *)(a1 + 1408);
if ( v11 )
return (*(__int64 (__fastcall **)(__int64, const std::string::value_type *, __int64, _QWORD))(*(_QWORD *)v11 + 8LL))(
v11,
v7,
v9,
__stack_chk_guard);
return __stack_chk_guard;
}