//
// MusicDownloadManager::createSongsInfo from 0x837308 to 0x83778c (1156 bytes)
//
// 3 xrefs:
// > GameLevelManager::onGetOnlineLevelsCompleted @ 0x705824
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x707690
// > ??> @ 0xae288
//
// 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 MusicDownloadManager::createSongsInfo(__int64 a1, char **a2)
{
cocos2d::CCDictionary *v4; // x23
char *v5; // x0
char *v6; // x0
void *v7; // x0
unsigned int v8; // w26
cocos2d::CCString *v9; // x0
char *CString; // x0
SongInfoObject *v11; // x27
char *v12; // x0
std::__detail::_Hash_node_base *i; // x19
unsigned int M_nxt; // w20
cocos2d::CCObject *v15; // x21
cocos2d::CCString *v16; // x0
size_t v17; // x0
char *v18; // x0
void *v19; // x0
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x1
int v23; // w2
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x3
int v27; // w1
unsigned int *v28; // x3
int v29; // w1
unsigned int *v30; // x3
int v31; // w1
cocos2d::CCArray *v33; // [xsp+78h] [xbp+78h]
const char *v34; // [xsp+88h] [xbp+88h]
__int64 v35; // [xsp+A8h] [xbp+A8h] BYREF
char *v36; // [xsp+B0h] [xbp+B0h] BYREF
if ( *((_QWORD *)*a2 - 3) )
{
sub_D18D28(&v36);
v4 = MusicDownloadManager::createArtistsInfo(a1, &v36);
v5 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
v26 = (unsigned int *)(v36 - 8);
if ( &pthread_create )
{
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v5);
}
sub_D153B8((int)&v35, *a2);
sub_D153B8((int)&v36, "~:~");
v33 = sub_827328(&v35, (void **)&v36);
v6 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
v30 = (unsigned int *)(v36 - 8);
if ( &pthread_create )
{
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v6);
}
v7 = (void *)(v35 - 24);
if ( (__int64 *)(v35 - 24) != &qword_124B6B0 )
{
v28 = (unsigned int *)(v35 - 8);
if ( &pthread_create )
{
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(_DWORD *)(v35 - 8);
*(_DWORD *)(v35 - 8) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v7);
}
v8 = 0;
while ( v8 < (unsigned int)cocos2d::CCArray::count(v33) )
{
v9 = cocos2d::CCArray::stringAtIndex(v33, v8);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v35, CString);
sub_D18D28(&v36);
v11 = MusicDownloadManager::addSongObjectFromString(a1);
v12 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v36 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v12);
}
if ( v11 && v4 && v11->m_artistIDs._M_h._M_element_count )
{
v36 = &byte_124B6C8;
for ( i = v11->m_artistIDs._M_h._M_before_begin._M_nxt; i; i = i->_M_nxt )
{
M_nxt = (unsigned int)i[1]._M_nxt;
v15 = cocos2d::CCDictionary::objectForKey(v4, (int)M_nxt);
if ( v15 )
{
if ( *((_QWORD *)v36 - 3) )
sub_D15FD4(&v36, &byte_F804F8, 1);
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i,%s",
(const char *)M_nxt,
*(_QWORD *)&v15[1].m_uID);
v34 = cocos2d::CCString::getCString(v16);
v17 = strlen(v34);
sub_D15FD4(&v36, v34, v17);
}
}
sub_D18EA8(&v11->m_extraArtistNames, &v36);
v18 = v36 - 24;
if ( v36 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v36 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v18);
}
}
v19 = (void *)(v35 - 24);
if ( (__int64 *)(v35 - 24) == &qword_124B6B0 )
goto LABEL_20;
if ( &pthread_create )
{
v20 = (unsigned int *)(v35 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(v35 - 8);
*(_DWORD *)(v35 - 8) = v21 - 1;
}
if ( v21 > 0 )
{
LABEL_20:
++v8;
}
else
{
++v8;
operator delete(v19);
}
}
}
return _stack_chk_guard;
}