//
// AchievementManager::getAllAchievementsSorted from 0x100784470 to 0x10078462a (442 bytes)
//
// 4 xrefs:
// > AchievementManager::sharedState @ 0x10072b9e9
// > AchievementManager::sharedState @ 0x10072ba05
// > AchievementManager::init @ 0x10072ba8c
// > AchievementManager::init @ 0x10072baa8
//
// 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 *__fastcall AchievementManager::getAllAchievementsSorted(AchievementManager *a1, bool a2)
{
double v2; // xmm0_8
cocos2d::CCArray *v3; // rbx
unsigned int v4; // r13d
cocos2d::CCString *v5; // rax
const char *CString; // r15
size_t v7; // rax
size_t v8; // r14
char *v9; // r12
__int64 v10; // rax
size_t v11; // rbx
cocos2d::CCObject *v12; // rbx
__int64 v13; // r14
cocos2d::CCDictionary *m_platformAchievements; // [rsp+8h] [rbp-68h]
__int64 v16; // [rsp+18h] [rbp-58h]
cocos2d::CCArray *v17; // [rsp+20h] [rbp-50h]
_QWORD __dst[2]; // [rsp+30h] [rbp-40h] BYREF
void *__p; // [rsp+40h] [rbp-30h]
v3 = cocos2d::CCDictionary::allKeys(a1->m_platformAchievements);
v17 = (cocos2d::CCArray *)sub_10071F9E0();
if ( (unsigned int)sub_100720070((__int64)v3) )
{
v4 = 0;
v16 = (__int64)v3;
do
{
v5 = (cocos2d::CCString *)sub_1007200C0((__int64)v3, v4);
CString = cocos2d::CCString::getCString(v5);
v7 = strlen(CString);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v8 = v7;
m_platformAchievements = a1->m_platformAchievements;
if ( v7 >= 0x17 )
{
v10 = v7 | 7;
v11 = 26;
if ( (v8 | 7) != 0x17 )
v11 = v10 + 1;
v9 = (char *)operator new(v11);
__p = v9;
__dst[0] = v11 + 1;
__dst[1] = v8;
}
else
{
LOBYTE(__dst[0]) = 2 * v7;
v9 = (char *)__dst + 1;
if ( !v7 )
goto LABEL_13;
}
memmove(v9, CString, v8);
LABEL_13:
v9[v8] = 0;
v12 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey_1((__int64)m_platformAchievements, (char *)__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( !a2 )
goto LABEL_3;
LOBYTE(__dst[0]) = 4;
*(_WORD *)((char *)__dst + 1) = 28277;
BYTE3(__dst[0]) = 0;
v13 = cocos2d::CCDictionary::objectForKey_1((__int64)v12, (char *)__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( !v13 )
LABEL_3:
sub_10071FCD0((__int64)v17, v12);
++v4;
v3 = (cocos2d::CCArray *)v16;
}
while ( v4 < (unsigned int)sub_100720070(v16) );
}
if ( (unsigned int)sub_100720070((__int64)v17) )
qsort(v17->data->arr, v17->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_10072B790);
return v17;
}