//
// GameStatsManager::getAwardedDiamondsForLevel from 0x1401e0f10 to 0x1401e113a (554 bytes)
//
// 3 xrefs:
// > LevelCell::loadCustomLevelCell @ 0x1400afad0
// > LevelInfoLayer::setupLevelInfo @ 0x1402fb7de
// > ??> @ 0x1406cc4f8
//
// 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
//
// Hidden C++ exception states: #wind=2
int GameStatsManager::getAwardedDiamondsForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
int v4; // edx
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // rbx
size_t v9; // r8
cocos2d::CCString *v10; // rax
cocos2d::CCDictionary *m_gauntletDiamondScores; // rsi
void **v12; // rdx
cocos2d::CCString *v13; // rax
int v14; // ebx
void *v15; // rcx
int v16; // ecx
unsigned int v17; // eax
int v18; // ecx
int v19; // ebx
void *v20; // rcx
void *v21[2]; // [rsp+28h] [rbp-60h] BYREF
__int128 v22; // [rsp+38h] [rbp-50h]
void *Block[2]; // [rsp+48h] [rbp-40h] BYREF
__int128 v24; // [rsp+58h] [rbp-30h]
v4 = a2->m_dailyID.random - a2->m_dailyID.seed;
if ( v4 > 0 )
{
v10 = cocos2d::CCString::createWithFormat("%i", v4);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)v21 = 0;
v22 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
}
else
{
if ( !a2->m_gauntletLevel )
return 0;
v6 = cocos2d::CCString::createWithFormat("%i", a2->m_levelID.random - a2->m_levelID.seed);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)v21 = 0;
v22 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
}
sub_14003A930(v21, CString, v9);
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
m_gauntletDiamondScores = a1->m_gauntletDiamondScores;
else
m_gauntletDiamondScores = a1->m_timelyDiamondScores;
v12 = v21;
if ( *((_QWORD *)&v22 + 1) > 0xFu )
v12 = (void **)v21[0];
*(_OWORD *)Block = 0;
v24 = 0;
do
++v8;
while ( *((_BYTE *)v12 + v8) );
sub_14003A930(Block, v12, v8);
v13 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_gauntletDiamondScores, Block);
v14 = cocos2d::CCString::intValue(v13);
if ( *((_QWORD *)&v24 + 1) > 0xFu )
{
v15 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v24 + 1) + 1LL) >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
v16 = a2->m_stars.random - a2->m_stars.seed;
v17 = v16 - 2;
v18 = v16 + 2;
if ( v17 > 8 )
v18 = 0;
v19 = (int)floorf((float)v18 * (float)((float)v14 / 100.0));
if ( *((_QWORD *)&v22 + 1) > 0xFu )
{
v20 = v21[0];
if ( (unsigned __int64)(*((_QWORD *)&v22 + 1) + 1LL) >= 0x1000 )
{
v20 = *((void **)v21[0] - 1);
if ( (unsigned __int64)((char *)v21[0] - (char *)v20 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v20);
}
return v19;
}