//
// GameStatsManager::createReward from 0x100332f8c to 0x10033310c (384 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetGJDailyLevelStateCompleted @ 0x1000904e0
// > GameLevelManager::onGetGJSecretRewardCompleted @ 0x100091b88
//
// 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
//
GJRewardItem *__fastcall GameStatsManager::createReward(int a1, GJRewardType a2, int a3, std::string *a4)
{
cocos2d::CCObject *v5; // x21
__int64 v6; // x27
__int64 v7; // x28
__int64 v8; // x23
unsigned __int64 i; // x24
__int64 v10; // x19
const char *v11; // x0
SpecialRewardItem v12; // w22
const char *v13; // x0
int v14; // w2
GJRewardItem *v15; // x22
__int64 v18; // [xsp+10h] [xbp-70h] BYREF
__int64 v19; // [xsp+18h] [xbp-68h]
__int64 v20; // [xsp+20h] [xbp-60h]
void **v21; // [xsp+28h] [xbp-58h] BYREF
v18 = 0;
v19 = 0;
v20 = 0;
sub_100332314(a4, ",", (__int64)&v18);
v5 = sub_10024A15C();
v7 = v18;
v6 = v19;
if ( v19 - v18 != 24 )
{
v8 = 0;
for ( i = 0; i < -1 - 0x5555555555555555LL * ((v6 - v7) >> 3); i += 2LL )
{
v10 = v7 + v8;
if ( *(char *)(v7 + v8 + 23) < 0 )
v11 = *(const char **)v10;
else
v11 = (const char *)(v7 + v8);
v12 = atoi(v11);
v13 = (const char *)(v10 + 24);
if ( *(char *)(v10 + 47) < 0 )
v13 = *(const char **)v13;
v14 = atoi(v13);
if ( v12 < 1001 )
{
if ( v12 == CustomItem || (unsigned int)(v12 - 1) > 0xE )
goto LABEL_14;
GJRewardObject::create(v12, v14, 0);
}
else
{
GJRewardObject::create(CustomItem, 1, v14)->m_unlockType = v12 - 1000;
}
sub_10024A2D0((__int64)v5);
v7 = v18;
v6 = v19;
LABEL_14:
v8 += 48;
}
}
if ( (unsigned int)sub_10024A36C((__int64)v5) )
{
v15 = GJRewardItem::create_1();
v15->m_rewardType = a2;
sub_10015C71C((__int64)v15, v5);
v15->m_chestID = a3;
}
else
{
v15 = nullptr;
}
v21 = (void **)&v18;
sub_1000177FC(&v21);
return v15;
}