//
// AchievementManager::storeAchievementUnlocks from 0x14003c630 to 0x14003ca07 (983 bytes)
//
// 2 xrefs:
// > AchievementManager::init @ 0x14000a140
// > ??> @ 0x14090f014
//
// 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 11:25:27 +0000
//
// Hidden C++ exception states: #wind=5
int __fastcall AchievementManager::storeAchievementUnlocks(__int64 a1)
{
_UNKNOWN **v1; // rax
cocos2d::CCObject *v3; // rax
cocos2d::CCArray *v4; // r15
unsigned int v5; // esi
__m128i si128; // xmm6
__m128i v7; // xmm7
cocos2d::CCString *v8; // rax
const char *CString; // rax
const char *v10; // rbx
__int64 v11; // r8
__int64 v12; // rdi
void *v13; // rcx
cocos2d::CCString *v14; // rdi
void *v15; // rcx
const char *v16; // rax
__int64 v17; // r8
const char *v18; // rax
__int64 v19; // r8
__int64 v20; // r8
__int64 v21; // rbx
__int64 v22; // rax
void *v23; // rcx
void *v24; // rcx
void *v25; // rcx
__int128 v27; // [rsp+38h] [rbp-79h] BYREF
__m128i v28; // [rsp+48h] [rbp-69h]
__int128 v29; // [rsp+58h] [rbp-59h] BYREF
__m128i v30; // [rsp+68h] [rbp-49h]
__int128 v31; // [rsp+78h] [rbp-39h] BYREF
__int64 v32; // [rsp+88h] [rbp-29h]
unsigned __int64 v33; // [rsp+90h] [rbp-21h]
__int128 v34; // [rsp+98h] [rbp-19h] BYREF
__int128 v35; // [rsp+A8h] [rbp-9h]
_UNKNOWN *retaddr; // [rsp+110h] [rbp+5Fh] BYREF
v1 = &retaddr;
if ( !*(_QWORD *)(a1 + 336) )
{
v3 = (cocos2d::CCObject *)cocos2d::CCDictionary::create();
*(_QWORD *)(a1 + 336) = v3;
cocos2d::CCObject::retain(v3);
v4 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 328));
v5 = 0;
LODWORD(v1) = cocos2d::CCArray::count(v4);
if ( (_DWORD)v1 )
{
si128 = _mm_load_si128((const __m128i *)&Size);
v7 = _mm_load_si128((const __m128i *)&xmmword_140836550);
do
{
v8 = cocos2d::CCArray::stringAtIndex(v4, v5);
CString = cocos2d::CCString::getCString(v8);
v10 = CString;
v27 = 0;
v28 = 0;
v11 = -1;
do
++v11;
while ( CString[v11] );
sub_14003D230(&v27);
v12 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 328), &v27);
if ( v28.m128i_i64[1] > 0xFuLL )
{
v13 = (void *)v27;
if ( (unsigned __int64)(v28.m128i_i64[1] + 1) >= 0x1000 )
{
v13 = *(void **)(v27 - 8);
if ( (unsigned __int64)(v27 - (_QWORD)v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
v28 = si128;
LOBYTE(v27) = 0;
v29 = 0;
v30 = v7;
strcpy((char *)&v29, "icon");
v14 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(v12, &v29);
if ( v30.m128i_i64[1] > 0xFuLL )
{
v15 = (void *)v29;
if ( (unsigned __int64)(v30.m128i_i64[1] + 1) >= 0x1000 )
{
v15 = *(void **)(v29 - 8);
if ( (unsigned __int64)(v29 - (_QWORD)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
v30 = si128;
LOBYTE(v29) = 0;
if ( v14 )
{
v16 = cocos2d::CCString::getCString(v14);
v31 = 0;
v32 = 0;
v33 = 0;
v17 = -1;
do
++v17;
while ( v16[v17] );
sub_14003D230(&v31);
if ( v32 )
{
v18 = cocos2d::CCString::getCString(v14);
v34 = 0;
v35 = 0;
v19 = -1;
do
++v19;
while ( v18[v19] );
sub_14003D230(&v34);
v27 = 0;
v28 = 0;
v20 = -1;
do
++v20;
while ( v10[v20] );
sub_14003D230(&v27);
v21 = *(_QWORD *)(a1 + 336);
v22 = cocos2d::CCString::create(&v27);
cocos2d::CCDictionary::setObject(v21, v22, &v34);
if ( v28.m128i_i64[1] > 0xFuLL )
{
v23 = (void *)v27;
if ( (unsigned __int64)(v28.m128i_i64[1] + 1) >= 0x1000 )
{
v23 = *(void **)(v27 - 8);
if ( (unsigned __int64)(v27 - (_QWORD)v23 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v23);
}
v28 = si128;
LOBYTE(v27) = 0;
if ( *((_QWORD *)&v35 + 1) > 0xFu )
{
v24 = (void *)v34;
if ( (unsigned __int64)(*((_QWORD *)&v35 + 1) + 1LL) >= 0x1000 )
{
v24 = *(void **)(v34 - 8);
if ( (unsigned __int64)(v34 - (_QWORD)v24 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v24);
}
}
if ( v33 > 0xF )
{
v25 = (void *)v31;
if ( v33 + 1 >= 0x1000 )
{
v25 = *(void **)(v31 - 8);
if ( (unsigned __int64)(v31 - (_QWORD)v25 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v25);
}
}
++v5;
LODWORD(v1) = cocos2d::CCArray::count(v4);
}
while ( v5 < (unsigned int)v1 );
}
}
return (int)v1;
}