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