//
// GameStatsManager::createReward from 0x100071cc0 to 0x100071f5a (666 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetGJDailyLevelStateCompleted @ 0x100528f1a
// > GameLevelManager::onGetGJSecretRewardCompleted @ 0x10052b658
//
// 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
//
__int64 __fastcall GameStatsManager::createReward(__int64 a1, int a2, int a3, unsigned __int8 *a4)
{
const char *v5; // r13
_BYTE *v6; // rbx
cocos2d::CCObject *v7; // rbx
__int64 v8; // r12
cocos2d::CCObject *v9; // rdi
void **v10; // rbx
__int64 v11; // r15
unsigned __int64 i; // r14
int v13; // r12d
cocos2d::CCObject *v14; // r13
void **v15; // r14
void **v16; // rdi
__int16 v18[12]; // [rsp+8h] [rbp-78h] BYREF
__int64 v19; // [rsp+20h] [rbp-60h]
int v20; // [rsp+28h] [rbp-58h]
int v21; // [rsp+2Ch] [rbp-54h]
void *__p[2]; // [rsp+30h] [rbp-50h] BYREF
__int64 v23; // [rsp+40h] [rbp-40h]
int v24; // [rsp+54h] [rbp-2Ch]
v21 = a3;
v20 = a2;
*(_OWORD *)__p = 0;
v23 = 0;
sub_1000708A0(a4, ",", (__int64)__p, 0.0);
v19 = sub_10071F9E0(a4, ",");
v5 = (const char *)__p[0];
v6 = __p[1];
if ( (void *)((char *)__p[1] - (char *)__p[0]) != (void *)24 )
{
v11 = 25;
for ( i = 0; i < 0xAAAAAAAAAAAAAAABLL * ((v6 - v5) >> 3) - 1; i += 2LL )
{
if ( (v5[v11 - 25] & 1) != 0 )
{
v13 = atoi(*(const char **)&v5[v11 - 9]);
if ( (v5[v11 - 1] & 1) == 0 )
{
LABEL_16:
v24 = atoi(&v5[v11]);
if ( v13 >= 1001 )
goto LABEL_17;
goto LABEL_20;
}
}
else
{
v13 = atoi(&v5[v11 - 24]);
if ( (v5[v11 - 1] & 1) == 0 )
goto LABEL_16;
}
v24 = atoi(*(const char **)&v5[v11 + 15]);
if ( v13 >= 1001 )
{
LABEL_17:
v14 = (cocos2d::CCObject *)operator new(0x48u);
cocos2d::CCObject::CCObject(v14);
v14->__vftable = (cocos2d::CCObject_vtbl *)off_1008B38A8;
LODWORD(v14[1].__vftable) = 9;
v14[1].m_uID = v24;
v14[1].m_nLuaID = 1;
cocos2d::CCObject::autorelease(v14);
HIDWORD(v14[1].__vftable) = v13 - 1000;
goto LABEL_12;
}
LABEL_20:
if ( (unsigned int)(v13 - 1) >= 0xF || v13 == 9 )
goto LABEL_13;
v14 = (cocos2d::CCObject *)operator new(0x48u);
cocos2d::CCObject::CCObject(v14);
v14->__vftable = (cocos2d::CCObject_vtbl *)off_1008B38A8;
LODWORD(v14[1].__vftable) = v13;
v14[1].m_uID = 0;
v14[1].m_nLuaID = v24;
cocos2d::CCObject::autorelease(v14);
LABEL_12:
sub_10071FCD0(v19, v14);
v5 = (const char *)__p[0];
v6 = __p[1];
LABEL_13:
v11 += 48;
}
}
v7 = (cocos2d::CCObject *)v19;
if ( !(unsigned int)sub_100720070(v19) )
{
v8 = 0;
v10 = (void **)__p[0];
if ( !__p[0] )
return v8;
goto LABEL_23;
}
v18[0] = 0;
v8 = GJRewardItem::create(0, 0, v18);
*(_DWORD *)(v8 + 64) = v20;
v9 = *(cocos2d::CCObject **)(v8 + 72);
if ( v9 != v7 )
{
if ( v7 )
{
cocos2d::CCObject::retain(v7);
v9 = *(cocos2d::CCObject **)(v8 + 72);
}
if ( v9 )
cocos2d::CCObject::release(v9);
*(_QWORD *)(v8 + 72) = v7;
}
*(_DWORD *)(v8 + 56) = v21;
v10 = (void **)__p[0];
if ( __p[0] )
{
LABEL_23:
v15 = (void **)__p[1];
v16 = v10;
if ( __p[1] != v10 )
{
do
{
if ( (*(_BYTE *)(v15 - 3) & 1) != 0 )
operator delete(*(v15 - 1));
v15 -= 3;
}
while ( v15 != v10 );
v16 = (void **)__p[0];
}
__p[1] = v10;
operator delete(v16);
}
return v8;
}