//
// GameStatsManager::completedChallenge from 0x7bb4b4 to 0x7bb614 (352 bytes)
//
// 2 xrefs:
// > ChallengesPage::claimItem @ 0x908cc8
// > ??> @ 0x599a0
//
// 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::completedChallenge(GameStatsManager *a1, GJChallengeItem *a2)
{
cocos2d::CCDictionary *m_challengeDiamonds; // x25
unsigned int v5; // w22
cocos2d::CCObject *v6; // x24
void *v7; // x0
unsigned int *v8; // x2
int v9; // w1
__int64 v10; // [xsp+70h] [xbp+70h] BYREF
if ( a2->m_canClaim && !GameStatsManager::hasCompletedChallenge(a1, a2) )
{
m_challengeDiamonds = a1->m_challengeDiamonds;
v5 = a2->m_reward.random - a2->m_reward.seed;
v6 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v5);
GameStatsManager::getChallengeKey(a1, a2, (__int64)&v10);
cocos2d::CCDictionary::setObject((int)m_challengeDiamonds, v6);
v7 = (void *)(v10 - 24);
if ( (__int64 *)(v10 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v10 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *(_DWORD *)(v10 - 8);
*(_DWORD *)(v10 - 8) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v7);
}
GameStatsManager::incrementStat(a1, "13", v5);
}
}