//
// GameStatsManager::getSecondaryQueuedChallenge from 0x7a4084 to 0x7a4194 (272 bytes)
//
// 3 xrefs:
// > GameLevelManager::onGetGJChallengesCompleted @ 0x6fe58c
// > GameStatsManager::processChallengeQueue @ 0x7a4320
// > ??> @ 0xb57a0
//
// 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
//
GJChallengeItem *GameStatsManager::getSecondaryQueuedChallenge(GameStatsManager *a1, int a2)
{
cocos2d::CCDictionary *m_upcomingChallenges; // x21
cocos2d::CCString *v3; // x0
char *CString; // x0
GJChallengeItem *v5; // x20
char *v6; // x0
unsigned int *v8; // x2
int v9; // w1
std::string v10; // [xsp+40h] [xbp+40h] BYREF
m_upcomingChallenges = a1->m_upcomingChallenges;
v3 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(a2 + 100));
CString = (char *)cocos2d::CCString::getCString(v3);
sub_D153B8((int)&v10, CString);
v5 = (GJChallengeItem *)cocos2d::CCDictionary::objectForKey(m_upcomingChallenges, &v10);
v6 = (char *)v10.m_data.m_data - 24;
if ( (__int64 *)v10.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)((char *)v10.m_data.m_data - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v10.m_data.m_data - 2);
*((_DWORD *)v10.m_data.m_data - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v6);
}
return v5;
}