//
// AchievementManager::storeAchievementUnlocks from 0x552e68 to 0x553270 (1032 bytes)
//
// 2 xrefs:
// > AchievementManager::init @ 0x5532d8
// > ??> @ 0x9c1b0
//
// 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
//
void AchievementManager::storeAchievementUnlocks(AchievementManager *a1)
{
cocos2d::CCDictionary *v2; // x0
unsigned int v3; // w21
cocos2d::CCDictionary *m_platformAchievements; // x0
cocos2d::CCArray *v5; // x24
cocos2d::CCString *v6; // x0
char *CString; // x27
cocos2d::CCDictionary *v8; // x20
cocos2d::CCDictionary *v9; // x23
char *v10; // x0
cocos2d::CCString *v11; // x23
char *v12; // x0
char *v13; // x0
__int64 v14; // x1
__int64 *v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
const std::string *v20; // x1
cocos2d::CCObject *v21; // x27
char *v22; // x0
char *v23; // x0
void *v24; // x0
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
int v30; // w2
_QWORD v31[13]; // [xsp+0h] [xbp+0h] BYREF
int v32[4]; // [xsp+68h] [xbp+68h]
char v33; // [xsp+78h] [xbp+78h] BYREF
__int64 v34; // [xsp+90h] [xbp+90h]
__int64 v35; // [xsp+98h] [xbp+98h] BYREF
std::string v36; // [xsp+A0h] [xbp+A0h] BYREF
if ( !a1->m_achievementUnlocks )
{
v2 = cocos2d::CCDictionary::create();
a1->m_achievementUnlocks = v2;
v3 = 0;
cocos2d::CCObject::retain(v2);
m_platformAchievements = a1->m_platformAchievements;
v31[12] = &v33;
v5 = cocos2d::CCDictionary::allKeys(m_platformAchievements);
while ( v3 < (unsigned int)cocos2d::CCArray::count(v5) )
{
v6 = cocos2d::CCArray::stringAtIndex(v5, v3);
CString = (char *)cocos2d::CCString::getCString(v6);
v8 = a1->m_platformAchievements;
sub_D153B8((unsigned int)v31 + 160, CString);
v9 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::objectForKey(v8, &v36);
v10 = (char *)v36.m_data.m_data - 24;
if ( (__int64 *)v36.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)((char *)v36.m_data.m_data - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v36.m_data.m_data - 2);
*((_DWORD *)v36.m_data.m_data - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v10);
}
sub_D153B8((unsigned int)v31 + 160, "icon");
v11 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v9, &v36);
v12 = (char *)v36.m_data.m_data - 24;
if ( (__int64 *)v36.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v36.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v36.m_data.m_data - 2);
*((_DWORD *)v36.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v12);
}
if ( !v11 )
goto LABEL_10;
v13 = (char *)cocos2d::CCString::getCString(v11);
sub_D153B8((unsigned int)v31 + 144, v13);
v14 = v34;
v15 = (__int64 *)(v34 - 24);
if ( *(_QWORD *)(v34 - 24) )
{
*(_QWORD *)v32 = a1->m_achievementUnlocks;
sub_D153B8((int)&v35, CString);
v21 = (cocos2d::CCObject *)cocos2d::CCString::create((cocos2d::CCString *)&v35, v20);
v22 = (char *)cocos2d::CCString::getCString(v11);
sub_D153B8((int)&v36, v22);
cocos2d::CCDictionary::setObject(v32[0], v21);
v23 = (char *)v36.m_data.m_data - 24;
if ( (__int64 *)v36.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)((char *)v36.m_data.m_data - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v36.m_data.m_data - 2);
*((_DWORD *)v36.m_data.m_data - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v23);
}
v24 = (void *)(v35 - 24);
if ( (__int64 *)(v35 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v35 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v35 - 8);
*(_DWORD *)(v35 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v24);
}
v14 = v34;
v15 = (__int64 *)(v34 - 24);
}
if ( v15 == &qword_124B6B0 )
goto LABEL_10;
if ( &pthread_create )
{
v18 = (unsigned int *)(v14 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v19 - 1;
}
if ( v19 > 0 )
{
LABEL_10:
++v3;
}
else
{
++v3;
operator delete(v15);
}
}
}
}