//
// AchievementManager::storeAchievementUnlocks from 0x100784650 to 0x100784a0d (957 bytes)
//
// 2 xrefs:
// > AchievementManager::sharedState @ 0x10072ba1c
// > AchievementManager::init @ 0x10072babf
//
// 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 __fastcall AchievementManager::storeAchievementUnlocks(AchievementManager *a1)
{
double v1; // xmm0_8
AchievementManager *v2; // r13
cocos2d::CCDictionary *v3; // rax
cocos2d::CCArray *v4; // rbx
unsigned int v5; // r12d
cocos2d::CCString *v6; // rax
char *CString; // rax
__int64 m_platformAchievements; // rbx
size_t v9; // rax
size_t v10; // r14
char *v11; // r15
unsigned int v12; // r13d
__int64 v13; // rax
size_t v14; // r12
__int64 v15; // rbx
cocos2d::CCString *v16; // r12
const char *v17; // r14
size_t v18; // rax
size_t v19; // rbx
char *v20; // r15
__int64 v21; // rax
size_t v22; // r13
char v23; // al
cocos2d::CCDictionary *m_achievementUnlocks; // r13
size_t v25; // rax
size_t v26; // r14
char *v27; // rbx
__int64 v28; // rax
size_t v29; // r15
cocos2d::CCObject *v30; // r13
const char *v31; // r12
size_t v32; // rax
size_t v33; // r14
char *v34; // rbx
__int64 v35; // rax
size_t v36; // r15
__int64 v37; // [rsp+8h] [rbp-98h]
__int64 v38; // [rsp+10h] [rbp-90h]
_QWORD v39[2]; // [rsp+18h] [rbp-88h] BYREF
void *v40; // [rsp+28h] [rbp-78h]
_QWORD v41[2]; // [rsp+30h] [rbp-70h] BYREF
void *v42; // [rsp+40h] [rbp-60h]
unsigned int v43; // [rsp+4Ch] [rbp-54h]
void *__src; // [rsp+50h] [rbp-50h]
AchievementManager *v45; // [rsp+58h] [rbp-48h]
size_t __dst; // [rsp+60h] [rbp-40h] BYREF
size_t v47; // [rsp+68h] [rbp-38h]
void *__p; // [rsp+70h] [rbp-30h]
if ( !a1->m_achievementUnlocks )
{
v2 = a1;
v3 = cocos2d::CCDictionary::create();
a1->m_achievementUnlocks = v3;
cocos2d::CCObject::retain(v3);
v4 = cocos2d::CCDictionary::allKeys(a1->m_platformAchievements);
if ( (unsigned int)sub_100720070((__int64)v4) )
{
v5 = 0;
v45 = a1;
v37 = (__int64)v4;
while ( 1 )
{
v6 = cocos2d::CCArray::stringAtIndex(v4, v5);
CString = (char *)cocos2d::CCString::getCString(v6);
m_platformAchievements = (__int64)v2->m_platformAchievements;
__src = CString;
v9 = strlen(CString);
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_54:
sub_100006BF0(v1);
v10 = v9;
if ( v9 >= 0x17 )
break;
LOBYTE(__dst) = 2 * v9;
v11 = (char *)&__dst + 1;
if ( v9 )
goto LABEL_13;
LABEL_14:
v11[v10] = 0;
v15 = cocos2d::CCDictionary::objectForKey_1(m_platformAchievements, (char *)&__dst);
v43 = v5;
if ( (__dst & 1) != 0 )
operator delete(__p);
LOBYTE(__dst) = 8;
*(_DWORD *)((char *)&__dst + 1) = 1852793705;
BYTE5(__dst) = 0;
v16 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(v15, (char *)&__dst);
if ( (__dst & 1) != 0 )
operator delete(__p);
if ( !v16 )
goto LABEL_5;
v17 = cocos2d::CCString::getCString(v16);
v18 = strlen(v17);
if ( v18 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_54;
v19 = v18;
if ( v18 >= 0x17 )
{
v21 = v18 | 7;
v22 = 26;
if ( (v19 | 7) != 0x17 )
v22 = v21 + 1;
v20 = (char *)operator new(v22);
__p = v20;
__dst = v22 + 1;
v47 = v19;
v2 = v45;
LABEL_26:
memmove(v20, v17, v19);
goto LABEL_27;
}
LOBYTE(__dst) = 2 * v18;
v20 = (char *)&__dst + 1;
if ( v18 )
goto LABEL_26;
LABEL_27:
v20[v19] = 0;
v23 = __dst & 1;
if ( (__dst & 1) != 0 )
{
if ( v47 )
goto LABEL_31;
}
else if ( (unsigned __int8)__dst >> 1 )
{
LABEL_31:
m_achievementUnlocks = v2->m_achievementUnlocks;
v25 = strlen((const char *)__src);
if ( v25 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v1);
v26 = v25;
v38 = (__int64)m_achievementUnlocks;
if ( v25 >= 0x17 )
{
v28 = v25 | 7;
v29 = 26;
if ( (v26 | 7) != 0x17 )
v29 = v28 + 1;
v27 = (char *)operator new(v29);
v40 = v27;
v39[0] = v29 | 1;
v39[1] = v26;
}
else
{
LOBYTE(v39[0]) = 2 * v25;
v27 = (char *)v39 + 1;
if ( !v25 )
{
LABEL_39:
v27[v26] = 0;
v30 = (cocos2d::CCObject *)sub_1007AB360(v39);
v31 = cocos2d::CCString::getCString(v16);
v32 = strlen(v31);
if ( v32 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v1);
v33 = v32;
if ( v32 >= 0x17 )
{
v35 = v32 | 7;
v36 = 26;
if ( (v33 | 7) != 0x17 )
v36 = v35 + 1;
v34 = (char *)operator new(v36);
v42 = v34;
v41[0] = v36 | 1;
v41[1] = v33;
}
else
{
LOBYTE(v41[0]) = 2 * v32;
v34 = (char *)v41 + 1;
if ( !v32 )
goto LABEL_47;
}
memmove(v34, v31, v33);
LABEL_47:
v34[v33] = 0;
cocos2d::CCDictionary::setObject_1(v38, v30, (char *)v41);
v2 = v45;
if ( (v41[0] & 1) != 0 )
operator delete(v42);
if ( (v39[0] & 1) != 0 )
operator delete(v40);
v23 = __dst & 1;
goto LABEL_52;
}
}
memmove(v27, __src, v26);
goto LABEL_39;
}
LABEL_52:
if ( v23 )
operator delete(__p);
LABEL_5:
v5 = v43 + 1;
v4 = (cocos2d::CCArray *)v37;
if ( v5 >= (unsigned int)sub_100720070(v37) )
return;
}
v12 = v5;
v13 = v9 | 7;
v14 = 26;
if ( (v10 | 7) != 0x17 )
v14 = v13 + 1;
v11 = (char *)operator new(v14);
__p = v11;
__dst = v14 + 1;
v47 = v10;
v5 = v12;
v2 = v45;
LABEL_13:
memmove(v11, __src, v10);
goto LABEL_14;
}
}
}