//
// AchievementManager::getAllAchievementsSorted from 0x140039b50 to 0x140039d62 (530 bytes)
//
// 3 xrefs:
// > AchievementManager::init @ 0x140007eae
// > AchievementManager::init @ 0x140007ec8
// > ??> @ 0x1406c3c6c
//
// 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
//
// Hidden C++ exception states: #wind=2
cocos2d::CCArray *AchievementManager::getAllAchievementsSorted(AchievementManager *a1, bool a2)
{
cocos2d::CCArray *v4; // r14
cocos2d::CCArray *v5; // rbp
unsigned int i; // edi
cocos2d::CCString *v7; // rax
const char *CString; // rax
__int64 v9; // r8
struct cocos2d::CCObject *v10; // rsi
void *v11; // rcx
__int64 v12; // rbx
void *v13; // rcx
__int128 v15; // [rsp+20h] [rbp-78h] BYREF
__int64 v16; // [rsp+30h] [rbp-68h]
unsigned __int64 v17; // [rsp+38h] [rbp-60h]
__int128 v18; // [rsp+40h] [rbp-58h] BYREF
__int64 v19; // [rsp+50h] [rbp-48h]
unsigned __int64 v20; // [rsp+58h] [rbp-40h]
v4 = cocos2d::CCDictionary::allKeys(a1->m_platformAchievements);
v5 = (cocos2d::CCArray *)cocos2d::CCArray::create();
for ( i = 0; i < cocos2d::CCArray::count(v4); ++i )
{
v7 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v4, i);
CString = cocos2d::CCString::getCString(v7);
v15 = 0;
v16 = 0;
v17 = 0;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(&v15);
v10 = (struct cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(a1->m_platformAchievements, &v15);
if ( v17 > 0xF )
{
v11 = (void *)v15;
if ( v17 + 1 >= 0x1000 )
{
v11 = *(void **)(v15 - 8);
if ( (unsigned __int64)(v15 - (_QWORD)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v11);
}
v16 = 0;
v17 = 15;
LOBYTE(v15) = 0;
if ( a2 )
{
v18 = 0;
v19 = 2;
v20 = 15;
strcpy((char *)&v18, "un");
v12 = cocos2d::CCDictionary::objectForKey(v10, &v18);
if ( v20 > 0xF )
{
v13 = (void *)v18;
if ( v20 + 1 >= 0x1000 )
{
v13 = *(void **)(v18 - 8);
if ( (unsigned __int64)(v18 - (_QWORD)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v13);
}
if ( v12 )
continue;
}
cocos2d::CCArray::addObject(v5, v10);
}
if ( cocos2d::CCArray::count(v5) )
qsort(v5->data->arr, v5->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)CompareFunction);
return v5;
}