//
// MusicDownloadManager::encodeCustomSFX from 0x96e4c0 to 0x96e938 (1144 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::updateCustomSFXMappings @ 0x7a3870
// > MusicDownloadManager::exportCustomSFXToFile @ 0x96e978
// > MusicDownloadManager::encodeDataTo @ 0x96eea0
// > ??> @ 0x6d2b8
//
// 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:39 +0000
//
__int64 *__usercall MusicDownloadManager::encodeCustomSFX@(__int64 a1@, _QWORD *a2@, __int64 *a3@)
{
__int64 v5; // x0
__int64 v6; // x19
__int64 i; // x20
__int64 v8; // x19
char v9; // w0
__int64 v10; // x2
__int64 v11; // x0
__int64 v12; // x1
__int64 v13; // x2
size_t v14; // x1
size_t v15; // x0
char *v16; // x1
size_t v17; // x2
size_t v18; // x0
size_t v19; // x2
char *v20; // x1
char *v21; // x1
size_t v22; // x2
__int64 v23; // x2
__int64 v24; // x3
char v25; // w0
char v26; // w0
size_t v27; // x1
size_t v28; // x0
char *v29; // x1
size_t v30; // x2
void *v31; // x19
__int64 *v33; // [xsp+60h] [xbp+60h] BYREF
_QWORD **v34; // [xsp+68h] [xbp+68h] BYREF
__int64 v35; // [xsp+70h] [xbp+70h]
__int64 v36; // [xsp+78h] [xbp+78h] BYREF
size_t v37; // [xsp+80h] [xbp+80h]
void *v38; // [xsp+88h] [xbp+88h]
__int64 v39; // [xsp+90h] [xbp+90h] BYREF
size_t v40; // [xsp+98h] [xbp+98h]
void *v41; // [xsp+A0h] [xbp+A0h]
__int64 v42; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v43; // [xsp+B0h] [xbp+B0h]
void *v44; // [xsp+B8h] [xbp+B8h]
__int64 v45; // [xsp+C0h] [xbp+C0h] BYREF
size_t v46; // [xsp+C8h] [xbp+C8h]
void *v47; // [xsp+D0h] [xbp+D0h]
char s[64]; // [xsp+D8h] [xbp+D8h] BYREF
if ( !*(_QWORD *)(a1 + 824) )
{
*a3 = 0;
a3[1] = 0;
a3[2] = 0;
std::string::__init(a3, &byte_11B8890, 0);
return a3;
}
v34 = nullptr;
v35 = 0;
v33 = (__int64 *)&v34;
if ( (unsigned __int8)sub_96E158((MusicDownloadManager *)a1, a2, &v33) || v35 )
{
v5 = *(_QWORD *)(a1 + 824);
v36 = 0;
v37 = 0;
v38 = nullptr;
v39 = 0;
v40 = 0;
v41 = nullptr;
if ( !v5 || (v6 = *(_QWORD *)(v5 + 56)) == 0 )
{
LABEL_24:
sprintf(s, "1|%i|", *(_DWORD *)(a1 + 832));
v45 = 0;
v46 = 0;
v47 = nullptr;
v18 = strlen(s);
std::string::__init(&v45, s, v18);
if ( (v36 & 1) != 0 )
{
v20 = (char *)v38;
v19 = v37;
}
else
{
v19 = (unsigned __int8)v36 >> 1;
v20 = (char *)&v36 + 1;
}
std::string::append((__int64)&v45, v20, v19);
std::string::append((__int64)&v45, "|", 1u);
if ( (v39 & 1) != 0 )
{
v21 = (char *)v41;
v22 = v40;
}
else
{
v22 = (unsigned __int8)v39 >> 1;
v21 = (char *)&v39 + 1;
}
std::string::append((__int64)&v45, v21, v22);
v23 = v45;
v24 = v46;
v25 = v39;
a3[2] = (__int64)v47;
*a3 = v23;
a3[1] = v24;
if ( (v25 & 1) != 0 )
operator delete(v41);
if ( (v36 & 1) != 0 )
operator delete(v38);
goto LABEL_46;
}
for ( i = *(_QWORD *)(v6 + 288); ; i = *(_QWORD *)(i + 288) )
{
v8 = *(_QWORD *)(v6 + 264);
if ( *(_DWORD *)(v8 + 76) == 1 )
{
LABEL_21:
if ( !i )
goto LABEL_24;
goto LABEL_22;
}
if ( v35 )
{
if ( !std::__tree::__count_unique((__int64)&v33, (int *)(v8 + 76)) )
goto LABEL_21;
v26 = *(_BYTE *)(v8 + 80);
v10 = v8 + 80;
v42 = 0;
v43 = 0;
v44 = nullptr;
if ( (v26 & 1) == 0 )
{
LABEL_9:
v11 = *(_QWORD *)(v8 + 80);
v12 = *(_QWORD *)(v8 + 88);
v44 = *(void **)(v10 + 16);
v42 = v11;
v43 = v12;
goto LABEL_10;
}
}
else
{
v9 = *(_BYTE *)(v8 + 80);
v10 = v8 + 80;
v42 = 0;
v43 = 0;
v44 = nullptr;
if ( (v9 & 1) == 0 )
goto LABEL_9;
}
std::string::__init(&v42, *(void **)(v10 + 16), *(_QWORD *)(v10 + 8));
LABEL_10:
LevelTools::base64EncodeString((__int64)&v42, &v45);
if ( (v42 & 1) != 0 )
operator delete(v44);
v13 = *(unsigned int *)(v8 + 76);
if ( *(_BYTE *)(v8 + 72) )
{
sprintf(s, "%i,%i,", v13, *(_DWORD *)(v8 + 60));
v14 = (unsigned __int8)v36 >> 1;
if ( (v36 & 1) != 0 )
v14 = v37;
if ( v14 )
std::string::append((__int64)&v36, ";", 1u);
v15 = strlen(s);
std::string::append((__int64)&v36, s, v15);
if ( (v45 & 1) != 0 )
{
v16 = (char *)v47;
v17 = v46;
}
else
{
v17 = (unsigned __int8)v45 >> 1;
v16 = (char *)&v45 + 1;
}
std::string::append((__int64)&v36, v16, v17);
}
else
{
sprintf(s, aIII_1, v13, *(unsigned int *)(v8 + 60), *(unsigned int *)(v8 + 56));
v27 = (unsigned __int8)v39 >> 1;
if ( (v39 & 1) != 0 )
v27 = v40;
if ( v27 )
std::string::append((__int64)&v39, ";", 1u);
v28 = strlen(s);
std::string::append((__int64)&v39, s, v28);
if ( (v45 & 1) != 0 )
{
v29 = (char *)v47;
v30 = v46;
}
else
{
v30 = (unsigned __int8)v45 >> 1;
v29 = (char *)&v45 + 1;
}
std::string::append((__int64)&v39, v29, v30);
}
if ( (v45 & 1) == 0 )
goto LABEL_21;
operator delete(v47);
if ( !i )
goto LABEL_24;
LABEL_22:
v6 = i;
}
}
*a3 = 0;
a3[1] = 0;
a3[2] = 0;
std::string::__init(a3, &byte_11B8890, 0);
LABEL_46:
v31 = v34;
if ( v34 )
{
std::__tree::destroy((__int64)&v33, *v34);
std::__tree::destroy((__int64)&v33, *(_QWORD **)&byte_8[(_QWORD)v31]);
operator delete(v31);
}
return a3;
}