//
// GameStatsManager::awardDiamondsForLevel from 0x8ea43c to 0x8ea804 (968 bytes)
//
// 3 xrefs:
// > PlayLayer::destroyPlayer @ 0x6ffacc
// > PlayLayer::levelComplete @ 0x70411c
// > ??> @ 0x1059d0
//
// 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::awardDiamondsForLevel(GameStatsManager *this, GJGameLevel *a2)
{
int v4; // w22
int BaseDiamonds; // w21
int v6; // w0
int v7; // w26
char *v8; // x24
__int64 v9; // x25
size_t v10; // x0
cocos2d::CCString *v11; // x0
int v12; // w24
unsigned int v13; // w19
int v15; // w21
cocos2d::CCObject *v16; // x28
const char *v17; // x1
size_t v18; // x0
const char *v19; // x1
int v20; // w0
__int64 v21; // x19
size_t v22; // x0
cocos2d::CCString *v23; // x0
int v24; // w25
cocos2d::CCObject *v25; // x24
const char *v26; // x1
size_t v27; // x0
char *v28; // [xsp+68h] [xbp+68h]
char *v29; // [xsp+68h] [xbp+68h]
char *v30; // [xsp+68h] [xbp+68h]
__int64 v31[2]; // [xsp+70h] [xbp+70h] BYREF
void *v32; // [xsp+80h] [xbp+80h]
__int64 v33[2]; // [xsp+88h] [xbp+88h] BYREF
void *v34; // [xsp+98h] [xbp+98h]
__int64 v35[2]; // [xsp+A0h] [xbp+A0h] BYREF
void *v36; // [xsp+B0h] [xbp+B0h]
__int64 v37[2]; // [xsp+B8h] [xbp+B8h] BYREF
void *v38; // [xsp+C8h] [xbp+C8h]
__int64 v39[2]; // [xsp+D0h] [xbp+D0h] BYREF
void *v40; // [xsp+E0h] [xbp+E0h]
if ( (*((_DWORD *)a2 + 230) - *((_DWORD *)a2 + 231) > 0 || *((_BYTE *)a2 + 649))
&& (v4 = *((_DWORD *)a2 + 237) - *((_DWORD *)a2 + 238),
BaseDiamonds = GameStatsManager::getBaseDiamonds(this, v4),
v6 = *((_DWORD *)a2 + 216) - *((_DWORD *)a2 + 217),
BaseDiamonds > 0)
&& v6 > 0 )
{
v7 = 100;
if ( v6 <= 99 )
v7 = *((_DWORD *)a2 + 216) - *((_DWORD *)a2 + 217);
v8 = (char *)v31 + 1;
GameStatsManager::getCurrencyKey(a2, v31);
v9 = *((_QWORD *)this + 87);
if ( *((_DWORD *)a2 + 230) - *((_DWORD *)a2 + 231) <= 0 )
v9 = *((_QWORD *)this + 86);
if ( (v31[0] & 1) != 0 )
v8 = (char *)v32;
v33[0] = 0;
v33[1] = 0;
v34 = nullptr;
v10 = strlen(v8);
std::string::__init(v33, v8, v10);
v11 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v9, v33);
v12 = cocos2d::CCString::intValue(v11);
if ( (v33[0] & 1) != 0 )
operator delete(v34);
if ( v7 <= v12
|| (v15 = vcvtms_s32_f32((float)BaseDiamonds * (float)((float)v7 / 100.0))
- vcvtms_s32_f32((float)BaseDiamonds * (float)((float)v12 / 100.0)),
v15 <= 0) )
{
v13 = 0;
}
else
{
v16 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v7);
v17 = (char *)v31 + 1;
if ( (v31[0] & 1) != 0 )
v17 = (const char *)v32;
v28 = (char *)v17;
v35[0] = 0;
v35[1] = 0;
v36 = nullptr;
v18 = strlen(v17);
std::string::__init(v35, v28, v18);
cocos2d::CCDictionary::setObject(v9, v16);
if ( (v35[0] & 1) != 0 )
operator delete(v36);
v19 = (char *)v31 + 1;
v20 = *((_DWORD *)a2 + 230) - *((_DWORD *)a2 + 231);
v21 = *((_QWORD *)this + 85);
if ( v20 <= 0 )
v21 = *((_QWORD *)this + 84);
if ( (v31[0] & 1) != 0 )
v19 = (const char *)v32;
v29 = (char *)v19;
v37[0] = 0;
v37[1] = 0;
v38 = nullptr;
v22 = strlen(v19);
std::string::__init(v37, v29, v22);
v23 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v21, v37);
v24 = cocos2d::CCString::intValue(v23);
if ( (v37[0] & 1) != 0 )
operator delete(v38);
if ( v24 < v4 )
{
v25 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)v4);
v26 = (char *)v31 + 1;
if ( (v31[0] & 1) != 0 )
v26 = (const char *)v32;
v30 = (char *)v26;
v39[0] = 0;
v39[1] = 0;
v40 = nullptr;
v27 = strlen(v26);
std::string::__init(v39, v30, v27);
cocos2d::CCDictionary::setObject(v21, v25);
if ( (v39[0] & 1) != 0 )
operator delete(v40);
}
GameStatsManager::incrementStat(this, "13", v15);
v13 = v15;
}
if ( (v31[0] & 1) != 0 )
operator delete(v32);
}
else
{
return 0;
}
return v13;
}