//
// MusicDownloadManager::importCustomSFXSetup from 0x96fca0 to 0x970860 (3008 bytes)
//
// 5 xrefs:
// > MusicDownloadManager::importCustomSFXFromFile @ 0x970b88
// > MusicDownloadManager::decodeCustomSFX @ 0x970f28
// > SFXBrowser::setTextPopupClosed @ 0xb8f2bc
// > SFXBrowser::FLAlert_Clicked @ 0xb90514
// > ??> @ 0x62b90
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:57:40 +0000
//
__int64 __fastcall MusicDownloadManager::importCustomSFXSetup(
MusicDownloadManager *a1,
__int64 a2,
char *a3,
unsigned __int8 a4,
_DWORD *a5,
_DWORD *a6)
{
__int64 v7; // x0
__int64 v9; // x2
unsigned __int8 *v11; // x20
const char *v12; // x0
char *v13; // x19
char *v14; // x0
char *v15; // x0
char *v16; // x19
unsigned __int8 *v17; // x0
__int64 v18; // x24
__int64 v19; // x28
char *v20; // x19
const char *v21; // x0
const char *v22; // x0
char v23; // w0
__int64 v24; // x0
__int64 v25; // x1
int v26; // w2
char *v27; // x0
char *v28; // x0
void **v29; // x1
size_t v30; // x3
char *v31; // x19
char *v32; // x0
unsigned __int8 *v33; // x0
__int64 v34; // x24
__int64 v35; // x28
char *v36; // x19
const char *v37; // x0
const char *v38; // x0
const char *v39; // x0
char v40; // w0
__int64 v41; // x0
__int64 v42; // x1
void **v43; // x1
size_t v44; // x3
char *v45; // x19
char *v46; // x0
char *v47; // x0
void **v48; // x19
char v49; // w0
__int64 v50; // x0
__int64 v51; // x1
char *v52; // x19
char *v53; // x0
void **v54; // x19
void **v55; // x0
char *v56; // x19
__int64 CustomSFXRoot; // x0
__int64 v58; // x0
unsigned int *v59; // x1
__int64 *v60; // x19
__int64 *v61; // x22
__int64 v62; // x1
int v63; // w1
char *i; // x0
_DWORD *v65; // x1
__int64 v66; // x19
__int64 v67; // x22
char *v68; // x20
char *v69; // x0
void **v70; // x25
unsigned __int64 v71; // [xsp+80h] [xbp+80h]
unsigned __int64 v72; // [xsp+80h] [xbp+80h]
int v73; // [xsp+88h] [xbp+88h]
int v74; // [xsp+8Ch] [xbp+8Ch]
void *v77; // [xsp+A0h] [xbp+A0h] BYREF
char *v78; // [xsp+A8h] [xbp+A8h]
__int64 v79; // [xsp+B0h] [xbp+B0h]
void *v80; // [xsp+B8h] [xbp+B8h] BYREF
void **v81; // [xsp+C0h] [xbp+C0h]
void **v82; // [xsp+C8h] [xbp+C8h]
void *v83; // [xsp+D0h] [xbp+D0h] BYREF
char *v84; // [xsp+D8h] [xbp+D8h]
__int64 v85; // [xsp+E0h] [xbp+E0h]
__int64 v86; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v87; // [xsp+F0h] [xbp+F0h]
void *v88; // [xsp+F8h] [xbp+F8h]
__int64 v89; // [xsp+100h] [xbp+100h] BYREF
__int64 v90; // [xsp+108h] [xbp+108h]
void *v91; // [xsp+110h] [xbp+110h]
void *v92; // [xsp+118h] [xbp+118h] BYREF
char *v93; // [xsp+120h] [xbp+120h]
char *v94; // [xsp+128h] [xbp+128h]
__int64 v95; // [xsp+130h] [xbp+130h] BYREF
__int64 v96; // [xsp+138h] [xbp+138h]
void *v97; // [xsp+140h] [xbp+140h] BYREF
size_t v98; // [xsp+148h] [xbp+148h]
void *v99; // [xsp+150h] [xbp+150h]
__int64 v100; // [xsp+158h] [xbp+158h]
v7 = _stack_chk_guard;
*a5 = 0;
*a6 = 0;
v100 = v7;
v74 = a4;
v9 = *(_BYTE *)a2 >> 1;
if ( (*(_BYTE *)a2 & 1) != 0 )
v9 = *(_QWORD *)(a2 + 8);
if ( !v9 )
return _stack_chk_guard;
v77 = nullptr;
v78 = nullptr;
v79 = 0;
sub_961B60((unsigned __int8 *)a2, "|", (__int64 *)&v77);
v11 = (unsigned __int8 *)v77;
if ( 0xAAAAAAAAAAAAAAABLL * ((v78 - (_BYTE *)v77) >> 3) <= 2 )
{
v13 = (char *)v77;
if ( !v77 )
return _stack_chk_guard;
goto LABEL_9;
}
v12 = (char *)&dword_0 + (_QWORD)v77 + 1;
if ( (*(_BYTE *)v77 & 1) != 0 )
v12 = *(const char **)((char *)&word_10 + (_QWORD)v77);
v13 = (char *)v77;
if ( atoi(v12) > 1 )
{
LABEL_9:
v14 = v78;
if ( v78 != v13 )
{
do
{
v78 = v14 - 24;
std::string::~string((__int64)(v14 - 24));
v14 = v78;
}
while ( v13 != v78 );
v13 = (char *)v77;
}
v15 = v13;
goto LABEL_13;
}
v80 = nullptr;
v81 = nullptr;
v82 = nullptr;
v83 = nullptr;
v84 = nullptr;
v85 = 0;
sub_961B60(v11 + 48, ";", (__int64 *)&v83);
v16 = (char *)v83;
v71 = 0xAAAAAAAAAAAAAAABLL * ((v84 - (_BYTE *)v83) >> 3);
if ( v71 )
{
v17 = (unsigned __int8 *)v83;
v18 = 0;
v19 = 0;
v73 = -2;
while ( 1 )
{
v92 = nullptr;
v93 = nullptr;
v94 = nullptr;
sub_961B60(&v17[v18], &byte_1169BE0, (__int64 *)&v92);
v20 = (char *)v92;
if ( 0xAAAAAAAAAAAAAAABLL * ((v93 - (_BYTE *)v92) >> 3) <= 2 )
goto LABEL_31;
v99 = nullptr;
v95 = 0;
v96 = 0;
v97 = nullptr;
v98 = 0;
v21 = (char *)v92 + 1;
if ( (*(_BYTE *)v92 & 1) != 0 )
v21 = *((const char **)v92 + 2);
LODWORD(v95) = atoi(v21);
v22 = v20 + 25;
if ( (v20[24] & 1) != 0 )
v22 = *((const char **)v20 + 5);
HIDWORD(v95) = atoi(v22);
v86 = 0;
v23 = v20[48];
v87 = 0;
v88 = nullptr;
if ( (v23 & 1) != 0 )
{
std::string::__init(&v86, *((void **)v20 + 8), *((_QWORD *)v20 + 7));
}
else
{
v24 = *((_QWORD *)v20 + 6);
v25 = *((_QWORD *)v20 + 7);
v88 = *((void **)v20 + 8);
v86 = v24;
v87 = v25;
}
LevelTools::base64DecodeString((__int64)&v86, &v97);
if ( (v86 & 1) != 0 )
operator delete(v88);
v26 = (unsigned __int8)v97 & 1;
if ( v26 )
{
if ( !v98 )
{
operator delete(v99);
LABEL_30:
v20 = (char *)v92;
LABEL_31:
if ( !v20 )
goto LABEL_37;
v27 = v93;
if ( v93 != v20 )
{
do
{
v93 = v27 - 24;
std::string::~string((__int64)(v27 - 24));
v27 = v93;
}
while ( v93 != v20 );
v20 = (char *)v92;
}
v28 = v20;
LABEL_36:
operator delete(v28);
goto LABEL_37;
}
}
else if ( !((int)(unsigned __int8)v97 >> 1) )
{
goto LABEL_30;
}
if ( (unsigned int)(v95 - 2) > 0xFFFFFD )
LODWORD(v95) = v73--;
v29 = v81;
if ( v81 == v82 )
{
std::vector::__push_back_slow_path(&v80, (__int64)&v95);
v26 = (unsigned __int8)v97 & 1;
}
else
{
if ( v81 )
{
*v81 = (void *)v95;
*((_DWORD *)v29 + 2) = v96;
v29[2] = nullptr;
v29[3] = nullptr;
v29[4] = nullptr;
if ( ((unsigned __int8)v97 & 1) != 0 )
{
std::string::__init((__int64 *)v29 + 2, v99, v98);
}
else
{
v30 = v98;
v29[2] = v97;
v29[3] = (void *)v30;
v29[4] = v99;
}
v29 = v81;
v26 = (unsigned __int8)v97 & 1;
}
v81 = v29 + 5;
}
if ( v26 )
operator delete(v99);
v31 = (char *)v92;
if ( v92 )
{
v28 = v93;
if ( v92 != v93 )
{
do
{
v93 = v28 - 24;
std::string::~string((__int64)(v28 - 24));
v28 = v93;
}
while ( v31 != v93 );
v28 = (char *)v92;
}
goto LABEL_36;
}
LABEL_37:
++v19;
v18 += 24;
if ( v19 == v71 )
{
v16 = (char *)v83;
v32 = v84;
goto LABEL_58;
}
v17 = (unsigned __int8 *)v83;
}
}
v32 = v84;
v73 = -2;
LABEL_58:
while ( v16 != v32 )
{
v84 = v32 - 24;
std::string::~string((__int64)(v32 - 24));
v32 = v84;
}
if ( 0xAAAAAAAAAAAAAAABLL * ((v78 - (_BYTE *)v77) >> 3) > 3 )
sub_961B60((unsigned __int8 *)v77 + 72, ";", (__int64 *)&v83);
v72 = 0xAAAAAAAAAAAAAAABLL * ((v84 - (_BYTE *)v83) >> 3);
if ( v72 )
{
v33 = (unsigned __int8 *)v83;
v34 = 0;
v35 = 0;
while ( 1 )
{
v92 = nullptr;
v93 = nullptr;
v94 = nullptr;
sub_961B60(&v33[v34], &byte_1169BE0, (__int64 *)&v92);
v36 = (char *)v92;
if ( 0xAAAAAAAAAAAAAAABLL * ((v93 - (_BYTE *)v92) >> 3) > 3 )
{
v37 = (char *)v92 + 1;
if ( (*(_BYTE *)v92 & 1) != 0 )
v37 = *((const char **)v92 + 2);
LODWORD(v95) = atoi(v37);
v38 = v36 + 25;
if ( (v36[24] & 1) != 0 )
v38 = *((const char **)v36 + 5);
HIDWORD(v95) = atoi(v38);
v39 = v36 + 49;
if ( (v36[48] & 1) != 0 )
v39 = *((const char **)v36 + 8);
LODWORD(v96) = atoi(v39);
v89 = 0;
v40 = v36[72];
v90 = 0;
v91 = nullptr;
if ( (v40 & 1) != 0 )
{
std::string::__init(&v89, *((void **)v36 + 11), *((_QWORD *)v36 + 10));
}
else
{
v41 = *((_QWORD *)v36 + 9);
v42 = *((_QWORD *)v36 + 10);
v91 = *((void **)v36 + 11);
v89 = v41;
v90 = v42;
}
LevelTools::base64DecodeString((__int64)&v89, &v97);
if ( (v89 & 1) != 0 )
operator delete(v91);
if ( (int)v96 > 0 )
{
if ( (unsigned int)(v95 - 2) > 0xFFFFFD )
LODWORD(v95) = v73--;
v43 = v81;
if ( v81 == v82 )
{
std::vector::__push_back_slow_path(&v80, (__int64)&v95);
}
else
{
if ( v81 )
{
*v81 = (void *)v95;
*((_DWORD *)v43 + 2) = v96;
v43[2] = nullptr;
v43[3] = nullptr;
v43[4] = nullptr;
if ( ((unsigned __int8)v97 & 1) != 0 )
{
std::string::__init((__int64 *)v43 + 2, v99, v98);
}
else
{
v44 = v98;
v43[2] = v97;
v43[3] = (void *)v44;
v43[4] = v99;
}
v43 = v81;
}
v81 = v43 + 5;
}
if ( ((unsigned __int8)v97 & 1) != 0 )
operator delete(v99);
v45 = (char *)v92;
if ( v92 )
{
v46 = v93;
if ( v92 != v93 )
{
do
{
v93 = v46 - 24;
std::string::~string((__int64)(v46 - 24));
v46 = v93;
}
while ( v45 != v93 );
v46 = (char *)v92;
}
LABEL_89:
operator delete(v46);
goto LABEL_90;
}
goto LABEL_90;
}
if ( ((unsigned __int8)v97 & 1) != 0 )
operator delete(v99);
v36 = (char *)v92;
}
if ( v36 )
{
v47 = v93;
if ( v93 != v36 )
{
do
{
v93 = v47 - 24;
std::string::~string((__int64)(v47 - 24));
v47 = v93;
}
while ( v93 != v36 );
v36 = (char *)v92;
}
v46 = v36;
goto LABEL_89;
}
LABEL_90:
++v35;
v34 += 24;
if ( v35 == v72 )
break;
v33 = (unsigned __int8 *)v83;
}
}
v48 = (void **)v80;
if ( v80 == v81 )
{
v68 = (char *)v83;
if ( v83 )
{
v69 = v84;
if ( v83 != v84 )
{
do
{
v84 = v69 - 24;
std::string::~string((__int64)(v69 - 24));
v69 = v84;
}
while ( v68 != v84 );
v68 = (char *)v83;
}
operator delete(v68);
v48 = (void **)v80;
}
if ( v48 )
{
while ( 1 )
{
v70 = v81;
if ( v81 == v48 )
break;
v81 -= 5;
if ( (*(_BYTE *)(v70 - 3) & 1) != 0 )
operator delete(*(v70 - 1));
}
operator delete(v80);
}
v13 = (char *)v77;
if ( !v77 )
return _stack_chk_guard;
goto LABEL_9;
}
if ( v74 )
{
CustomSFXRoot = MusicDownloadManager::getCustomSFXRoot(a1);
v92 = nullptr;
v93 = nullptr;
v94 = nullptr;
v58 = *(_QWORD *)(CustomSFXRoot + 152);
if ( v58 )
{
v59 = *(unsigned int **)(v58 + 56);
if ( *v59 )
{
v60 = *((__int64 **)v59 + 2);
v61 = &v60[*v59 - 1];
if ( v60 <= v61 )
{
v62 = *v60;
if ( *v60 )
{
LABEL_137:
std::vector::__push_back_slow_path((__int64)&v92, (_DWORD *)(v62 + 76));
for ( i = v93; v61 >= ++v60; v93 = i )
{
v62 = *v60;
if ( !*v60 )
break;
if ( i == v94 )
goto LABEL_137;
v63 = *(_DWORD *)(v62 + 76);
if ( i )
{
*(_DWORD *)i = v63;
i = v93;
}
i += 4;
}
v65 = v92;
v66 = (i - (_BYTE *)v92) >> 2;
if ( v66 )
{
v67 = 0;
while ( 1 )
{
MusicDownloadManager::deleteCustomSFXObject(a1, v65[v67++]);
if ( v67 == v66 )
break;
v65 = v92;
}
}
}
}
}
}
if ( v92 )
{
if ( v92 != v93 )
v93 += 4 * ~((unsigned __int64)(v93 - 4 - (_BYTE *)v92) >> 2);
operator delete(v92);
}
v95 = 0;
v96 = 0;
v97 = nullptr;
std::string::__init(&v95, &byte_11B8890, 0);
}
else
{
v95 = 0;
v96 = 0;
v49 = *a3;
v97 = nullptr;
if ( (v49 & 1) != 0 )
{
std::string::__init(&v95, *((void **)a3 + 2), *((_QWORD *)a3 + 1));
}
else
{
v50 = *(_QWORD *)a3;
v51 = *((_QWORD *)a3 + 1);
v97 = *((void **)a3 + 2);
v95 = v50;
v96 = v51;
}
}
sub_96F3B0(a1, (__int64 *)&v80, (__int64)&v95, a5, a6);
if ( (v95 & 1) != 0 )
operator delete(v97);
v52 = (char *)v83;
if ( v83 )
{
v53 = v84;
if ( v83 != v84 )
{
do
{
v84 = v53 - 24;
std::string::~string((__int64)(v53 - 24));
v53 = v84;
}
while ( v52 != v84 );
v53 = (char *)v83;
}
operator delete(v53);
}
v54 = (void **)v80;
if ( v80 )
{
v55 = v81;
if ( v80 != v81 )
{
do
{
v81 = v55 - 5;
if ( (*(_BYTE *)(v55 - 3) & 1) != 0 )
operator delete(*(v55 - 1));
v55 = v81;
}
while ( v54 != v81 );
v55 = (void **)v80;
}
operator delete(v55);
}
v56 = (char *)v77;
if ( v77 )
{
v15 = v78;
if ( v77 != v78 )
{
do
{
v78 = v15 - 24;
std::string::~string((__int64)(v15 - 24));
v15 = v78;
}
while ( v56 != v78 );
operator delete(v77);
return _stack_chk_guard;
}
LABEL_13:
operator delete(v15);
}
return _stack_chk_guard;
}