//
// AchievementManager::getAllAchievementsSorted from 0x5528cc to 0x552b34 (616 bytes)
//
// 3 xrefs:
// > AchievementManager::init @ 0x5532b4
// > AchievementManager::init @ 0x5532c8
// > ??> @ 0x3d608
//
// 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
//
cocos2d::CCArray *AchievementManager::getAllAchievementsSorted(AchievementManager *a1, bool a2)
{
_BOOL4 v3; // w26
unsigned int v4; // w19
cocos2d::CCArray *v5; // x21
cocos2d::CCArray *v6; // x27
cocos2d::CCString *v7; // x0
char *CString; // x0
cocos2d::CCDictionary *m_platformAchievements; // x22
cocos2d::CCDictionary *v10; // x22
char *v11; // x0
unsigned int *v13; // x1
int v14; // w2
__int64 v15; // x2
char *v16; // x0
unsigned int *v17; // x1
int v18; // w3
__int64 v19; // [xsp+60h] [xbp+60h]
std::string v20; // [xsp+80h] [xbp+80h] BYREF
v3 = a2;
v4 = 0;
v5 = cocos2d::CCDictionary::allKeys(a1->m_platformAchievements);
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
if ( (unsigned int)cocos2d::CCArray::count(v5) )
{
do
{
v7 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v5, v4);
CString = (char *)cocos2d::CCString::getCString(v7);
m_platformAchievements = a1->m_platformAchievements;
sub_D153B8((int)&v20, CString);
v10 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::objectForKey(m_platformAchievements, &v20);
v11 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_3;
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v14 - 1;
}
if ( v14 > 0 )
{
LABEL_3:
if ( !v3 )
goto LABEL_4;
}
else
{
operator delete(v11);
if ( !v3 )
goto LABEL_4;
}
sub_D153B8((int)&v20, "un");
v15 = cocos2d::CCDictionary::objectForKey(v10, &v20);
v16 = (char *)v20.m_data.m_data - 24;
if ( (__int64 *)v20.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_15;
if ( &pthread_create )
{
v17 = (unsigned int *)((char *)v20.m_data.m_data - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v20.m_data.m_data - 2);
*((_DWORD *)v20.m_data.m_data - 2) = v18 - 1;
}
if ( v18 > 0 )
{
LABEL_15:
if ( v15 )
goto LABEL_16;
}
else
{
v19 = v15;
operator delete(v16);
if ( v19 )
{
LABEL_16:
++v4;
continue;
}
}
LABEL_4:
++v4;
cocos2d::CCArray::addObject(v6, v10);
}
while ( v4 < (unsigned int)cocos2d::CCArray::count(v5) );
}
if ( (unsigned int)cocos2d::CCArray::count(v6) )
qsort(v6->data->arr, v6->data->num, 8u, (int (*)(const void *, const void *))achievementCompare);
return v6;
}