//
// GameStatsManager::markLevelAsCompletedAndClaimed from 0x7b582c to 0x7b5aa0 (628 bytes)
//
// 2 xrefs:
// > GameManager::recountUserStats @ 0x5f9dc0
// > ??> @ 0x8f7c0
//
// 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
//
void GameStatsManager::markLevelAsCompletedAndClaimed(GameStatsManager *a1, GJGameLevel *a2)
{
char *StarLevelKey; // x0
cocos2d::CCDictionary *m_completedLevels; // x26
cocos2d::CCString *m_trueString; // x25
void *v7; // x0
char *DemonLevelKey; // x0
cocos2d::CCDictionary *v9; // x24
cocos2d::CCString *v10; // x20
void *v11; // x0
void *v12; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x1
int v18; // w2
__int64 v19; // [xsp+70h] [xbp+70h] BYREF
__int64 v20; // [xsp+78h] [xbp+78h] BYREF
__int64 v21; // [xsp+80h] [xbp+80h] BYREF
GameStatsManager::getLevelKey(a1, a2, (__int64)&v19);
cocos2d::CCDictionary::setObject((int)a1->m_completedLevels, a1->m_trueString);
StarLevelKey = (char *)GameStatsManager::getStarLevelKey(a1, a2);
m_completedLevels = a1->m_completedLevels;
m_trueString = a1->m_trueString;
sub_D153B8((int)&v20, StarLevelKey);
cocos2d::CCDictionary::setObject((int)m_completedLevels, m_trueString);
v7 = (void *)(v20 - 24);
if ( (__int64 *)(v20 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v20 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v20 - 8);
*(_DWORD *)(v20 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v7);
}
DemonLevelKey = (char *)GameStatsManager::getDemonLevelKey(a1, a2);
v9 = a1->m_completedLevels;
v10 = a1->m_trueString;
sub_D153B8((int)&v21, DemonLevelKey);
cocos2d::CCDictionary::setObject((int)v9, v10);
v11 = (void *)(v21 - 24);
if ( (__int64 *)(v21 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v21 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v21 - 8);
*(_DWORD *)(v21 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v11);
}
v12 = (void *)(v19 - 24);
if ( (__int64 *)(v19 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v19 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v19 - 8);
*(_DWORD *)(v19 - 8) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v12);
}
}