//
// MusicDownloadManager::encodeCustomSFX from 0x1006562d0 to 0x1006566e1 (1041 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateCustomSFXMappings @ 0x1000bb92d
// > sub_100656110 @ 0x100656133
// > MusicDownloadManager::encodeDataTo @ 0x10065770e
//
// This function is hookable on this platform (idp: pc, 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:34:51 +0000
//
std::string *__fastcall MusicDownloadManager::encodeCustomSFX(std::string *this, __int64 a2, _QWORD *a3)
{
char v4; // al
__int64 v5; // rax
__int64 v6; // r15
__int64 v7; // r12
int v8; // eax
__int64 *i; // rcx
int v10; // edx
int v11; // edx
int v12; // ecx
std::string *v13; // r13
const std::string::value_type *data; // rsi
std::string::size_type size; // rdx
size_t v16; // rax
std::string::size_type v17; // r14
_BYTE *v18; // r15
unsigned int v19; // edx
const std::string::value_type *v20; // rsi
std::string::size_type v21; // rdx
size_t v22; // r12
const std::string::value_type *v23; // rsi
std::string::size_type v24; // rdx
std::string v26; // [rsp+0h] [rbp-100h] BYREF
std::string v27; // [rsp+20h] [rbp-E0h] BYREF
__int128 *v28; // [rsp+38h] [rbp-C8h] BYREF
__int128 v29; // [rsp+40h] [rbp-C0h] BYREF
std::string v30; // [rsp+50h] [rbp-B0h] BYREF
std::string v31; // [rsp+70h] [rbp-90h] BYREF
std::string::value_type __s[64]; // [rsp+90h] [rbp-70h] BYREF
if ( *(_QWORD *)(a2 + 824) )
{
v29 = 0;
v28 = &v29;
v4 = sub_100651730(a2, a3, (__int64 **)&v28);
if ( !((*((_QWORD *)&v29 + 1) != 0) | (unsigned __int8)v4) )
{
*(_WORD *)&this->__r_.__value_.__l.0 = 0;
LABEL_56:
sub_10001ADF0((__int64)&v28, (_QWORD *)v29);
return this;
}
memset(&v30, 0, sizeof(v30));
memset(&v31, 0, sizeof(v31));
v5 = *(_QWORD *)(a2 + 824);
if ( v5 )
{
v6 = *(_QWORD *)(v5 + 56);
while ( 1 )
{
while ( 1 )
{
do
{
if ( !v6 )
goto LABEL_39;
v7 = *(_QWORD *)(v6 + 264);
v6 = *(_QWORD *)(v6 + 288);
v8 = *(_DWORD *)(v7 + 76);
}
while ( v8 == 1 );
if ( !*((_QWORD *)&v29 + 1) )
break;
for ( i = (__int64 *)v29; i; i = (__int64 *)*i )
{
v10 = *((_DWORD *)i + 7);
if ( v8 >= v10 )
{
if ( v8 <= v10 )
goto LABEL_14;
++i;
}
}
}
LABEL_14:
if ( (*(_BYTE *)(v7 + 80) & 1) != 0 )
sub_10001AD30(&v26, *(const void **)(v7 + 96), *(_QWORD *)(v7 + 88));
else
v26 = *(std::string *)(v7 + 80);
LevelTools::base64EncodeString(&v27, &v26);
if ( (*(_BYTE *)&v26.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v26.__r_.__value_.__l.__data_);
v11 = *(_DWORD *)(v7 + 76);
v12 = *(_DWORD *)(v7 + 60);
if ( *(_BYTE *)(v7 + 72) == 1 )
{
sprintf(__s, "%i,%i,", v11, v12);
if ( (*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) != 0 )
{
if ( !v30.__r_.__value_.__l.__size_ )
goto LABEL_28;
LABEL_27:
std::string::append(&v30, ";");
}
else if ( *(_BYTE *)&v30.__r_.__value_.__l.0 >> 1 )
{
goto LABEL_27;
}
LABEL_28:
v13 = &v30;
std::string::append(&v30, __s);
goto LABEL_32;
}
sprintf(__s, "%i,%i,%i,", v11, v12, *(_DWORD *)(v7 + 56));
if ( (*(_BYTE *)&v31.__r_.__value_.__s.0 & 1) != 0 )
break;
if ( *(_BYTE *)&v31.__r_.__value_.__l.0 >> 1 )
goto LABEL_30;
LABEL_31:
v13 = &v31;
std::string::append(&v31, __s);
LABEL_32:
if ( (*(_BYTE *)&v27.__r_.__value_.__s.0 & 1) != 0 )
{
data = v27.__r_.__value_.__l.__data_;
size = v27.__r_.__value_.__l.__size_;
}
else
{
size = *(_BYTE *)&v27.__r_.__value_.__l.0 >> 1;
data = v27.__r_.__value_.__s.__data_;
}
std::string::append(v13, data, size);
if ( (*(_BYTE *)&v27.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v27.__r_.__value_.__l.__data_);
}
if ( !v31.__r_.__value_.__l.__size_ )
goto LABEL_31;
LABEL_30:
std::string::append(&v31, ";");
goto LABEL_31;
}
LABEL_39:
sprintf(__s, "1|%i|", *(_DWORD *)(a2 + 832));
v16 = strlen(__s);
if ( v16 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v17 = v16;
if ( v16 >= 0x17 )
{
v22 = 26;
if ( (v16 | 7) != 0x17 )
v22 = (v16 | 7) + 1;
v18 = operator new(v22);
this->__r_.__value_.__r.__words[2] = (std::string::size_type)v18;
this->__r_.__value_.__r.__words[0] = v22 | 1;
this->__r_.__value_.__l.__size_ = v17;
}
else
{
this->__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v16);
v18 = this->__r_.__value_.__s.__data_;
if ( !v16 )
{
*v18 = 0;
v19 = (unsigned int)v30.__r_.__value_.__l.0;
if ( (*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_43:
v20 = v30.__r_.__value_.__l.__data_;
v21 = v30.__r_.__value_.__l.__size_;
LABEL_49:
std::string::append(this, v20, v21);
std::string::append(this, "|");
if ( (*(_BYTE *)&v31.__r_.__value_.__s.0 & 1) != 0 )
{
v23 = v31.__r_.__value_.__l.__data_;
v24 = v31.__r_.__value_.__l.__size_;
}
else
{
v24 = *(_BYTE *)&v31.__r_.__value_.__l.0 >> 1;
v23 = v31.__r_.__value_.__s.__data_;
}
std::string::append(this, v23, v24);
if ( (*(_BYTE *)&v31.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v31.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v30.__r_.__value_.__l.__data_);
goto LABEL_56;
}
LABEL_48:
v21 = v19 >> 1;
v20 = v30.__r_.__value_.__s.__data_;
goto LABEL_49;
}
}
memcpy(v18, __s, v17);
v18[v17] = 0;
v19 = (unsigned int)v30.__r_.__value_.__l.0;
if ( (*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_43;
goto LABEL_48;
}
*(_WORD *)&this->__r_.__value_.__l.0 = 0;
return this;
}