//
// GameStatsManager::awardCurrencyForLevel from 0x8e9e78 to 0x8ea2e8 (1136 bytes)
//
// 5 xrefs:
// > PlayLayer::destroyPlayer @ 0x6ff914
// > PlayLayer::levelComplete @ 0x703ee0
// > GameLevelManager::updateLevelRewards @ 0x80560c
// > GameStatsManager::awardOldSpecialStats @ 0x8ea398
// > ??> @ 0xe2978
//
// 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:55 +0000
//
__int64 __fastcall GameStatsManager::awardCurrencyForLevel(GameStatsManager *this, GJGameLevel *a2)
{
_BOOL4 v4; // w25
const char *v5; // x1
_BOOL4 v6; // w24
int v7; // w22
int v8; // w20
__int64 v9; // x26
unsigned int v10; // w19
char *v11; // x27
size_t v12; // x0
cocos2d::CCString *v13; // x0
int v14; // w27
float BaseCurrencyForLevel; // s2
unsigned int v17; // w1
int v18; // w27
int v19; // w27
cocos2d::CCObject *v20; // x20
const char *v21; // x1
size_t v22; // x0
__int64 v23; // x20
const char *v24; // x1
size_t v25; // x0
cocos2d::CCString *v26; // x0
int v27; // w19
cocos2d::CCObject *v28; // x22
const char *v29; // x1
size_t v30; // x0
int v31; // [xsp+68h] [xbp+68h]
char *v32; // [xsp+68h] [xbp+68h]
char *v33; // [xsp+68h] [xbp+68h]
char *v34; // [xsp+68h] [xbp+68h]
__int64 v35[2]; // [xsp+70h] [xbp+70h] BYREF
void *v36; // [xsp+80h] [xbp+80h]
__int64 v37[2]; // [xsp+88h] [xbp+88h] BYREF
void *v38; // [xsp+98h] [xbp+98h]
__int64 v39[2]; // [xsp+A0h] [xbp+A0h] BYREF
void *v40; // [xsp+B0h] [xbp+B0h]
__int64 v41[2]; // [xsp+B8h] [xbp+B8h] BYREF
void *v42; // [xsp+C8h] [xbp+C8h]
__int64 v43[2]; // [xsp+D0h] [xbp+D0h] BYREF
void *v44; // [xsp+E0h] [xbp+E0h]
v4 = *((_DWORD *)a2 + 285) == 1;
v5 = (const char *)(unsigned int)(*((_DWORD *)a2 + 230) - *((_DWORD *)a2 + 231));
v6 = (int)v5 > 0;
v7 = *((_DWORD *)a2 + 237) - *((_DWORD *)a2 + 238);
v8 = *((_DWORD *)a2 + 216) - *((_DWORD *)a2 + 217);
if ( (int)v5 <= 0 )
{
if ( v4 )
{
v9 = *((_QWORD *)this + 81);
}
else if ( *((_BYTE *)a2 + 649) )
{
v9 = *((_QWORD *)this + 82);
}
else
{
v9 = *((_QWORD *)this + 80);
}
if ( v8 <= 0 || v7 <= 0 )
return 0;
}
else
{
v9 = *((_QWORD *)this + 83);
if ( v8 <= 0 || v7 <= 0 || GameStatsManager::isDailyRecall(this, v5) )
return 0;
}
if ( v8 > 99 )
{
v31 = 100;
v11 = (char *)v35 + 1;
GameStatsManager::getCurrencyKey(a2, v35);
if ( (v35[0] & 1) == 0 )
goto LABEL_12;
}
else
{
v31 = v8;
v11 = (char *)v35 + 1;
GameStatsManager::getCurrencyKey(a2, v35);
if ( (v35[0] & 1) == 0 )
goto LABEL_12;
}
v11 = (char *)v36;
LABEL_12:
v37[0] = 0;
v37[1] = 0;
v38 = nullptr;
v12 = strlen(v11);
std::string::__init(v37, v11, v12);
v13 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v9, v37);
v14 = cocos2d::CCString::intValue(v13);
if ( (v37[0] & 1) != 0 )
operator delete(v38);
if ( v31 <= v14 )
goto LABEL_15;
BaseCurrencyForLevel = (float)(int)GameStatsManager::getBaseCurrencyForLevel(this, a2);
v17 = vcvtms_s32_f32(BaseCurrencyForLevel * (float)((float)v14 / 100.0));
v18 = vcvtms_s32_f32(BaseCurrencyForLevel * (float)((float)v31 / 100.0));
if ( v31 == 100 )
v18 = (int)(float)((float)v18 + (float)(BaseCurrencyForLevel * 0.25));
v19 = v18 - v17;
if ( v19 <= 0 )
{
LABEL_15:
v10 = 0;
goto LABEL_16;
}
v20 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v31);
v21 = (char *)v35 + 1;
if ( (v35[0] & 1) != 0 )
v21 = (const char *)v36;
v32 = (char *)v21;
v39[0] = 0;
v39[1] = 0;
v40 = nullptr;
v22 = strlen(v21);
std::string::__init(v39, v32, v22);
cocos2d::CCDictionary::setObject(v9, v20);
if ( (v39[0] & 1) != 0 )
{
operator delete(v40);
if ( !v4 )
goto LABEL_31;
}
else if ( !v4 )
{
LABEL_31:
v23 = *((_QWORD *)this + 85);
if ( !v6 )
v23 = *((_QWORD *)this + 84);
GameStatsManager::getCurrencyKey(a2, v39);
v24 = (char *)v39 + 1;
if ( (v39[0] & 1) != 0 )
v24 = (const char *)v40;
v33 = (char *)v24;
v41[0] = 0;
v41[1] = 0;
v42 = nullptr;
v25 = strlen(v24);
std::string::__init(v41, v33, v25);
v26 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v23, v41);
v27 = cocos2d::CCString::intValue(v26);
if ( (v41[0] & 1) != 0 )
operator delete(v42);
if ( v27 < v7 )
{
v28 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v7);
v29 = (char *)v39 + 1;
if ( (v39[0] & 1) != 0 )
v29 = (const char *)v40;
v34 = (char *)v29;
v43[0] = 0;
v43[1] = 0;
v44 = nullptr;
v30 = strlen(v29);
std::string::__init(v43, v34, v30);
cocos2d::CCDictionary::setObject(v23, v28);
if ( (v43[0] & 1) != 0 )
operator delete(v44);
}
if ( (v39[0] & 1) != 0 )
operator delete(v40);
}
GameStatsManager::incrementStat(this, (char *)&word_1217DE8, v19);
v10 = v19;
LABEL_16:
if ( (v35[0] & 1) != 0 )
operator delete(v36);
return v10;
}