//
// MusicDownloadManager::clearSong from 0x829648 to 0x82974c (260 bytes)
//
// 2 xrefs:
// > MusicDownloadManager::clearUnusedSongs @ 0x83014c
// > ??> @ 0xa23f0
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void MusicDownloadManager::clearSong(MusicDownloadManager *a1, int a2)
{
cocos2d::CCDictionary *m_songObjects; // x21
cocos2d::CCString *v3; // x0
char *CString; // x0
char *v5; // x0
unsigned int *v6; // x2
int v7; // w1
std::string v8; // [xsp+40h] [xbp+40h] BYREF
m_songObjects = a1->m_songObjects;
v3 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", *(const char **)&a2);
CString = (char *)cocos2d::CCString::getCString(v3);
sub_D153B8((int)&v8, CString);
cocos2d::CCDictionary::removeObjectForKey(m_songObjects, &v8);
v5 = (char *)v8.m_data.m_data - 24;
if ( (__int64 *)v8.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v6 = (unsigned int *)((char *)v8.m_data.m_data - 8);
do
v7 = __ldaxr(v6);
while ( __stlxr(v7 - 1, v6) );
}
else
{
v7 = *((_DWORD *)v8.m_data.m_data - 2);
*((_DWORD *)v8.m_data.m_data - 2) = v7 - 1;
}
if ( v7 <= 0 )
operator delete(v5);
}
}