//
// GameStatsManager::createReward from 0x1402e5050 to 0x1402e5290 (576 bytes)
//
// 3 xrefs:
// > GameLevelManager::rewardItemFromResponse @ 0x14025cc65
// > GameLevelManager::parseEventReward @ 0x1402601f7
// > ??> @ 0x14091df78
//
// 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 11:29:50 +0000
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall GameStatsManager::createReward(__int64 a1, int a2, int a3, __int64 *a4)
{
int v5; // r13d
int v6; // edi
__int64 v7; // rcx
cocos2d::CCArray *v8; // r14
unsigned __int64 v9; // r15
__int64 v10; // rdx
__int64 v11; // rsi
const char *v12; // rcx
int v13; // ebx
const char *v14; // rcx
unsigned int v15; // ebp
struct cocos2d::CCObject *v16; // rdi
__int64 v17; // rbx
cocos2d::CCObject *v18; // rcx
__int128 v22; // [rsp+28h] [rbp-80h] BYREF
__int64 v23; // [rsp+38h] [rbp-70h]
struct cocos2d::CCObject *v24; // [rsp+40h] [rbp-68h]
__int128 v25; // [rsp+48h] [rbp-60h] BYREF
__int64 v26; // [rsp+58h] [rbp-50h]
__int64 v27; // [rsp+60h] [rbp-48h]
__int64 *v28; // [rsp+68h] [rbp-40h]
v5 = a3;
v6 = a2;
v28 = a4;
v22 = 0;
v23 = 0;
sub_1401C5360(a4, byte_14070ECF8, (__int64 *)&v22);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
v9 = 0;
v10 = v22;
if ( (__int64)(*((_QWORD *)&v22 + 1) - v22) >> 5 != 1 )
{
v11 = 0;
while ( 1 )
{
v12 = (const char *)(v11 + v10);
if ( *(_QWORD *)(v11 + v10 + 24) > 0xFu )
v12 = *(const char **)v12;
v13 = atoi(v12);
v14 = (const char *)(v11 + v22 + 32);
if ( *((_QWORD *)v14 + 3) > 0xFu )
v14 = *(const char **)v14;
v15 = atoi(v14);
if ( v13 > 1000 )
break;
if ( (unsigned int)(v13 - 1) <= 0xE && v13 != 9 )
{
v16 = (struct cocos2d::CCObject *)GJRewardObject::create((unsigned int)v13, v15, 0);
LABEL_12:
if ( v16 )
cocos2d::CCArray::addObject(v8, v16);
}
v9 += 2LL;
v11 += 64;
v10 = v22;
if ( v9 >= ((__int64)(*((_QWORD *)&v22 + 1) - v22) >> 5) - 1 )
{
v5 = a3;
v6 = a2;
goto LABEL_16;
}
}
v16 = (struct cocos2d::CCObject *)operator new(0x48u);
v24 = v16;
cocos2d::CCObject::CCObject(v16);
*(_QWORD *)v16 = &GJRewardObject::`vftable';
*((_DWORD *)v16 + 14) = 9;
*((_DWORD *)v16 + 16) = v15;
*((_DWORD *)v16 + 17) = 1;
cocos2d::CCObject::autorelease(v16);
*((_DWORD *)v16 + 15) = v13 - 1000;
goto LABEL_12;
}
LABEL_16:
if ( cocos2d::CCArray::count(v8) )
{
v25 = 0;
v26 = 0;
v27 = 15;
LOBYTE(v25) = 0;
v17 = GJRewardItem::create(0, 0, &v25);
*(_DWORD *)(v17 + 64) = v6;
if ( *(cocos2d::CCArray **)(v17 + 72) != v8 )
{
if ( v8 )
cocos2d::CCObject::retain(v8);
v18 = *(cocos2d::CCObject **)(v17 + 72);
if ( v18 )
cocos2d::CCObject::release(v18);
*(_QWORD *)(v17 + 72) = v8;
}
*(_DWORD *)(v17 + 56) = v5;
sub_1400760C0((__int64 *)&v22);
sub_14003D310((__int64)a4);
return v17;
}
else
{
sub_1400760C0((__int64 *)&v22);
sub_14003D310((__int64)a4);
return 0;
}
}