//
// GameStatsManager::getAwardedDiamondsForLevel from 0x7a3540 to 0x7a374c (524 bytes)
//
// 3 xrefs:
// > LevelCell::loadCustomLevelCell @ 0x6114c8
// > LevelInfoLayer::setupLevelInfo @ 0x6dae24
// > ??> @ 0xc5268
//
// 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
//
int GameStatsManager::getAwardedDiamondsForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
cocos2d::CCDictionary *m_timelyDiamondScores; // x22
cocos2d::CCString *v5; // x0
int v6; // w22
char *v7; // x0
int BaseDiamonds; // w0
float v9; // s0
char *v10; // x22
int v11; // w19
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x3
int v16; // w0
char *v17; // [xsp+58h] [xbp+58h] BYREF
std::string v18; // [xsp+60h] [xbp+60h] BYREF
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 && !a2->m_gauntletLevel )
return 0;
GameStatsManager::getCurrencyKey(a1, a2, (__int64)&v17);
m_timelyDiamondScores = a1->m_timelyDiamondScores;
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
m_timelyDiamondScores = a1->m_gauntletDiamondScores;
sub_D153B8((int)&v18, v17);
v5 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyDiamondScores, &v18);
v6 = cocos2d::CCString::intValue(v5);
v7 = (char *)v18.m_data.m_data - 24;
if ( (__int64 *)v18.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v18.m_data.m_data - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v18.m_data.m_data - 2);
*((_DWORD *)v18.m_data.m_data - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v7);
}
BaseDiamonds = GameStatsManager::getBaseDiamonds(a1, a2->m_stars.random - a2->m_stars.seed);
v9 = (float)v6;
v10 = v17 - 24;
v11 = vcvtms_s32_f32((float)BaseDiamonds * (float)(v9 / 100.0));
if ( v17 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v17 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v17 - 2);
*((_DWORD *)v17 - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v10);
}
return v11;
}