//
// GJGarageLayer::descriptionForUnlock from 0x791378 to 0x791548 (464 bytes)
//
// 2 xrefs:
// > ItemInfoPopup::init @ 0x7952b4
// > ??> @ 0x78dc8
//
// 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 __usercall GJGarageLayer::descriptionForUnlock@(signed int a1@, int a2@, __int64 a3@)
{
AchievementManager *v4; // x0
AchievementManager *v5; // x0
cocos2d::CCDictionary *AchievementsWithID; // x19
cocos2d::CCString *v7; // x0
char *CString; // x0
char *v9; // x0
char *v10; // x0
unsigned int *v12; // x1
int v13; // w2
unsigned int *v14; // x1
int v15; // w2
char *v18; // [xsp+68h] [xbp+68h] BYREF
std::string v19; // [xsp+70h] [xbp+70h] BYREF
v4 = AchievementManager::sharedState();
AchievementManager::achievementForUnlock((__int64)v4, a1, a2, (__int64)&v18);
v5 = AchievementManager::sharedState();
AchievementsWithID = AchievementManager::getAchievementsWithID(v5, v18);
sub_D153B8((int)&v19, "unachievedDescription");
v7 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(AchievementsWithID, &v19);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8(a3, CString);
v9 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)((char *)v19.m_data.m_data - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v9);
}
v10 = v18 - 24;
if ( v18 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v18 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v18 - 2);
*((_DWORD *)v18 - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v10);
}
return a3;
}