//
// AchievementManager::storeAchievementUnlocks from 0x140039e20 to 0x14003a1b2 (914 bytes)
//
// 3 xrefs:
// > AchievementManager::init @ 0x140007ee0
// > ??> @ 0x1406c3c78
// > ??> @ 0x1406c3c84
//
// 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=5
void AchievementManager::storeAchievementUnlocks(AchievementManager *a1)
{
cocos2d::CCDictionary *v2; // rax
cocos2d::CCArray *v3; // r15
unsigned int i; // esi
cocos2d::CCString *v5; // rax
const char *CString; // rax
const char *v7; // rbx
__int64 v8; // r8
__int64 v9; // rdi
void *v10; // rcx
cocos2d::CCString *v11; // rdi
void *v12; // rcx
const char *v13; // rax
__int64 v14; // r8
const char *v15; // rax
__int64 v16; // r8
__int64 v17; // r8
__int64 v18; // rax
void *v19; // rcx
void *v20; // rcx
void *v21; // rcx
__int128 v22; // [rsp+20h] [rbp-59h] BYREF
__int64 v23; // [rsp+30h] [rbp-49h]
unsigned __int64 v24; // [rsp+38h] [rbp-41h]
__int128 v25; // [rsp+40h] [rbp-39h] BYREF
__int64 v26; // [rsp+50h] [rbp-29h]
unsigned __int64 v27; // [rsp+58h] [rbp-21h]
__int128 v28; // [rsp+60h] [rbp-19h] BYREF
__int64 v29; // [rsp+70h] [rbp-9h]
unsigned __int64 v30; // [rsp+78h] [rbp-1h]
__int128 v31; // [rsp+80h] [rbp+7h] BYREF
__int64 v32; // [rsp+90h] [rbp+17h]
unsigned __int64 v33; // [rsp+98h] [rbp+1Fh]
if ( !a1->m_achievementUnlocks )
{
v2 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create();
a1->m_achievementUnlocks = v2;
cocos2d::CCObject::retain(v2);
v3 = cocos2d::CCDictionary::allKeys(a1->m_platformAchievements);
for ( i = 0; i < cocos2d::CCArray::count(v3); ++i )
{
v5 = cocos2d::CCArray::stringAtIndex(v3, i);
CString = cocos2d::CCString::getCString(v5);
v7 = CString;
v22 = 0;
v23 = 0;
v24 = 0;
v8 = -1;
do
++v8;
while ( CString[v8] );
sub_14003A930(&v22);
v9 = cocos2d::CCDictionary::objectForKey(a1->m_platformAchievements, &v22);
if ( v24 > 0xF )
{
v10 = (void *)v22;
if ( v24 + 1 >= 0x1000 )
{
v10 = *(void **)(v22 - 8);
if ( (unsigned __int64)(v22 - (_QWORD)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
v23 = 0;
v24 = 15;
LOBYTE(v22) = 0;
v25 = 0;
v26 = 4;
v27 = 15;
strcpy((char *)&v25, "icon");
v11 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v9, &v25);
if ( v27 > 0xF )
{
v12 = (void *)v25;
if ( v27 + 1 >= 0x1000 )
{
v12 = *(void **)(v25 - 8);
if ( (unsigned __int64)(v25 - (_QWORD)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v12);
}
v26 = 0;
v27 = 15;
LOBYTE(v25) = 0;
if ( v11 )
{
v13 = cocos2d::CCString::getCString(v11);
v31 = 0;
v32 = 0;
v33 = 0;
v14 = -1;
do
++v14;
while ( v13[v14] );
sub_14003A930(&v31);
if ( v32 )
{
v15 = cocos2d::CCString::getCString(v11);
v28 = 0;
v29 = 0;
v30 = 0;
v16 = -1;
do
++v16;
while ( v15[v16] );
sub_14003A930(&v28);
v22 = 0;
v23 = 0;
v24 = 0;
v17 = -1;
do
++v17;
while ( v7[v17] );
sub_14003A930(&v22);
v18 = cocos2d::CCString::create(&v22);
cocos2d::CCDictionary::setObject(a1->m_achievementUnlocks, v18, &v28);
if ( v24 > 0xF )
{
v19 = (void *)v22;
if ( v24 + 1 >= 0x1000 )
{
v19 = *(void **)(v22 - 8);
if ( (unsigned __int64)(v22 - (_QWORD)v19 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
v23 = 0;
v24 = 15;
LOBYTE(v22) = 0;
if ( v30 > 0xF )
{
v20 = (void *)v28;
if ( v30 + 1 >= 0x1000 )
{
v20 = *(void **)(v28 - 8);
if ( (unsigned __int64)(v28 - (_QWORD)v20 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v20);
}
}
if ( v33 > 0xF )
{
v21 = (void *)v31;
if ( v33 + 1 >= 0x1000 )
{
v21 = *(void **)(v31 - 8);
if ( (unsigned __int64)(v31 - (_QWORD)v21 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v21);
}
}
}
}
}