//
// GameStatsManager::completedDemonLevel from 0x1401de500 to 0x1401de763 (611 bytes)
//
// 5 xrefs:
// > GameLevelManager::updateLevelRewards @ 0x1401464b8
// > GameManager::dataLoaded @ 0x140187dd0
// > GameStatsManager::completedLevel @ 0x1401de4ab
// > LevelInfoLayer::init @ 0x1402f8e7a
// > ??> @ 0x1406cc414
//
// 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=1
void GameStatsManager::completedDemonLevel(GameStatsManager *a1, GJGameLevel *a2)
{
int v4; // edx
cocos2d::CCString *v5; // rax
const char *CString; // rax
const char *v7; // rcx
cocos2d::CCString *v8; // rax
size_t v9; // rbx
size_t v10; // r8
__int64 v11; // r15
void *v12; // rcx
cocos2d::CCString *v13; // rax
const char *v14; // rcx
const char *v15; // rax
void *v16; // rcx
void *Block[2]; // [rsp+20h] [rbp-58h] BYREF
__int128 v18; // [rsp+30h] [rbp-48h]
v4 = a2->m_dailyID.random - a2->m_dailyID.seed;
if ( v4 <= 0 )
{
v7 = "gdemon_%i";
if ( !a2->m_gauntletLevel )
v7 = "demon_%i";
v8 = cocos2d::CCString::createWithFormat(v7, (unsigned int)(a2->m_levelID.random - a2->m_levelID.seed));
CString = cocos2d::CCString::getCString(v8);
}
else
{
v5 = cocos2d::CCString::createWithFormat("ddemon_%i", v4);
CString = cocos2d::CCString::getCString(v5);
}
*(_OWORD *)Block = 0;
v18 = 0;
v9 = -1;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003A930(Block, CString, v10);
v11 = cocos2d::CCDictionary::objectForKey(a1->m_completedLevels, Block);
if ( *((_QWORD *)&v18 + 1) > 0xFu )
{
v12 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v18 + 1) + 1LL) >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v12);
}
if ( !v11 && a2->m_demon.random - a2->m_demon.seed == 1 )
{
if ( a2->m_dailyID.random - a2->m_dailyID.seed <= 0 )
{
v14 = "gdemon_%i";
if ( !a2->m_gauntletLevel )
v14 = "demon_%i";
v13 = cocos2d::CCString::createWithFormat(v14);
}
else
{
v13 = cocos2d::CCString::createWithFormat("ddemon_%i");
}
v15 = cocos2d::CCString::getCString(v13);
*(_OWORD *)Block = 0;
v18 = 0;
do
++v9;
while ( v15[v9] );
sub_14003A930(Block, v15, v9);
cocos2d::CCDictionary::setObject(a1->m_completedLevels, a1->m_trueString, Block);
if ( *((_QWORD *)&v18 + 1) > 0xFu )
{
v16 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v18 + 1) + 1LL) >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
if ( a2->m_stars.random - a2->m_stars.seed >= 10 )
GameStatsManager::incrementStat(a1, (const char *)&word_140531E90, 1);
}
}