//
// MusicDownloadManager::createSongsInfo from 0x10058d3d0 to 0x10058d79f (975 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetOnlineLevelsCompleted @ 0x10051eb65
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x100544cc3
//
// 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(__m128 *a1, unsigned __int8 *a2, __int64 a3, __m128 a4)
{
unsigned int v4; // eax
__int64 result; // rax
const char *v6; // rbx
size_t v7; // rax
size_t v8; // r15
__int8 *v9; // r12
size_t v10; // r13
cocos2d::CCArray *v11; // r14
unsigned int v12; // r12d
cocos2d::CCString *v13; // rax
const char *CString; // r15
size_t v15; // rax
size_t v16; // rbx
__int8 *v17; // r13
__int8 v18; // r13
size_t v19; // r14
SongInfoObject *v20; // r15
std::__hash_node_base *>::__next_pointer i; // r14
cocos2d::CCString *v22; // rax
const char *v23; // rax
char v24; // [rsp+0h] [rbp-C0h]
__m128 *v25; // [rsp+8h] [rbp-B8h]
__m128 v26; // [rsp+10h] [rbp-B0h] BYREF
void *__p; // [rsp+20h] [rbp-A0h]
__m128 v28; // [rsp+30h] [rbp-90h] BYREF
void *v29; // [rsp+40h] [rbp-80h]
cocos2d::CCDictionary *v30; // [rsp+50h] [rbp-70h]
cocos2d::CCArray *v31; // [rsp+58h] [rbp-68h]
std::string __str; // [rsp+60h] [rbp-60h] BYREF
__m128 __dst; // [rsp+78h] [rbp-48h] BYREF
void *v34; // [rsp+88h] [rbp-38h]
__int8 v35; // [rsp+97h] [rbp-29h]
v25 = a1;
v4 = *a2;
if ( (v4 & 1) != 0 )
{
result = *((_QWORD *)a2 + 1);
if ( !result )
return result;
}
else
{
result = v4 >> 1;
if ( !result )
return result;
}
if ( (*(_BYTE *)a3 & 1) != 0 )
{
a1 = &v26;
sub_100006B70(&v26, *(const void **)(a3 + 16), *(_QWORD *)(a3 + 8), *(double *)a4.i64);
}
else
{
__p = *(void **)(a3 + 16);
a4 = *(__m128 *)a3;
v26 = *(__m128 *)a3;
}
v30 = (cocos2d::CCDictionary *)MusicDownloadManager::createArtistsInfo(a1, &v26);
if ( (v26.i8[0] & 1) != 0 )
operator delete(__p);
if ( (*a2 & 1) != 0 )
v6 = *((const char **)a2 + 2);
else
v6 = (const char *)(a2 + 1);
v7 = strlen(v6);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_55:
sub_100006BF0(*(double *)a4.i64);
v8 = v7;
if ( v7 >= 0x17 )
{
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
v9 = (__int8 *)operator new(v10);
v34 = v9;
__dst.i64[0] = v10 + 1;
__dst.i64[1] = v8;
goto LABEL_20;
}
__dst.i8[0] = 2 * v7;
v9 = &__dst.i8[1];
if ( v7 )
LABEL_20:
memmove(v9, v6, v8);
v9[v8] = 0;
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)6;
*(_DWORD *)((char *)&__str.__r_.__value_.__l.0 + 1) = 8272510;
v11 = (cocos2d::CCArray *)sub_10058DAD0(&__dst, &__str);
if ( (__dst.i8[0] & 1) != 0 )
operator delete(v34);
result = sub_100720070(v11);
if ( (_DWORD)result )
{
v12 = 0;
v31 = v11;
do
{
v13 = cocos2d::CCArray::stringAtIndex(v11, v12);
CString = cocos2d::CCString::getCString(v13);
v15 = strlen(CString);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_55;
v16 = v15;
if ( v15 >= 0x17 )
{
v19 = (v15 | 7) + 1;
if ( (v15 | 7) == 0x17 )
v19 = 26;
v17 = (__int8 *)operator new(v19);
v34 = v17;
__dst.i64[0] = v19 + 1;
v11 = v31;
__dst.i64[1] = v16;
}
else
{
__dst.i8[0] = 2 * v15;
v17 = &__dst.i8[1];
if ( !v15 )
{
__dst.i8[1] = 0;
v18 = __dst.i8[0];
if ( (__dst.i8[0] & 1) == 0 )
goto LABEL_30;
goto LABEL_35;
}
}
memmove(v17, CString, v16);
v17[v16] = 0;
v18 = __dst.i8[0];
if ( (__dst.i8[0] & 1) == 0 )
{
LABEL_30:
v29 = v34;
a4 = __dst;
v28 = __dst;
goto LABEL_36;
}
LABEL_35:
sub_100006B70(&v28, v34, __dst.u64[1], *(double *)a4.i64);
LABEL_36:
v20 = MusicDownloadManager::addSongObjectFromString(v25, (__int64)&v28, a4);
if ( (v28.i8[0] & 1) != 0 )
operator delete(v29);
if ( v30 != nullptr && v20 != nullptr && v20->m_artistIDs.__table_.__p2_.__value_ )
{
v35 = v18;
a4 = 0;
memset(&__str, 0, sizeof(__str));
for ( i = v20->m_artistIDs.__table_.__p1_.__value_.__next_; ; i = i->__next_ )
{
if ( !i )
{
std::string::operator=((std::string *)&v20->m_extraArtistNames, &__str);
v11 = v31;
v18 = v35;
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
goto LABEL_52;
}
if ( cocos2d::CCDictionary::objectForKey(v30, SLODWORD(i[2].__next_)) )
break;
LABEL_41:
;
}
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
{
if ( !__str.__r_.__value_.__l.__size_ )
goto LABEL_49;
LABEL_48:
std::string::append(&__str, ",");
}
else if ( *(_BYTE *)&__str.__r_.__value_.__l.0 >> 1 )
{
goto LABEL_48;
}
LABEL_49:
v22 = (cocos2d::CCString *)sub_1007AB580("%i,%s", v24);
v23 = cocos2d::CCString::getCString(v22);
std::string::append(&__str, v23);
goto LABEL_41;
}
LABEL_52:
if ( (v18 & 1) != 0 )
operator delete(v34);
++v12;
result = sub_100720070(v11);
}
while ( v12 < (unsigned int)result );
}
return result;
}