//
// MusicDownloadManager::addSongObjectFromString from 0x836644 to 0x836970 (812 bytes)
//
// 3 xrefs:
// > MusicDownloadManager::onGetSongInfoCompleted @ 0x836ab0
// > MusicDownloadManager::createSongsInfo @ 0x837480
// > ??> @ 0x404b8
//
// 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
//
SongInfoObject *__fastcall MusicDownloadManager::addSongObjectFromString(__int64 a1)
{
cocos2d::CCDictionary *v2; // x25
int *p_m_uOrderOfArrival; // x0
SongInfoObject *v4; // x0
const char *m_songID; // x1
SongInfoObject *v6; // x20
cocos2d::CCDictionary *v7; // x27
cocos2d::CCString *v8; // x0
char *CString; // x0
__int64 v10; // x27
int *v11; // x0
cocos2d::CCString *v12; // x0
bool v13; // w25
int *v14; // x0
const char *v15; // x1
__int64 v16; // x23
cocos2d::CCString *v17; // x0
char *v18; // x0
int *v19; // x0
unsigned int *v21; // x19
cocos2d::CCDictionary::CCDictType v22; // w1
unsigned int *v23; // x1
cocos2d::CCDictionary::CCDictType v24; // w2
unsigned int *p_m_eDictType; // x1
cocos2d::CCDictionary::CCDictType m_eDictType; // w2
unsigned int *v27; // x1
cocos2d::CCDictionary::CCDictType v28; // w2
cocos2d::CCDictionary *v29; // [xsp+70h] [xbp+70h] BYREF
sub_D18D28(&v29);
v2 = MusicDownloadManager::responseToDict(a1, (char **)&v29, "~|~");
p_m_uOrderOfArrival = &v29[-1].m_uOrderOfArrival;
if ( &v29[-1].m_uOrderOfArrival != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_eDictType = (unsigned int *)&v29[-1].m_eDictType;
do
m_eDictType = __ldaxr(p_m_eDictType);
while ( __stlxr(m_eDictType - 1, p_m_eDictType) );
}
else
{
m_eDictType = v29[-1].m_eDictType;
v29[-1].m_eDictType = m_eDictType - 1;
}
if ( (int)m_eDictType <= (int)kCCDictUnknown )
operator delete(p_m_uOrderOfArrival);
}
v4 = SongInfoObject::create(v2);
m_songID = (const char *)(unsigned int)v4->m_songID;
v6 = v4;
if ( !(_DWORD)m_songID )
return nullptr;
v7 = *(cocos2d::CCDictionary **)(a1 + 344);
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", m_songID);
CString = (char *)cocos2d::CCString::getCString(v8);
sub_D153B8((int)&v29, CString);
v10 = cocos2d::CCDictionary::objectForKey(v7, (const std::string *)&v29);
v11 = &v29[-1].m_uOrderOfArrival;
if ( &v29[-1].m_uOrderOfArrival != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)&v29[-1].m_eDictType;
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = v29[-1].m_eDictType;
v29[-1].m_eDictType = v24 - 1;
}
if ( (int)v24 <= (int)kCCDictUnknown )
operator delete(v11);
}
if ( v10 )
SongInfoObject::copyValues(v6);
sub_D153B8((int)&v29, "8");
v12 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v2, (const std::string *)&v29);
v13 = cocos2d::CCString::boolValue(v12);
v14 = &v29[-1].m_uOrderOfArrival;
if ( &v29[-1].m_uOrderOfArrival != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)&v29[-1].m_eDictType;
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = v29[-1].m_eDictType;
v29[-1].m_eDictType = v28 - 1;
}
if ( (int)v28 <= (int)kCCDictUnknown )
operator delete(v14);
}
v15 = (const char *)(unsigned int)v6->m_songID;
v6->m_verified = !v13;
v16 = *(_QWORD *)(a1 + 344);
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v15);
v18 = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v29, v18);
cocos2d::CCDictionary::setObject(v16, v6);
v19 = &v29[-1].m_uOrderOfArrival;
if ( &v29[-1].m_uOrderOfArrival != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)&v29[-1].m_eDictType;
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = v29[-1].m_eDictType;
v29[-1].m_eDictType = v22 - 1;
}
if ( (int)v22 <= (int)kCCDictUnknown )
operator delete(v19);
}
return v6;
}