//
// MusicDownloadManager::rebuildCustomSFXMappings from 0x97a718 to 0x97aa50 (824 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateCustomSFXMappings @ 0x7a371c
// > EditorSFXManager::serializeAll @ 0xcc2c04
// > ??> @ 0x88288
//
// 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:47 +0000
//
__int64 __fastcall MusicDownloadManager::rebuildCustomSFXMappings(
MusicDownloadManager *this,
int **a2,
__int64 a3,
__int64 a4,
int a5,
int a6,
int a7,
int a8,
char a9)
{
int *v10; // x20
int *v12; // x22
__int64 *v13; // x1
__int64 v15; // x22
__int64 v16; // x19
int *v17; // x1
int v18; // w20
int v19; // w1
int *v20; // x1
__int64 *v21; // x0
int v22; // w2
int v23; // w2
__int64 CustomSFXObject; // x0
SFXInfoObject *v25; // x28
__int64 v26; // x0
__int64 v27; // x4
__int64 v28; // x20
int v29; // w1
int v30; // w0
__int64 *v31; // x28
__int64 v32; // x1
__int64 *v33; // x0
SFXInfoObject *v35; // x1
__int64 *v36; // x28
__int64 v37; // x0
__int64 v38; // x1
__int64 v39; // [xsp+68h] [xbp+68h]
int v41; // [xsp+A0h] [xbp+A0h] BYREF
int v42; // [xsp+A4h] [xbp+A4h]
int *v43; // [xsp+A8h] [xbp+A8h] BYREF
int *v44; // [xsp+B0h] [xbp+B0h] BYREF
__int64 *v45; // [xsp+B8h] [xbp+B8h] BYREF
__int64 *v46; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v47; // [xsp+C8h] [xbp+C8h]
__int64 v48[3]; // [xsp+D0h] [xbp+D0h] BYREF
v46 = nullptr;
v10 = *a2;
v12 = a2[1];
v13 = (__int64 *)&v46;
v47 = 0;
v15 = ((char *)v12 - (char *)v10) >> 3;
v45 = (__int64 *)&v46;
if ( v15 )
{
v16 = 0;
v17 = v10;
v18 = *v10;
v19 = v17[1];
if ( v18 > 0 && v19 > 0 )
goto LABEL_8;
LABEL_4:
if ( ++v16 != v15 )
{
while ( (int)v47 <= 999 )
{
v20 = &(*a2)[2 * v16];
v18 = *v20;
v19 = v20[1];
if ( v18 <= 0 || v19 <= 0 )
goto LABEL_4;
LABEL_8:
v21 = v46;
v41 = v19;
v42 = v18;
while ( v21 )
{
while ( 1 )
{
v22 = *((_DWORD *)v21 + 8);
if ( v19 < v22 )
break;
if ( v19 <= v22 )
{
v23 = *((_DWORD *)v21 + 9);
if ( v18 < v23 )
break;
if ( v18 <= v23 )
goto LABEL_4;
}
v21 = (__int64 *)v21[1];
if ( !v21 )
goto LABEL_15;
}
v21 = (__int64 *)*v21;
}
LABEL_15:
CustomSFXObject = MusicDownloadManager::getCustomSFXObject(this, v19);
v25 = (SFXInfoObject *)CustomSFXObject;
if ( CustomSFXObject && !*(_BYTE *)(CustomSFXObject + 72) && v18 == *(_DWORD *)(CustomSFXObject + 56) )
{
if ( !a4 || (unsigned __int8)MusicDownloadManager::isCustomSFXInScope(this, CustomSFXObject, a4) )
{
v43 = &v41;
v39 = 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<>>(
&v45,
&v41,
(__int64)&unk_1168A28,
(_QWORD **)&v43);
v35 = v25;
v36 = (__int64 *)(v39 + 40);
MusicDownloadManager::getCustomSFXRawPath(this, v35, v48);
if ( (*(_BYTE *)(v39 + 40) & 1) != 0 )
{
**(_BYTE **)(v39 + 56) = 0;
*(_QWORD *)(v39 + 48) = 0;
}
else
{
*(_BYTE *)(v39 + 41) = 0;
*(_BYTE *)(v39 + 40) = 0;
}
std::string::reserve(v36, 0);
v37 = v48[0];
v38 = v48[1];
*(_QWORD *)(v39 + 56) = v48[2];
*v36 = v37;
*(_QWORD *)(v39 + 48) = v38;
}
goto LABEL_4;
}
v26 = *(_QWORD *)(a3 + 8);
v27 = a3 + 8;
if ( !v26 )
goto LABEL_4;
v28 = a3 + 8;
do
{
while ( 1 )
{
v29 = *(_DWORD *)(v26 + 32);
if ( v29 < v41 || v29 <= v41 && *(_DWORD *)(v26 + 36) < v42 )
break;
v28 = v26;
v26 = *(_QWORD *)v26;
if ( !v26 )
goto LABEL_24;
}
v26 = *(_QWORD *)(v26 + 8);
}
while ( v26 );
LABEL_24:
if ( v28 == v27 )
goto LABEL_4;
v30 = *(_DWORD *)(v28 + 32);
if ( v41 < v30 || v41 <= v30 && v42 < *(_DWORD *)(v28 + 36) )
goto LABEL_4;
if ( v27 == v28 )
goto LABEL_4;
v31 = (__int64 *)(v28 + 40);
v32 = *(_BYTE *)(v28 + 40) >> 1;
if ( (*(_BYTE *)(v28 + 40) & 1) != 0 )
v32 = *(_QWORD *)(v28 + 48);
if ( !v32 )
goto LABEL_4;
v44 = &v41;
v33 = (__int64 *)(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<>>(
&v45,
&v41,
(__int64)&unk_1168A28,
(_QWORD **)&v44)
+ 40);
if ( v33 == v31 )
goto LABEL_4;
if ( (*(_BYTE *)v31 & 1) != 0 )
std::string::assign(v33, *(const void **)(v28 + 56), *(_QWORD *)(v28 + 48));
else
std::string::assign(v33, (const void *)(v28 + 41), *(_BYTE *)v31 >> 1);
if ( ++v16 == v15 )
break;
}
}
v13 = v45;
}
std::__tree,std::string>,std::__map_value_compare,std::__value_type,std::string>,std::less>,true>,std::allocator,std::string>>>::__assign_multi,std::string>,std::__tree_node,std::string>,void *> *,long>>(
a3,
v13,
&v46);
std::__tree,std::string>,std::__map_value_compare,std::__value_type,std::string>,std::less>,true>,std::allocator,std::string>>>::~__tree((__int64)&v45);
return _stack_chk_guard;
}