//
// MusicDownloadManager::decodeCustomSFXMappingEntries from 0x9720a0 to 0x972484 (996 bytes)
//
// 3 xrefs:
// > LevelSettingsObject::objectFromDict @ 0x7abf30
// > EditorSFXManager::deserializeAll @ 0xcc6508
// > ??> @ 0xfd9c0
//
// 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:42 +0000
//
__int64 __fastcall MusicDownloadManager::decodeCustomSFXMappingEntries(
__int64 a1,
__int64 a2,
unsigned __int8 a3,
int a4,
int a5,
int a6,
int a7,
int a8,
char a9)
{
__int64 v11; // x1
__int64 v13; // x20
_BYTE *v14; // x22
unsigned __int64 v15; // x23
unsigned __int8 *v16; // x0
__int64 v17; // x21
__int64 v18; // x20
char *v19; // x28
char *v20; // x22
const char *v21; // x0
int v22; // w27
const char *v23; // x0
int v24; // w0
__int64 v25; // x4
__int64 v26; // x0
char *v27; // x22
__int64 *v28; // x0
char *v29; // x1
size_t v30; // x2
char *v31; // x0
_BYTE *v32; // x0
void **v33; // x1
__int64 *v34; // x1
int v35; // w4
int v36; // w4
int v37; // [xsp+7Ch] [xbp+7Ch]
int v38[2]; // [xsp+88h] [xbp+88h] BYREF
int *v39; // [xsp+90h] [xbp+90h] BYREF
void *v40; // [xsp+98h] [xbp+98h] BYREF
_BYTE *v41; // [xsp+A0h] [xbp+A0h]
__int64 v42; // [xsp+A8h] [xbp+A8h]
void *v43; // [xsp+B0h] [xbp+B0h] BYREF
char *v44; // [xsp+B8h] [xbp+B8h]
__int64 v45; // [xsp+C0h] [xbp+C0h]
v37 = a3;
if ( !a3 )
{
v13 = *(_QWORD *)(a2 + 8);
if ( v13 )
{
std::__tree,std::string>,std::__map_value_compare,std::__value_type,std::string>,std::less>,true>,std::allocator,std::string>>>::destroy(
a2,
*(void **)v13);
std::__tree,std::string>,std::__map_value_compare,std::__value_type,std::string>,std::less>,true>,std::allocator,std::string>>>::destroy(
a2,
*(void **)(v13 + 8));
if ( (*(_BYTE *)(v13 + 40) & 1) != 0 )
operator delete(*(void **)(v13 + 56));
operator delete((void *)v13);
}
*(_QWORD *)(a2 + 16) = 0;
*(_QWORD *)a2 = a2 + 8;
*(_QWORD *)(a2 + 8) = 0;
}
v11 = *(_BYTE *)a1 >> 1;
if ( (*(_BYTE *)a1 & 1) != 0 )
v11 = *(_QWORD *)(a1 + 8);
if ( !v11 )
return _stack_chk_guard;
v40 = nullptr;
v41 = nullptr;
v42 = 0;
sub_961B60((unsigned __int8 *)a1, "|", (__int64 *)&v40);
v14 = v40;
v15 = 0xAAAAAAAAAAAAAAABLL * ((v41 - (_BYTE *)v40) >> 3);
if ( !v15 || (int)*(_QWORD *)(a2 + 16) > 999 )
goto LABEL_38;
v16 = (unsigned __int8 *)v40;
v17 = 0;
v18 = 0;
while ( 1 )
{
v43 = nullptr;
v44 = nullptr;
v45 = 0;
sub_961B60(&v16[v17], ":", (__int64 *)&v43);
v19 = (char *)v43;
v20 = v44;
if ( 0xAAAAAAAAAAAAAAABLL * ((v44 - (_BYTE *)v43) >> 3) <= 2 )
{
if ( !v43 )
goto LABEL_34;
}
else
{
v21 = (char *)v43 + 1;
if ( (*(_BYTE *)v43 & 1) != 0 )
v21 = *((const char **)v43 + 2);
v22 = atoi(v21);
v23 = v19 + 25;
if ( (v19[24] & 1) != 0 )
v23 = *((const char **)v19 + 5);
v24 = atoi(v23);
if ( v24 > 0 && v22 > 0 )
{
v25 = (unsigned __int8)v19[48] >> 1;
if ( (v19[48] & 1) != 0 )
v25 = *((_QWORD *)v19 + 7);
if ( v25 )
{
v38[0] = v22;
v38[1] = v24;
if ( !v37 )
{
LABEL_25:
v39 = v38;
v26 = std::__tree,std::string>,std::__map_value_compare,std::__value_type,std::string>,std::less>,true>,std::allocator,std::string>>>::__emplace_unique_key_args,std::piecewise_construct_t const&,std::tuple const&>,std::tuple<>>(
(__int64 **)a2,
v38,
(__int64)&unk_1168A28,
(_QWORD **)&v39);
v27 = (char *)v43;
v28 = (__int64 *)(v26 + 40);
if ( v28 != (__int64 *)((char *)v43 + 48) )
{
if ( (*((_BYTE *)v43 + 48) & 1) != 0 )
{
v29 = *((char **)v43 + 8);
v30 = *((_QWORD *)v43 + 7);
}
else
{
v29 = (char *)v43 + 49;
v30 = *((_BYTE *)v43 + 48) >> 1;
}
std::string::assign(v28, v29, v30);
v27 = (char *)v43;
}
if ( v27 )
{
v31 = v44;
if ( v44 != v27 )
{
do
{
v44 = v31 - 24;
std::string::~string((__int64)(v31 - 24));
v31 = v44;
}
while ( v44 != v27 );
v27 = (char *)v43;
}
operator delete(v27);
}
goto LABEL_34;
}
v34 = *(__int64 **)(a2 + 8);
while ( 1 )
{
if ( !v34 )
goto LABEL_25;
v35 = *((_DWORD *)v34 + 8);
if ( v22 < v35 )
goto LABEL_57;
if ( v22 > v35 )
goto LABEL_56;
v36 = *((_DWORD *)v34 + 9);
if ( v24 < v36 )
{
LABEL_57:
v34 = (__int64 *)*v34;
}
else
{
if ( v24 <= v36 )
break;
LABEL_56:
v34 = (__int64 *)v34[1];
}
}
}
}
}
if ( v19 == v20 )
{
operator delete(v19);
}
else
{
v33 = (void **)v20;
do
{
v44 = (char *)(v33 - 3);
if ( (*(_BYTE *)(v33 - 3) & 1) != 0 )
operator delete(*(v33 - 1));
v33 = (void **)v44;
}
while ( v19 != v44 );
operator delete(v43);
}
LABEL_34:
if ( ++v18 == v15 )
break;
v17 += 24;
if ( (int)*(_QWORD *)(a2 + 16) > 999 )
break;
v16 = (unsigned __int8 *)v40;
}
v14 = v40;
LABEL_38:
if ( v14 )
{
v32 = v41;
if ( v41 != v14 )
{
do
{
v41 = v32 - 24;
std::string::~string((__int64)(v32 - 24));
v32 = v41;
}
while ( v41 != v14 );
v14 = v40;
}
operator delete(v14);
}
return _stack_chk_guard;
}