//
// sub_100577350 from 0x100577350 to 0x100577af5 (1957 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetGJSecretRewardCompleted @ 0x100530cdd
// > sub_10053CE00 @ 0x10053cf10
//
// 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:17 +0000
//
__int64 __fastcall sub_100577350(__int64 a1, unsigned __int8 *a2, int *a3)
{
const void *v4; // rdi
unsigned __int64 v5; // rcx
char *v6; // r15
size_t v7; // rdx
__int64 v8; // r14
__int64 Reward; // rbx
__int64 v11; // rax
const char *CString; // r13
size_t v13; // rax
size_t v14; // r12
char *v15; // rbx
size_t v16; // r13
__int64 v17; // rax
const char *v18; // r12
size_t v19; // rax
size_t v20; // r13
char *v21; // r14
unsigned int v22; // r12d
__int64 v23; // r12
char *v24; // r13
size_t v25; // rbx
size_t v26; // r12
size_t v27; // rbx
__int64 v28; // rax
const std::string::value_type *v29; // rax
const char *data; // rbx
unsigned int v31; // eax
size_t v32; // rax
std::string::size_type v33; // r15
char *v34; // r12
size_t v35; // rbx
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v36; // bl
std::string::pointer v37; // r15
unsigned __int128 v38; // kr00_16
char *v39; // rsi
size_t v40; // rdx
bool v41; // zf
char v42; // r14
int *v43; // r12
__int64 v44; // r15
__int64 v45; // rax
int v46; // ebx
__int64 v47; // rax
__int64 v48; // rax
__int64 v49; // rax
int v50; // r14d
__int64 v51; // rax
const char *v52; // r15
size_t v53; // rax
size_t v54; // r12
char *v55; // r13
size_t v56; // rbx
__int64 v57; // r15
int v58; // ebx
char v59; // r12
const char *v60; // [rsp+10h] [rbp-140h]
__int128 v61; // [rsp+18h] [rbp-138h] BYREF
void *v62; // [rsp+28h] [rbp-128h]
__int128 v63; // [rsp+30h] [rbp-120h] BYREF
void *v64; // [rsp+40h] [rbp-110h]
int *v65; // [rsp+48h] [rbp-108h]
std::string v66; // [rsp+50h] [rbp-100h] BYREF
__int128 v67; // [rsp+68h] [rbp-E8h] BYREF
void *v68; // [rsp+78h] [rbp-D8h]
__int64 v69; // [rsp+80h] [rbp-D0h] BYREF
size_t v70; // [rsp+88h] [rbp-C8h]
void *v71; // [rsp+90h] [rbp-C0h]
std::string __s1; // [rsp+98h] [rbp-B8h] BYREF
__int128 __dst; // [rsp+B0h] [rbp-A0h] BYREF
void *__p; // [rsp+C0h] [rbp-90h]
__int128 __s2; // [rsp+D0h] [rbp-80h] BYREF
void *v76; // [rsp+E0h] [rbp-70h]
_BYTE v77[32]; // [rsp+100h] [rbp-50h] BYREF
LOBYTE(__s2) = 4;
*(_WORD *)((char *)&__s2 + 1) = 12589;
BYTE3(__s2) = 0;
v4 = a2 + 1;
v5 = *a2 >> 1;
if ( (*a2 & 1) != 0 )
v4 = *((const void **)a2 + 2);
v6 = (char *)&__s2 + 1;
if ( (*a2 & 1) != 0 )
v5 = *((_QWORD *)a2 + 1);
v7 = 2;
if ( v5 < 2 )
v7 = v5;
if ( ((v5 == 2) & (memcmp(v4, (char *)&__s2 + 1, v7) == 0)) == 0 )
{
v8 = sub_10053FBE0(a2, "|");
if ( (unsigned int)sub_1007FEF90(v8) >= 2 )
{
v65 = a3;
v11 = cocos2d::CCArray::stringAtIndex(v8, 0);
CString = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v14 = v13;
if ( v13 >= 0x17 )
{
v60 = CString;
v16 = 26;
if ( (v13 | 7) != 0x17 )
v16 = (v13 | 7) + 1;
v15 = (char *)operator new(v16);
__p = v15;
*(_QWORD *)&__dst = v16 + 1;
CString = v60;
*((_QWORD *)&__dst + 1) = v14;
}
else
{
LOBYTE(__dst) = 2 * v13;
v15 = (char *)&__dst + 1;
if ( !v13 )
{
LABEL_19:
v15[v14] = 0;
v17 = cocos2d::CCArray::stringAtIndex(v8, 1);
v18 = (const char *)cocos2d::CCString::getCString(v17);
v19 = strlen(v18);
if ( v19 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v20 = v19;
v21 = (char *)&v69 + 1;
if ( v19 >= 0x17 )
{
v25 = 26;
if ( (v19 | 7) != 0x17 )
v25 = (v19 | 7) + 1;
v21 = (char *)operator new(v25);
v71 = v21;
v69 = v25 | 1;
v70 = v20;
}
else
{
LOBYTE(v69) = 2 * v19;
if ( !v19 )
{
BYTE1(v69) = 0;
v22 = (unsigned __int8)__dst;
if ( (__dst & 1) == 0 )
goto LABEL_23;
goto LABEL_29;
}
}
memmove(v21, v18, v20);
v21[v20] = 0;
v22 = (unsigned __int8)__dst;
if ( (__dst & 1) == 0 )
{
LABEL_23:
if ( (unsigned __int8)v22 >= 0xAu )
{
v23 = v22 >> 1;
v24 = (char *)&__dst + 1;
goto LABEL_31;
}
goto LABEL_98;
}
LABEL_29:
v23 = *((_QWORD *)&__dst + 1);
if ( *((_QWORD *)&__dst + 1) > 4u )
{
v24 = (char *)__p;
LABEL_31:
v26 = v23 - 5;
if ( v26 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v26 >= 0x17 )
{
v27 = 26;
if ( (v26 | 7) != 0x17 )
v27 = (v26 | 7) + 1;
v6 = (char *)operator new(v27);
v76 = v6;
*(_QWORD *)&__s2 = v27 | 1;
*((_QWORD *)&__s2 + 1) = v26;
}
else
{
LOBYTE(__s2) = 2 * v26;
if ( !v26 )
{
BYTE1(__s2) = 0;
if ( (__dst & 1) == 0 )
goto LABEL_36;
goto LABEL_35;
}
}
memmove(v6, v24 + 5, v26);
v6[v26] = 0;
if ( (__dst & 1) == 0 )
{
LABEL_36:
__p = v76;
__dst = __s2;
if ( (__s2 & 1) != 0 )
{
sub_10001AD30(&v66, __p, *((unsigned __int64 *)&__dst + 1));
}
else
{
v66.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&v66.__r_.__value_.__l.0 = __dst;
}
v28 = sub_10088E820("%c%s%s%c%c%s", (char)"tg");
v29 = (const std::string::value_type *)cocos2d::CCString::getCString(v28);
std::string::append(&v66, v29);
if ( (*(_BYTE *)&v66.__r_.__value_.__s.0 & 1) != 0 )
data = v66.__r_.__value_.__l.__data_;
else
data = v66.__r_.__value_.__s.__data_;
v31 = strlen(data);
sub_100872DB0(data, v31, v77);
sub_100873590(v77, &__s2);
v32 = strlen((const char *)&__s2);
if ( v32 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v33 = v32;
if ( v32 >= 0x17 )
{
v35 = 26;
if ( (v32 | 7) != 0x17 )
v35 = (v32 | 7) + 1;
v34 = (char *)operator new(v35);
__s1.__r_.__value_.__r.__words[2] = (std::string::size_type)v34;
__s1.__r_.__value_.__r.__words[0] = v35 | 1;
__s1.__r_.__value_.__l.__size_ = v33;
}
else
{
__s1.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v32);
v34 = __s1.__r_.__value_.__s.__data_;
if ( !v32 )
{
LABEL_55:
v34[v33] = 0;
v36 = __s1.__r_.__value_.__s.0;
v37 = __s1.__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
v38 = *(_OWORD *)&__s1.__r_.__value_.__r.__words[1];
else
v38 = __PAIR128__(
(std::string *)((char *)&__s1.__r_.__value_.__l.0 + 1),
*(_BYTE *)&__s1.__r_.__value_.__l.0 >> 1);
v39 = (char *)&v69 + 1;
v40 = (unsigned __int8)v69 >> 1;
if ( (v69 & 1) != 0 )
{
v40 = v70;
v39 = (char *)v71;
}
v41 = v40 == (_QWORD)v38;
if ( v40 >= (unsigned __int64)v38 )
v40 = v38;
v42 = v41 & (memcmp(*((const void **)&v38 + 1), v39, v40) == 0);
if ( (*(_BYTE *)&v36 & 1) != 0 )
operator delete(v37);
v43 = v65;
if ( !v42 )
{
Reward = 0;
goto LABEL_77;
}
strcpy((char *)&v61, "\n59182");
cocos2d::ZipUtils::base64DecodeEnc(&__s1, (unsigned __int8 *)&__dst, &v61);
if ( (v61 & 1) != 0 )
operator delete(v62);
v44 = sub_10053FBE0((unsigned __int8 *)&__s1, ":");
if ( (unsigned int)sub_1007FEF90(v44) < 5
|| (v45 = cocos2d::CCArray::stringAtIndex(v44, 1),
v46 = cocos2d::CCString::intValue(v45),
v47 = GameManager::sharedState(),
v46 != *(_DWORD *)(v47 + 896) - *(_DWORD *)(v47 + 900)) )
{
Reward = 0;
goto LABEL_75;
}
v48 = cocos2d::CCArray::stringAtIndex(v44, 2);
*v43 = cocos2d::CCString::intValue(v48);
v49 = cocos2d::CCArray::stringAtIndex(v44, 3);
v50 = cocos2d::CCString::intValue(v49);
v51 = cocos2d::CCArray::stringAtIndex(v44, 4);
v52 = (const char *)cocos2d::CCString::getCString(v51);
v53 = strlen(v52);
if ( v53 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v54 = v53;
if ( v53 >= 0x17 )
{
v56 = 26;
if ( (v53 | 7) != 0x17 )
v56 = (v53 | 7) + 1;
v55 = (char *)operator new(v56);
v68 = v55;
*(_QWORD *)&v67 = v56 | 1;
*((_QWORD *)&v67 + 1) = v54;
}
else
{
LOBYTE(v67) = 2 * v53;
v55 = (char *)&v67 + 1;
if ( !v53 )
{
LABEL_88:
v55[v54] = 0;
v57 = GameStatsManager::sharedState();
v58 = *v65;
v59 = v67 & 1;
if ( (v67 & 1) != 0 )
{
sub_10001AD30(&v63, v68, *((unsigned __int64 *)&v67 + 1));
}
else
{
v64 = v68;
v63 = v67;
}
Reward = GameStatsManager::createReward(v57, v50, v58, (unsigned __int8 *)&v63);
if ( (v63 & 1) != 0 )
{
operator delete(v64);
if ( !v59 )
goto LABEL_75;
}
else if ( !v59 )
{
goto LABEL_75;
}
operator delete(v68);
LABEL_75:
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s1.__r_.__value_.__l.__data_);
LABEL_77:
if ( (*(_BYTE *)&v66.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v66.__r_.__value_.__l.__data_);
if ( (v69 & 1) == 0 )
{
LABEL_79:
if ( (__dst & 1) == 0 )
return Reward;
LABEL_83:
operator delete(__p);
return Reward;
}
}
else if ( (v69 & 1) == 0 )
{
goto LABEL_79;
}
operator delete(v71);
if ( (__dst & 1) == 0 )
return Reward;
goto LABEL_83;
}
}
memmove(v55, v52, v54);
goto LABEL_88;
}
}
memcpy(v34, &__s2, v33);
goto LABEL_55;
}
LABEL_35:
operator delete(__p);
goto LABEL_36;
}
LABEL_98:
sub_100056810();
}
}
memmove(v15, CString, v14);
goto LABEL_19;
}
}
return 0;
}