//
// AchievementManager::getAllAchievementsSorted from 0x1008636d0 to 0x10086388a (442 bytes)
//
// 4 xrefs:
// > AchievementManager::sharedState @ 0x10080a7e9
// > AchievementManager::sharedState @ 0x10080a805
// > AchievementManager::init @ 0x10080a88c
// > AchievementManager::init @ 0x10080a8a8
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:36:42 +0000
//
_QWORD *__fastcall AchievementManager::getAllAchievementsSorted(__int64 a1, char a2)
{
__int64 v2; // rbx
unsigned int v3; // r13d
__int64 v4; // rax
const char *CString; // r15
size_t v6; // rax
size_t v7; // r14
char *v8; // r12
__int64 v9; // rax
size_t v10; // rbx
__int64 v11; // rbx
__int64 v12; // r14
__int64 v14; // [rsp+8h] [rbp-68h]
__int64 v15; // [rsp+18h] [rbp-58h]
_QWORD *v16; // [rsp+20h] [rbp-50h]
_QWORD __dst[2]; // [rsp+30h] [rbp-40h] BYREF
void *__p; // [rsp+40h] [rbp-30h]
v2 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(a1 + 328));
v16 = sub_1007FE900();
if ( (unsigned int)sub_1007FEF90(v2) )
{
v3 = 0;
v15 = v2;
do
{
v4 = sub_1007FEFE0(v2, v3);
CString = (const char *)cocos2d::CCString::getCString(v4);
v6 = strlen(CString);
if ( v6 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v7 = v6;
v14 = *(_QWORD *)(a1 + 328);
if ( v6 >= 0x17 )
{
v9 = v6 | 7;
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = v9 + 1;
v8 = (char *)operator new(v10);
__p = v8;
__dst[0] = v10 + 1;
__dst[1] = v7;
}
else
{
LOBYTE(__dst[0]) = 2 * v6;
v8 = (char *)__dst + 1;
if ( !v6 )
goto LABEL_13;
}
memmove(v8, CString, v7);
LABEL_13:
v8[v7] = 0;
v11 = cocos2d::CCDictionary::objectForKey(v14, (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;
v12 = cocos2d::CCDictionary::objectForKey(v11, (char *)__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( !v12 )
LABEL_3:
sub_1007FEBF0((__int64)v16, v11);
++v3;
v2 = v15;
}
while ( v3 < (unsigned int)sub_1007FEF90(v15) );
}
if ( (unsigned int)sub_1007FEF90((__int64)v16) )
qsort(
*(void **)(v16[7] + 16LL),
*(unsigned int *)v16[7],
8u,
(int (__cdecl *)(const void *, const void *))sub_10080A590);
return v16;
}