//
// sub_100560AF0 from 0x100560af0 to 0x10056101b (1323 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetGJDailyLevelStateCompleted @ 0x10052e09b
// > sub_10055F180 @ 0x1005603a4
//
// 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:09 +0000
//
__int64 __fastcall sub_100560AF0(__int64 a1, std::string *a2, unsigned __int8 *a3)
{
unsigned int v4; // r15d
unsigned __int64 size; // r15
std::string::pointer data; // r12
__int64 Reward; // rbx
size_t v8; // r15
const void *v9; // r12
char *v10; // r13
size_t v11; // r14
__int64 v12; // rax
const std::string::value_type *CString; // rax
const char *v14; // r15
unsigned int v15; // eax
size_t v16; // rax
std::string::size_type v17; // r15
char *v18; // r12
size_t v19; // r13
unsigned int v20; // eax
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v21; // r14
std::string::pointer v22; // r15
size_t v23; // rdx
std::string::pointer v24; // rdi
size_t v25; // rax
const void *v26; // rsi
bool v27; // zf
char v28; // r12
__int64 v29; // r15
__int64 v30; // rax
int v31; // ebx
__int64 v32; // rax
__int64 v33; // rax
int v34; // r14d
__int64 v35; // rax
__int64 v36; // rax
const char *v37; // r15
size_t v38; // rax
size_t v39; // r12
char *v40; // r13
size_t v42; // rbx
__int64 v43; // r15
char v44; // r12
__int128 v45; // [rsp+8h] [rbp-108h] BYREF
void *v46; // [rsp+18h] [rbp-F8h]
__int128 v47; // [rsp+20h] [rbp-F0h] BYREF
void *v48; // [rsp+30h] [rbp-E0h]
std::string v49; // [rsp+40h] [rbp-D0h] BYREF
unsigned __int8 *v50; // [rsp+58h] [rbp-B8h]
__int128 v51; // [rsp+60h] [rbp-B0h] BYREF
void *v52; // [rsp+70h] [rbp-A0h]
std::string __s1; // [rsp+78h] [rbp-98h] BYREF
__int128 __dst; // [rsp+90h] [rbp-80h] BYREF
char *v55; // [rsp+A0h] [rbp-70h]
_BYTE v56[32]; // [rsp+C0h] [rbp-50h] BYREF
v4 = (unsigned int)a2->__r_.__value_.__l.0;
if ( (v4 & 1) == 0 )
{
if ( (unsigned __int8)v4 >= 0xCu )
{
size = v4 >> 1;
data = a2->__r_.__value_.__s.__data_;
goto LABEL_7;
}
return 0;
}
size = a2->__r_.__value_.__l.__size_;
if ( size < 6 )
return 0;
data = a2->__r_.__value_.__l.__data_;
LABEL_7:
v8 = size - 5;
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v9 = data + 5;
v50 = a3;
if ( v8 >= 0x17 )
{
v11 = 26;
if ( (v8 | 7) != 0x17 )
v11 = (v8 | 7) + 1;
v10 = (char *)operator new(v11);
v55 = v10;
*(_QWORD *)&__dst = v11 + 1;
*((_QWORD *)&__dst + 1) = v8;
}
else
{
LOBYTE(__dst) = 2 * v8;
v10 = (char *)&__dst + 1;
}
memmove(v10, v9, v8);
v10[v8] = 0;
if ( (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) != 0 )
operator delete(a2->__r_.__value_.__l.__data_);
a2->__r_.__value_.__r.__words[2] = (std::string::size_type)v55;
*(_OWORD *)&a2->__r_.__value_.__l.0 = __dst;
if ( (*(_BYTE *)&a2->__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v49, a2->__r_.__value_.__l.__data_, a2->__r_.__value_.__l.__size_);
else
v49 = *a2;
v12 = sub_10088E820("%c%s%s%c%c%s", (char)"tg");
CString = (const std::string::value_type *)cocos2d::CCString::getCString(v12);
std::string::append(&v49, CString);
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) != 0 )
v14 = v49.__r_.__value_.__l.__data_;
else
v14 = v49.__r_.__value_.__s.__data_;
v15 = strlen(v14);
sub_100872DB0(v14, v15, v56);
sub_100873590(v56, &__dst);
v16 = strlen((const char *)&__dst);
if ( v16 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v17 = v16;
if ( v16 >= 0x17 )
{
v19 = 26;
if ( (v16 | 7) != 0x17 )
v19 = (v16 | 7) + 1;
v18 = (char *)operator new(v19);
__s1.__r_.__value_.__r.__words[2] = (std::string::size_type)v18;
__s1.__r_.__value_.__r.__words[0] = v19 | 1;
__s1.__r_.__value_.__l.__size_ = v17;
goto LABEL_28;
}
__s1.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v16);
v18 = __s1.__r_.__value_.__s.__data_;
if ( v16 )
LABEL_28:
memcpy(v18, &__dst, v17);
v18[v17] = 0;
v20 = *v50;
v21 = __s1.__r_.__value_.__s.0;
v22 = __s1.__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
{
v24 = __s1.__r_.__value_.__l.__data_;
v23 = __s1.__r_.__value_.__l.__size_;
if ( (v20 & 1) == 0 )
{
LABEL_31:
v25 = v20 >> 1;
v26 = v50 + 1;
goto LABEL_34;
}
}
else
{
v24 = __s1.__r_.__value_.__s.__data_;
v23 = *(_BYTE *)&__s1.__r_.__value_.__l.0 >> 1;
if ( (v20 & 1) == 0 )
goto LABEL_31;
}
v25 = *((_QWORD *)v50 + 1);
v26 = *((const void **)v50 + 2);
LABEL_34:
v27 = v25 == v23;
if ( v25 < v23 )
v23 = v25;
v28 = v27 & (memcmp(v24, v26, v23) == 0);
if ( (*(_BYTE *)&v21 & 1) != 0 )
operator delete(v22);
if ( v28 )
{
strcpy((char *)&v45, "\n59182");
cocos2d::ZipUtils::base64DecodeEnc(&__s1, (unsigned __int8 *)a2, &v45);
if ( (v45 & 1) != 0 )
operator delete(v46);
v29 = sub_10053FBE0((unsigned __int8 *)&__s1, ":");
if ( (unsigned int)sub_1007FEF90(v29) < 5
|| (v30 = cocos2d::CCArray::stringAtIndex(v29, 1),
v31 = cocos2d::CCString::intValue(v30),
v32 = GameManager::sharedState(),
v31 != *(_DWORD *)(v32 + 896) - *(_DWORD *)(v32 + 900)) )
{
Reward = 0;
goto LABEL_49;
}
v33 = cocos2d::CCArray::stringAtIndex(v29, 2);
v34 = cocos2d::CCString::intValue(v33);
v35 = cocos2d::CCArray::stringAtIndex(v29, 3);
LODWORD(v50) = cocos2d::CCString::intValue(v35);
v36 = cocos2d::CCArray::stringAtIndex(v29, 4);
v37 = (const char *)cocos2d::CCString::getCString(v36);
v38 = strlen(v37);
if ( v38 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v39 = v38;
if ( v38 >= 0x17 )
{
v42 = 26;
if ( (v38 | 7) != 0x17 )
v42 = (v38 | 7) + 1;
v40 = (char *)operator new(v42);
v52 = v40;
*(_QWORD *)&v51 = v42 | 1;
*((_QWORD *)&v51 + 1) = v39;
}
else
{
LOBYTE(v51) = 2 * v38;
v40 = (char *)&v51 + 1;
if ( !v38 )
{
LABEL_58:
v40[v39] = 0;
v43 = GameStatsManager::sharedState();
v44 = v51 & 1;
if ( (v51 & 1) != 0 )
{
sub_10001AD30(&v47, v52, *((unsigned __int64 *)&v51 + 1));
}
else
{
v48 = v52;
v47 = v51;
}
Reward = GameStatsManager::createReward(v43, (int)v50, v34, (unsigned __int8 *)&v47);
if ( (v47 & 1) != 0 )
{
operator delete(v48);
if ( !v44 )
goto LABEL_49;
}
else if ( !v44 )
{
goto LABEL_49;
}
operator delete(v52);
LABEL_49:
if ( (*(_BYTE *)&__s1.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s1.__r_.__value_.__l.__data_);
goto LABEL_51;
}
}
memmove(v40, v37, v39);
goto LABEL_58;
}
Reward = 0;
LABEL_51:
if ( (*(_BYTE *)&v49.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v49.__r_.__value_.__l.__data_);
return Reward;
}