//
// MusicDownloadManager::parseSFXLibrary from 0x1005958f0 to 0x100596281 (2449 bytes)
//
// 3 xrefs:
// > SFXBrowser::init @ 0x10043f4a7
// > MusicDownloadManager::onDownloadSFXLibraryCompleted @ 0x100595809
// > MusicDownloadManager::tryLoadLibraries @ 0x10059667f
//
// 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
//
void __fastcall MusicDownloadManager::parseSFXLibrary(MusicDownloadManager *a1)
{
cocos2d::CCFileUtils *v1; // rax
std::string::pointer data; // rsi
std::string::value_type *v3; // rax
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v4; // al
std::string::size_type v5; // rbx
std::string::size_type v6; // rax
double v7; // xmm0_8
unsigned __int8 *v8; // rax
unsigned __int8 *v9; // rcx
cocos2d::CCObject *m_sfxObjects; // rdi
cocos2d::CCObject *m_sfxArtists; // rdi
cocos2d::CCDictionary *v12; // rax
cocos2d::CCDictionary *v13; // rdi
cocos2d::CCObject *v14; // rax
unsigned __int64 i; // r12
void **v16; // rbx
void **v17; // r14
char *v18; // r13
const char *v19; // r13
size_t v20; // rax
std::string::size_type v21; // rbx
char *v22; // r14
char *v23; // rbx
int v24; // r14d
unsigned int v25; // r13d
unsigned int v26; // r15d
const char *v27; // rbx
size_t v28; // r15
unsigned int v29; // ebx
const char *v30; // rdi
int v31; // eax
__int64 v32; // rbx
intptr_t v33; // rsi
cocos2d::CCObject *v34; // rax
__int64 v35; // rbx
intptr_t v36; // rsi
cocos2d::CCObject *v37; // rax
__int128 v38; // xmm0
std::string::size_type v39; // rbx
std::string::size_type size; // r13
unsigned __int64 v41; // r12
void **v42; // r13
void **v43; // r14
char *v44; // rax
cocos2d::CCArray *v45; // rbx
char *v46; // rax
char *v47; // rax
void *v48; // rdi
void **v49; // rbx
void **v50; // r14
void *v51; // rdi
void **v52; // rbx
void **v53; // r14
void *v54; // rdi
std::string::size_type v55; // r14
void *v56; // rdi
std::string v57; // [rsp+8h] [rbp-168h] BYREF
__int128 v58; // [rsp+20h] [rbp-150h] BYREF
void *v59; // [rsp+30h] [rbp-140h]
__int128 v60; // [rsp+40h] [rbp-130h] BYREF
void *v61; // [rsp+50h] [rbp-120h]
__int128 v62; // [rsp+60h] [rbp-110h] BYREF
void *v63; // [rsp+70h] [rbp-100h]
std::string v64; // [rsp+80h] [rbp-F0h] BYREF
__int64 v65; // [rsp+98h] [rbp-D8h] BYREF
__int128 v66; // [rsp+A0h] [rbp-D0h] BYREF
void *__p; // [rsp+B0h] [rbp-C0h]
std::string v68; // [rsp+C0h] [rbp-B0h] BYREF
void *v69[2]; // [rsp+E0h] [rbp-90h] BYREF
__int64 v70; // [rsp+F0h] [rbp-80h]
void *v71[2]; // [rsp+100h] [rbp-70h] BYREF
__int64 v72; // [rsp+110h] [rbp-60h]
unsigned int v73; // [rsp+11Ch] [rbp-54h]
std::string __dst; // [rsp+120h] [rbp-50h] BYREF
MusicDownloadManager *v75; // [rsp+140h] [rbp-30h]
v75 = a1;
MusicDownloadManager::pathForSFXFolder(&v57, (__int64)a1, 0);
std::string::append(&v57, "sfxlibrary.dat");
v65 = 0;
v1 = cocos2d::CCFileUtils::sharedFileUtils();
if ( (*(_BYTE *)&v57.__r_.__value_.__s.0 & 1) != 0 )
data = v57.__r_.__value_.__l.__data_;
else
data = v57.__r_.__value_.__s.__data_;
v3 = (std::string::value_type *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *, std::string::pointer, const char *, __int64 *))v1->addSearchResolutionsOrder)(
v1,
data,
"r",
&v65);
v66 = 0;
__p = nullptr;
if ( !v3 )
goto LABEL_133;
cocos2d::ZipUtils::decompressString2(&v68, v3, 0, v65, 11);
if ( (v66 & 1) != 0 )
operator delete(__p);
__p = v68.__r_.__value_.__l.__data_;
v66 = *(_OWORD *)&v68.__r_.__value_.__l.0;
v4 = v68.__r_.__value_.__s.0;
if ( (*(_BYTE *)&v68.__r_.__value_.__s.0 & 1) == 0 )
{
if ( !(*(_BYTE *)&v68.__r_.__value_.__l.0 >> 1) )
goto LABEL_131;
LABEL_11:
memset(&v68, 0, sizeof(v68));
sub_10058DFB0((unsigned __int8 *)&v66, "|", (__int64)&v68, 0.0);
v5 = v68.__r_.__value_.__r.__words[0];
if ( 0xAAAAAAAAAAAAAAABLL * ((__int64)(v68.__r_.__value_.__l.__size_ - v68.__r_.__value_.__r.__words[0]) >> 3) >= 2 )
{
*(_OWORD *)v69 = 0;
v70 = 0;
sub_10058DFB0((unsigned __int8 *)v68.__r_.__value_.__r.__words[0], ";", (__int64)v69, 0.0);
v6 = v68.__r_.__value_.__r.__words[0];
if ( (*(_BYTE *)v68.__r_.__value_.__r.__words[0] & 1) != 0 )
{
**(_BYTE **)(v68.__r_.__value_.__r.__words[0] + 16) = 0;
*(_QWORD *)(v6 + 8) = 0;
}
else
{
*(_WORD *)v68.__r_.__value_.__r.__words[0] = 0;
}
v7 = 0.0;
*(_OWORD *)v71 = 0;
v72 = 0;
v8 = (unsigned __int8 *)v69[0];
v9 = (unsigned __int8 *)v69[1];
if ( v69[1] != v69[0] )
{
m_sfxObjects = v75->m_sfxObjects;
if ( m_sfxObjects )
{
cocos2d::CCObject::release(m_sfxObjects);
m_sfxArtists = v75->m_sfxArtists;
if ( m_sfxArtists )
cocos2d::CCObject::release(m_sfxArtists);
}
v12 = cocos2d::CCDictionary::create();
v75->m_sfxObjects = v12;
v13 = v12;
cocos2d::CCObject::retain(v12);
v14 = (cocos2d::CCObject *)sub_10071F9E0(v13, ";");
v75->m_sfxArtists = (cocos2d::CCArray *)v14;
cocos2d::CCObject::retain(v14);
v75->m_sfxObjectCount = 0;
v8 = (unsigned __int8 *)v69[0];
v9 = (unsigned __int8 *)v69[1];
}
if ( v9 != v8 )
{
for ( i = 0; 0xAAAAAAAAAAAAAAABLL * (((char *)v69[1] - (char *)v69[0]) >> 3) > i; ++i )
{
v16 = (void **)v71[0];
v17 = (void **)v71[1];
if ( v71[1] != v71[0] )
{
do
{
if ( (*(_BYTE *)(v17 - 3) & 1) != 0 )
operator delete(*(v17 - 1));
v17 -= 3;
}
while ( v17 != v16 );
v8 = (unsigned __int8 *)v69[0];
}
v71[1] = v16;
sub_10058DFB0(&v8[24 * i], ",", (__int64)v71, v7);
v18 = (char *)v71[0];
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)v71[1] - (char *)v71[0]) >> 3) < 6 )
goto LABEL_22;
if ( (*(_BYTE *)v71[0] & 1) != 0 )
{
v73 = atoi(*((const char **)v71[0] + 2));
if ( (v18[24] & 1) != 0 )
{
LABEL_32:
v19 = *((const char **)v18 + 5);
goto LABEL_35;
}
}
else
{
v73 = atoi((const char *)v71[0] + 1);
if ( (v18[24] & 1) != 0 )
goto LABEL_32;
}
v19 = v18 + 25;
LABEL_35:
v20 = strlen(v19);
if ( v20 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v7);
v21 = v20;
if ( v20 >= 0x17 )
{
v28 = (v20 | 7) + 1;
if ( (v20 | 7) == 0x17 )
v28 = 26;
v22 = (char *)operator new(v28);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)v22;
__dst.__r_.__value_.__r.__words[0] = v28 | 1;
__dst.__r_.__value_.__l.__size_ = v21;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v20);
v22 = __dst.__r_.__value_.__s.__data_;
if ( !v20 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v23 = (char *)v71[0];
if ( (*((_BYTE *)v71[0] + 48) & 1) == 0 )
goto LABEL_39;
goto LABEL_47;
}
}
memmove(v22, v19, v21);
v22[v21] = 0;
v23 = (char *)v71[0];
if ( (*((_BYTE *)v71[0] + 48) & 1) == 0 )
{
LABEL_39:
v24 = atoi(v23 + 49);
if ( (v23[72] & 1) != 0 )
goto LABEL_40;
goto LABEL_48;
}
LABEL_47:
v24 = atoi(*((const char **)v23 + 8));
if ( (v23[72] & 1) != 0 )
{
LABEL_40:
v25 = atoi(*((const char **)v23 + 11));
if ( (v23[96] & 1) != 0 )
goto LABEL_41;
goto LABEL_49;
}
LABEL_48:
v25 = atoi(v23 + 73);
if ( (v23[96] & 1) != 0 )
{
LABEL_41:
v26 = atoi(*((const char **)v23 + 14));
if ( (v23[120] & 1) != 0 )
goto LABEL_42;
goto LABEL_50;
}
LABEL_49:
v26 = atoi(v23 + 97);
if ( (v23[120] & 1) != 0 )
{
LABEL_42:
v27 = *((const char **)v23 + 17);
goto LABEL_51;
}
LABEL_50:
v27 = v23 + 121;
LABEL_51:
v29 = atoi(v27);
if ( v73 == 1 )
{
v30 = __dst.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v30 = __dst.__r_.__value_.__l.__data_;
v31 = atoi(v30);
v75->m_sfxLibraryVersion = v31;
std::string::assign(&__dst, "Root");
}
if ( v24 )
{
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v60, __dst.__r_.__value_.__l.__data_, __dst.__r_.__value_.__l.__size_, v7);
}
else
{
v61 = __dst.__r_.__value_.__l.__data_;
v7 = *(double *)__dst.__r_.__value_.__r.__words;
v60 = *(_OWORD *)&__dst.__r_.__value_.__l.0;
}
v32 = SFXFolderObject::create(v73, &v60, v25);
cocos2d::CCDictionary::setObject(v75->m_sfxObjects, (cocos2d::CCObject *)v32, *(int *)(v32 + 56));
v33 = *(int *)(v32 + 60);
if ( v33 > 0 )
{
v34 = cocos2d::CCDictionary::objectForKey(v75->m_sfxObjects, v33);
if ( v34 )
{
if ( LOBYTE(v34[1].m_nTag) == 1 )
sub_10071FCD0(*(_QWORD *)&v34[1].m_uOrderOfArrival, v32);
}
}
if ( (v60 & 1) != 0 )
operator delete(v61);
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_22;
}
else
{
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v58, __dst.__r_.__value_.__l.__data_, __dst.__r_.__value_.__l.__size_, v7);
}
else
{
v59 = __dst.__r_.__value_.__l.__data_;
v7 = *(double *)__dst.__r_.__value_.__r.__words;
v58 = *(_OWORD *)&__dst.__r_.__value_.__l.0;
}
v35 = SFXInfoObject::create(v73, &v58, v25, v26, v29);
cocos2d::CCDictionary::setObject(v75->m_sfxObjects, (cocos2d::CCObject *)v35, *(int *)(v35 + 56));
v36 = *(int *)(v35 + 60);
if ( v36 > 0 )
{
v37 = cocos2d::CCDictionary::objectForKey(v75->m_sfxObjects, v36);
if ( v37 )
{
if ( LOBYTE(v37[1].m_nTag) == 1 )
sub_10071FCD0(*(_QWORD *)&v37[1].m_uOrderOfArrival, v35);
}
}
if ( (v58 & 1) != 0 )
operator delete(v59);
++v75->m_sfxObjectCount;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_22;
}
operator delete(__dst.__r_.__value_.__l.__data_);
LABEL_22:
v8 = (unsigned __int8 *)v69[0];
}
}
*(_QWORD *)&v38 = 0;
memset(&__dst, 0, sizeof(__dst));
sub_10058DFB0((unsigned __int8 *)(v68.__r_.__value_.__r.__words[0] + 24), ";", (__int64)&__dst, 0.0);
size = __dst.__r_.__value_.__l.__size_;
v39 = __dst.__r_.__value_.__r.__words[0];
if ( __dst.__r_.__value_.__l.__size_ != __dst.__r_.__value_.__r.__words[0] )
{
v41 = 0;
do
{
v42 = (void **)v71[0];
v43 = (void **)v71[1];
if ( v71[1] != v71[0] )
{
do
{
if ( (*(_BYTE *)(v43 - 3) & 1) != 0 )
operator delete(*(v43 - 1));
v43 -= 3;
}
while ( v43 != v42 );
v39 = __dst.__r_.__value_.__r.__words[0];
}
v71[1] = v42;
sub_10058DFB0((unsigned __int8 *)(v39 + 24 * v41), ",", (__int64)v71, *(double *)&v38);
v44 = (char *)v71[0];
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)v71[1] - (char *)v71[0]) >> 3) < 2 )
goto LABEL_80;
v45 = v75->m_sfxArtists;
if ( (*(_BYTE *)v71[0] & 1) != 0 )
{
sub_100006B70(&v62, *((const void **)v71[0] + 2), *((_QWORD *)v71[0] + 1), *(double *)&v38);
v44 = (char *)v71[0];
if ( (*((_BYTE *)v71[0] + 24) & 1) != 0 )
{
LABEL_92:
sub_100006B70(&v64, *((const void **)v44 + 5), *((_QWORD *)v44 + 4), *(double *)&v38);
goto LABEL_93;
}
}
else
{
v63 = *((void **)v71[0] + 2);
v38 = *(_OWORD *)v71[0];
v62 = *(_OWORD *)v71[0];
if ( (*((_BYTE *)v71[0] + 24) & 1) != 0 )
goto LABEL_92;
}
v46 = v44 + 24;
v64.__r_.__value_.__r.__words[2] = *((_QWORD *)v46 + 2);
v38 = *(_OWORD *)v46;
*(_OWORD *)&v64.__r_.__value_.__l.0 = *(_OWORD *)v46;
LABEL_93:
v47 = CCURLObject::create(&v62, &v64);
sub_10071FCD0(v45, v47);
if ( (*(_BYTE *)&v64.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v64.__r_.__value_.__l.__data_);
if ( (v62 & 1) != 0 )
operator delete(v63);
LABEL_80:
++v41;
size = __dst.__r_.__value_.__l.__size_;
v39 = __dst.__r_.__value_.__r.__words[0];
}
while ( 0xAAAAAAAAAAAAAAABLL
* ((__int64)(__dst.__r_.__value_.__l.__size_ - __dst.__r_.__value_.__r.__words[0]) >> 3) > v41 );
}
if ( v39 )
{
v48 = (void *)v39;
if ( size != v39 )
{
do
{
if ( (*(_BYTE *)(size - 24) & 1) != 0 )
operator delete(*(void **)(size - 8));
size -= 24LL;
}
while ( size != v39 );
v48 = (void *)__dst.__r_.__value_.__r.__words[0];
}
__dst.__r_.__value_.__l.__size_ = v39;
operator delete(v48);
}
v49 = (void **)v71[0];
if ( v71[0] )
{
v50 = (void **)v71[1];
v51 = v71[0];
if ( v71[1] != v71[0] )
{
do
{
if ( (*(_BYTE *)(v50 - 3) & 1) != 0 )
operator delete(*(v50 - 1));
v50 -= 3;
}
while ( v50 != v49 );
v51 = v71[0];
}
v71[1] = v49;
operator delete(v51);
}
v52 = (void **)v69[0];
if ( v69[0] )
{
v53 = (void **)v69[1];
v54 = v69[0];
if ( v69[1] != v69[0] )
{
do
{
if ( (*(_BYTE *)(v53 - 3) & 1) != 0 )
operator delete(*(v53 - 1));
v53 -= 3;
}
while ( v53 != v52 );
v54 = v69[0];
}
v69[1] = v52;
operator delete(v54);
}
v5 = v68.__r_.__value_.__r.__words[0];
}
if ( v5 )
{
v55 = v68.__r_.__value_.__l.__size_;
v56 = (void *)v5;
if ( v68.__r_.__value_.__l.__size_ != v5 )
{
do
{
if ( (*(_BYTE *)(v55 - 24) & 1) != 0 )
operator delete(*(void **)(v55 - 8));
v55 -= 24LL;
}
while ( v55 != v5 );
v56 = (void *)v68.__r_.__value_.__r.__words[0];
}
v68.__r_.__value_.__l.__size_ = v5;
operator delete(v56);
}
v4 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)v66;
goto LABEL_131;
}
if ( *((_QWORD *)&v66 + 1) )
goto LABEL_11;
LABEL_131:
if ( (*(_BYTE *)&v4 & 1) != 0 )
operator delete(__p);
LABEL_133:
if ( (*(_BYTE *)&v57.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v57.__r_.__value_.__l.__data_);
}