//
// GameManager::completedAchievement from 0x5f35f8 to 0x5f3748 (336 bytes)
//
// 3 xrefs:
// > GameManager::reportAchievementWithID @ 0x5f37f0
// > GameManager::verifyAchievementUnlocks @ 0x5f4118
// > ??> @ 0x99138
//
// 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
//
__int64 __fastcall GameManager::completedAchievement(GameManager *a1, const char **a2)
{
const char *v3; // x0
void *v4; // x0
int v5; // w20
IconType v6; // w0
unsigned int *v8; // x2
int v9; // w1
int v11; // [xsp+48h] [xbp+48h] BYREF
int v12; // [xsp+4Ch] [xbp+4Ch] BYREF
__int64 v13; // [xsp+50h] [xbp+50h] BYREF
v3 = *a2;
v11 = 0;
v12 = 0;
PlatformToolbox::logEvent(v3);
sub_D18D28(&v13, a2);
GameManager::getUnlockForAchievement((__int64)a1, (__int64)&v13, &v11, &v12);
v4 = (void *)(v13 - 24);
if ( (__int64 *)(v13 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v13 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *(_DWORD *)(v13 - 8);
*(_DWORD *)(v13 - 8) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v4);
}
if ( v12 )
{
if ( (unsigned int)(v12 - 2) <= 1 )
{
GameManager::unlockColor(a1, v11, (UnlockType)v12);
}
else
{
v5 = v11;
v6 = GameManager::unlockTypeToIconType(a1, v12);
GameManager::unlockIcon(a1, v5, v6);
}
}
return _stack_chk_guard;
}