//
// GameStatsManager::createReward from 0x8d635c to 0x8d6588 (556 bytes)
//
// 3 xrefs:
// > GameLevelManager::rewardItemFromResponse @ 0x839fc0
// > GameLevelManager::parseEventReward @ 0x83b818
// > ??> @ 0xbb1f8
//
// This function is hookable on this platform (idp: arm, 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:56:42 +0000
//
__int64 __fastcall GameStatsManager::createReward(int a1, unsigned int a2, int a3, unsigned __int8 *a4)
{
cocos2d::CCArray *v6; // x0
__int64 v7; // x0
_BYTE *v8; // x27
cocos2d::CCArray *v9; // x23
char *v10; // x21
__int64 v11; // x19
unsigned __int64 v12; // x20
const char *v13; // x0
int v14; // w28
char *v15; // x2
const char *v16; // x0
int v17; // w1
cocos2d::CCObject *ItemUnlock; // x0
__int64 v19; // x20
char *v20; // x19
char *v21; // x0
void *v23; // [xsp+60h] [xbp+60h] BYREF
char *v24; // [xsp+68h] [xbp+68h]
__int64 v25; // [xsp+70h] [xbp+70h]
v23 = nullptr;
v24 = nullptr;
v25 = 0;
v6 = (cocos2d::CCArray *)sub_8D60A8(a4, &byte_1169BE0, (__int64 *)&v23);
v7 = cocos2d::CCArray::create(v6);
v8 = v23;
v9 = (cocos2d::CCArray *)v7;
v10 = v24;
v11 = 0;
v12 = 0;
if ( 0xAAAAAAAAAAAAAAABLL * ((v24 - (_BYTE *)v23) >> 3) != 1 )
{
do
{
while ( 1 )
{
v13 = &v8[v11 + 1];
if ( (v8[v11] & 1) != 0 )
v13 = *(const char **)&v8[v11 + 16];
v14 = atoi(v13);
v15 = &v8[v11 + 24];
v16 = v15 + 1;
if ( (*v15 & 1) != 0 )
v16 = *((const char **)v15 + 2);
v17 = atoi(v16);
if ( v14 <= 1000 )
break;
ItemUnlock = GJRewardObject::createItemUnlock(v14 - 1000, v17);
LABEL_12:
if ( ItemUnlock )
cocos2d::CCArray::addObject(v9, ItemUnlock);
v8 = v23;
v12 += 2LL;
v10 = v24;
v11 += 48;
if ( 0xAAAAAAAAAAAAAAABLL * ((v24 - (_BYTE *)v23) >> 3) - 1 <= v12 )
goto LABEL_15;
}
if ( (unsigned int)(v14 - 1) <= 0xE && v14 != 9 )
{
ItemUnlock = GJRewardObject::create(v14, v17, 0);
goto LABEL_12;
}
v12 += 2LL;
v11 += 48;
}
while ( 0xAAAAAAAAAAAAAAABLL * ((v10 - v8) >> 3) - 1 > v12 );
}
LABEL_15:
if ( (unsigned int)cocos2d::CCArray::count(v9) )
{
v19 = GJRewardItem::createWithObjects((GJRewardItem *)a2, v9);
*(_DWORD *)(v19 + 56) = a3;
}
else
{
v19 = 0;
}
v20 = (char *)v23;
if ( v23 )
{
v21 = v24;
if ( v23 != v24 )
{
do
{
v24 = v21 - 24;
std::string::~string((__int64)(v21 - 24));
v21 = v24;
}
while ( v20 != v24 );
v21 = (char *)v23;
}
operator delete(v21);
}
return v19;
}