//
// MusicDownloadManager::parseSFXLibrary from 0x830838 to 0x831508 (3280 bytes)
//
// 4 xrefs:
// > MusicDownloadManager::onDownloadSFXLibraryCompleted @ 0x8315dc
// > MusicDownloadManager::tryLoadLibraries @ 0x83a2f0
// > sub_A5DEA4 @ 0xa5ec90
// > ??> @ 0xb1a20
//
// 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 MusicDownloadManager::parseSFXLibrary(MusicDownloadManager *a1)
{
cocos2d::CCFileUtils *v2; // x0
cocos2d::ZipUtils *v3; // x0
int v4; // w4
char *v5; // x1
char *v6; // x0
__int64 *v7; // x21
__int64 *v8; // x22
__int64 *v9; // x0
__int64 *v10; // x27
__int64 *v11; // x2
unsigned __int64 v12; // x22
void *v13; // x28
__int64 *v14; // x3
__int64 *v15; // x27
__int64 v16; // x1
__int64 *v17; // x0
unsigned int *v18; // x1
int v19; // w2
cocos2d::CCArray *v20; // x27
cocos2d::CCObject *v21; // x0
char *v22; // x0
void *v23; // x0
__int64 *v24; // x20
__int64 *v25; // x21
__int64 v26; // x1
__int64 *v27; // x0
unsigned int *v28; // x1
int v29; // w2
void *v30; // x0
char *v31; // x0
void *v32; // x0
unsigned int *v33; // x1
int v34; // w3
__int64 v35; // x1
__int64 *v36; // x0
__int64 *v37; // x20
__int64 *v38; // x21
__int64 v39; // x1
__int64 *v40; // x0
unsigned int *v41; // x1
int v42; // w2
__int64 *v43; // x20
__int64 *v44; // x21
__int64 v45; // x1
__int64 *v46; // x0
unsigned int *v47; // x1
int v48; // w2
char *v49; // x0
unsigned int *v50; // x1
int v51; // w2
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x1
int v55; // w2
cocos2d::CCDictionary *m_sfxObjects; // x0
cocos2d::CCArray *m_sfxArtists; // x0
cocos2d::CCDictionary *v58; // x0
cocos2d::CCArray *v59; // x0
cocos2d::CCArray *v60; // x0
_QWORD *v61; // x0
_BYTE *v62; // x1
unsigned __int64 i; // x21
void *v64; // x26
__int64 *v65; // x25
__int64 *v66; // x22
__int64 v67; // x1
__int64 *v68; // x0
unsigned int *v69; // x1
int v70; // w2
void *v71; // x22
int v72; // w25
void *v73; // x22
int v74; // w27
int v75; // w26
int v76; // w22
SFXInfoObject *v77; // x0
void *v78; // x0
char *v79; // x0
unsigned int *v80; // x1
int v81; // w2
SFXInfoObject *v82; // x0
char *v83; // x0
unsigned int *v84; // x1
int v85; // w2
unsigned int *v86; // x1
int v87; // w2
__int64 v88; // x1
__int64 *v89; // x0
unsigned int *v90; // x1
int v91; // w2
unsigned int *v92; // x1
int v93; // w2
unsigned int *v94; // x1
int v95; // w2
unsigned int *v96; // x1
int v97; // w2
unsigned int *v98; // x1
int v99; // w2
int v100; // [xsp+80h] [xbp+80h]
int v101[2]; // [xsp+88h] [xbp+88h]
int v102[2]; // [xsp+88h] [xbp+88h]
__int64 v103; // [xsp+98h] [xbp+98h] BYREF
bool v104[8]; // [xsp+A0h] [xbp+A0h] BYREF
char *v105; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v106; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v107; // [xsp+B8h] [xbp+B8h] BYREF
const char *v108; // [xsp+C0h] [xbp+C0h] BYREF
void *v109; // [xsp+C8h] [xbp+C8h] BYREF
void *v110; // [xsp+D0h] [xbp+D0h]
__int64 v111; // [xsp+D8h] [xbp+D8h]
void *v112; // [xsp+E0h] [xbp+E0h] BYREF
void *v113; // [xsp+E8h] [xbp+E8h]
__int64 v114; // [xsp+F0h] [xbp+F0h]
void *v115; // [xsp+F8h] [xbp+F8h] BYREF
void *v116; // [xsp+100h] [xbp+100h]
__int64 v117; // [xsp+108h] [xbp+108h]
void *p; // [xsp+110h] [xbp+110h] BYREF
__int64 *v119; // [xsp+118h] [xbp+118h]
__int64 v120; // [xsp+120h] [xbp+120h]
MusicDownloadManager::pathForSFXFolder(a1, 0, (__int64)&v103);
sub_D15FD4(&v103, "sfxlibrary.dat", 14);
*(_QWORD *)v104 = 0;
v2 = cocos2d::CCFileUtils::sharedFileUtils();
v3 = (cocos2d::ZipUtils *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *, __int64, char *, bool *))v2->addSearchResolutionsOrder)(
v2,
v103,
"r",
v104);
v5 = &byte_124B6C8;
v105 = &byte_124B6C8;
if ( v3 )
{
cocos2d::ZipUtils::decompressString2((__int64 *)&v115, v3, nullptr, v104[0], 11, v4);
sub_D163D4(&v105, &v115);
v6 = (char *)v115 - 24;
if ( (char *)v115 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v96 = (unsigned int *)((char *)v115 - 8);
do
v97 = __ldaxr(v96);
while ( __stlxr(v97 - 1, v96) );
}
else
{
v97 = *((_DWORD *)v115 - 2);
*((_DWORD *)v115 - 2) = v97 - 1;
}
if ( v97 <= 0 )
operator delete(v6);
}
v5 = v105;
if ( *((_QWORD *)v105 - 3) )
{
v109 = nullptr;
v110 = nullptr;
v111 = 0;
sub_830154(&v105, "|", (__int64)&v109);
v7 = (__int64 *)v109;
v8 = (__int64 *)v110;
if ( (unsigned __int64)((_BYTE *)v110 - (_BYTE *)v109) > 0xF )
{
v112 = nullptr;
v113 = nullptr;
v114 = 0;
sub_830154(v109, ";", (__int64)&v112);
sub_D174B8(v109, 0, *(_QWORD *)(*(_QWORD *)v109 - 24LL), 0);
v115 = nullptr;
v116 = nullptr;
v117 = 0;
if ( ((_BYTE *)v113 - (_BYTE *)v112) >> 3 )
{
m_sfxObjects = a1->m_sfxObjects;
if ( m_sfxObjects )
{
cocos2d::CCObject::release(m_sfxObjects);
m_sfxArtists = a1->m_sfxArtists;
if ( m_sfxArtists )
cocos2d::CCObject::release(m_sfxArtists);
}
v58 = cocos2d::CCDictionary::create();
a1->m_sfxObjects = v58;
cocos2d::CCObject::retain(v58);
v60 = (cocos2d::CCArray *)cocos2d::CCArray::create(v59);
a1->m_sfxArtists = v60;
cocos2d::CCObject::retain(v60);
v61 = v112;
v62 = v113;
a1->m_sfxObjectCount = 0;
if ( (v62 - (_BYTE *)v61) >> 3 )
{
for ( i = 0; i < ((_BYTE *)v113 - (_BYTE *)v112) >> 3; ++i )
{
v64 = v115;
v65 = (__int64 *)v116;
v66 = (__int64 *)v115;
if ( v115 != v116 )
{
do
{
while ( 1 )
{
v67 = *v66;
v68 = (__int64 *)(*v66 - 24);
if ( v68 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)(v67 - 8);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *(_DWORD *)(v67 - 8);
*(_DWORD *)(v67 - 8) = v70 - 1;
}
if ( v70 <= 0 )
break;
}
if ( v65 == ++v66 )
goto LABEL_108;
}
++v66;
operator delete(v68);
}
while ( v65 != v66 );
LABEL_108:
v61 = v112;
}
v116 = v64;
sub_830154(&v61[i], &byte_F804F8, (__int64)&v115);
v71 = v115;
if ( (unsigned __int64)((_BYTE *)v116 - (_BYTE *)v115) <= 0x2F )
goto LABEL_110;
v72 = atoi(*(const char **)v115);
sub_D153B8((int)&v108, *(char **)&byte_8[(_QWORD)v71]);
v73 = v115;
v74 = atoi(*(const char **)((char *)&word_10 + (_QWORD)v115));
v75 = atoi(*(const char **)((char *)&off_18 + (_QWORD)v73));
v100 = atoi(*(const char **)((char *)&qword_20 + (_QWORD)v73));
v76 = atoi(*(const char **)((char *)&qword_28 + (_QWORD)v73));
if ( v72 == 1 )
{
a1->m_sfxLibraryVersion = atoi(v108);
sub_D1798C(&v108, "Root", 4);
if ( v74 )
{
LABEL_125:
sub_D18D28(&p);
v82 = (SFXInfoObject *)SFXFolderObject::create(v72, (__int64)&p, v75);
MusicDownloadManager::storeSFXInfoObject(a1, v82);
v83 = (char *)p - 24;
if ( (char *)p - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v84 = (unsigned int *)((char *)p - 8);
do
v85 = __ldaxr(v84);
while ( __stlxr(v85 - 1, v84) );
}
else
{
v85 = *((_DWORD *)p - 2);
*((_DWORD *)p - 2) = v85 - 1;
}
if ( v85 <= 0 )
operator delete(v83);
}
goto LABEL_118;
}
}
else if ( v74 )
{
goto LABEL_125;
}
sub_D18D28(&v106);
v77 = (SFXInfoObject *)SFXInfoObject::create(v72, (__int64)&v106, v75, v100, v76);
MusicDownloadManager::storeSFXInfoObject(a1, v77);
v78 = (void *)(v106 - 24);
if ( (__int64 *)(v106 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v86 = (unsigned int *)(v106 - 8);
do
v87 = __ldaxr(v86);
while ( __stlxr(v87 - 1, v86) );
}
else
{
v87 = *(_DWORD *)(v106 - 8);
*(_DWORD *)(v106 - 8) = v87 - 1;
}
if ( v87 <= 0 )
operator delete(v78);
}
++a1->m_sfxObjectCount;
LABEL_118:
v79 = (char *)(v108 - 24);
if ( v108 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v80 = (unsigned int *)(v108 - 8);
do
v81 = __ldaxr(v80);
while ( __stlxr(v81 - 1, v80) );
}
else
{
v81 = *((_DWORD *)v108 - 2);
*((_DWORD *)v108 - 2) = v81 - 1;
}
if ( v81 <= 0 )
operator delete(v79);
}
LABEL_110:
v61 = v112;
}
}
}
p = nullptr;
v119 = nullptr;
v120 = 0;
sub_830154((_QWORD *)v109 + 1, ";", (__int64)&p);
v9 = (__int64 *)p;
v10 = v119;
v11 = (__int64 *)p;
if ( ((char *)v119 - (_BYTE *)p) >> 3 )
{
v12 = 0;
do
{
v13 = v115;
v14 = (__int64 *)v116;
v15 = (__int64 *)v115;
if ( v115 != v116 )
{
do
{
while ( 1 )
{
v16 = *v15;
v17 = (__int64 *)(*v15 - 24);
if ( v17 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v16 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v19 - 1;
}
if ( v19 <= 0 )
break;
}
if ( v14 == ++v15 )
goto LABEL_17;
}
*(_QWORD *)v101 = v14;
++v15;
operator delete(v17);
v14 = *(__int64 **)v101;
}
while ( *(__int64 **)v101 != v15 );
LABEL_17:
v9 = (__int64 *)p;
}
v116 = v13;
sub_830154(&v9[v12], &byte_F804F8, (__int64)&v115);
if ( (unsigned __int64)((_BYTE *)v116 - (_BYTE *)v115) > 0xF )
{
v20 = a1->m_sfxArtists;
sub_D18D28(&v107);
sub_D18D28(&v108);
v21 = (cocos2d::CCObject *)CCURLObject::create((__int64)&v107, (__int64)&v108);
cocos2d::CCArray::addObject(v20, v21);
v22 = (char *)(v108 - 24);
if ( v108 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)(v108 - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *((_DWORD *)v108 - 2);
*((_DWORD *)v108 - 2) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v22);
}
v23 = (void *)(v107 - 24);
if ( (__int64 *)(v107 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)(v107 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *(_DWORD *)(v107 - 8);
*(_DWORD *)(v107 - 8) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v23);
}
}
v9 = (__int64 *)p;
++v12;
v10 = v119;
v11 = (__int64 *)p;
}
while ( v12 < ((char *)v119 - (_BYTE *)p) >> 3 );
}
if ( v10 != v9 )
{
do
{
v35 = *v11;
v36 = (__int64 *)(*v11 - 24);
if ( v36 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v35 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(_DWORD *)(v35 - 8);
*(_DWORD *)(v35 - 8) = v34 - 1;
}
if ( v34 <= 0 )
{
*(_QWORD *)v102 = v11;
operator delete(v36);
v11 = *(__int64 **)v102;
}
}
++v11;
}
while ( v10 != v11 );
}
if ( p )
operator delete(p);
v24 = (__int64 *)v115;
v25 = (__int64 *)v116;
if ( v115 != v116 )
{
do
{
v26 = *v24;
v27 = (__int64 *)(*v24 - 24);
if ( v27 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = (unsigned int *)(v26 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(_DWORD *)(v26 - 8);
*(_DWORD *)(v26 - 8) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v27);
}
++v24;
}
while ( v25 != v24 );
v25 = (__int64 *)v115;
}
if ( v25 )
operator delete(v25);
v37 = (__int64 *)v112;
v38 = (__int64 *)v113;
if ( v112 != v113 )
{
do
{
v39 = *v37;
v40 = (__int64 *)(*v37 - 24);
if ( v40 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v39 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(v39 - 8);
*(_DWORD *)(v39 - 8) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v40);
}
++v37;
}
while ( v38 != v37 );
v38 = (__int64 *)v112;
}
if ( v38 )
operator delete(v38);
v43 = (__int64 *)v109;
v44 = (__int64 *)v110;
if ( v109 != v110 )
{
do
{
v45 = *v43;
v46 = (__int64 *)(*v43 - 24);
if ( v46 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)(v45 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *(_DWORD *)(v45 - 8);
*(_DWORD *)(v45 - 8) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v46);
}
++v43;
}
while ( v44 != v43 );
v44 = (__int64 *)v109;
}
if ( v44 )
operator delete(v44);
v49 = v105 - 24;
if ( v105 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v98 = (unsigned int *)(v105 - 8);
do
v99 = __ldaxr(v98);
while ( __stlxr(v99 - 1, v98) );
}
else
{
v99 = *((_DWORD *)v105 - 2);
*((_DWORD *)v105 - 2) = v99 - 1;
}
if ( v99 <= 0 )
operator delete(v49);
}
v32 = (void *)(v103 - 24);
if ( (__int64 *)(v103 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)(v103 - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *(_DWORD *)(v103 - 8);
*(_DWORD *)(v103 - 8) = v51 - 1;
}
if ( v51 <= 0 )
goto LABEL_82;
}
return;
}
v30 = v109;
if ( v109 != v110 )
{
do
{
v88 = *v7;
v89 = (__int64 *)(*v7 - 24);
if ( v89 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v90 = (unsigned int *)(v88 - 8);
do
v91 = __ldaxr(v90);
while ( __stlxr(v91 - 1, v90) );
}
else
{
v91 = *(_DWORD *)(v88 - 8);
*(_DWORD *)(v88 - 8) = v91 - 1;
}
if ( v91 <= 0 )
operator delete(v89);
}
++v7;
}
while ( v8 != v7 );
v30 = v109;
}
if ( v30 )
operator delete(v30);
v5 = v105;
}
}
v31 = v5 - 24;
if ( v5 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v92 = (unsigned int *)(v5 - 8);
do
v93 = __ldaxr(v92);
while ( __stlxr(v93 - 1, v92) );
}
else
{
v93 = *((_DWORD *)v5 - 2);
*((_DWORD *)v5 - 2) = v93 - 1;
}
if ( v93 <= 0 )
operator delete(v31);
}
v32 = (void *)(v103 - 24);
if ( (__int64 *)(v103 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v94 = (unsigned int *)(v103 - 8);
do
v95 = __ldaxr(v94);
while ( __stlxr(v95 - 1, v94) );
}
else
{
v95 = *(_DWORD *)(v103 - 8);
*(_DWORD *)(v103 - 8) = v95 - 1;
}
if ( v95 <= 0 )
LABEL_82:
operator delete(v32);
}
}