//
// GameStatsManager::getAwardedDiamondsForLevel from 0x1402e48f0 to 0x1402e4b3e (590 bytes)
//
// 3 xrefs:
// > LevelCell::loadCustomLevelCell @ 0x14014b2de
// > LevelInfoLayer::setupLevelInfo @ 0x1404206f8
// > ??> @ 0x14091df60
//
// 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:49 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GameStatsManager::getAwardedDiamondsForLevel(__int64 a1, __int64 a2)
{
cocos2d::CCString *v5; // rax
const char *CString; // rax
size_t v7; // rbx
size_t v8; // r8
cocos2d::CCString *v9; // rax
__int64 v10; // rcx
__int64 v11; // rsi
void **v12; // rdx
cocos2d::CCString *v13; // rax
int v14; // ebx
void *v15; // r8
int v16; // ecx
unsigned int v17; // eax
int v18; // ecx
unsigned int v19; // ebx
void *v20; // rcx
void *v21[2]; // [rsp+38h] [rbp-60h] BYREF
__int128 v22; // [rsp+48h] [rbp-50h]
void *Block[2]; // [rsp+58h] [rbp-40h] BYREF
__int128 v24; // [rsp+68h] [rbp-30h]
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) > 0 )
{
v9 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8);
CString = cocos2d::CCString::getCString(v9);
*(_OWORD *)v21 = 0;
v22 = 0;
v7 = -1;
v8 = -1;
do
++v8;
while ( CString[v8] );
}
else
{
if ( !*(_BYTE *)(a2 + 721) )
return 0;
v5 = cocos2d::CCString::createWithFormat(
(const char *)&word_1406ED6F8,
(unsigned int)(*(_DWORD *)(a2 + 328) - *(_DWORD *)(a2 + 332)));
CString = cocos2d::CCString::getCString(v5);
*(_OWORD *)v21 = 0;
v22 = 0;
v7 = -1;
v8 = -1;
do
++v8;
while ( CString[v8] );
}
sub_14003D230(v21, CString, v8);
v10 = 800;
if ( *(_DWORD *)(a2 + 992) - *(_DWORD *)(a2 + 996) <= 0 )
v10 = 792;
v11 = *(_QWORD *)(v10 + a1);
v12 = v21;
if ( *((_QWORD *)&v22 + 1) > 0xFu )
v12 = (void **)v21[0];
*(_OWORD *)Block = 0;
v24 = 0;
do
++v7;
while ( *((_BYTE *)v12 + v7) );
sub_14003D230(Block, v12, v7);
v13 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v11, 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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
v16 = *(_DWORD *)(a2 + 1020) - *(_DWORD *)(a2 + 1024);
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 )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v20);
}
return v19;
}