//
// MusicDownloadManager::encodeDataTo from 0x1006572b0 to 0x100657779 (1225 bytes)
//
// 1 xrefs:
// > GameManager::encodeDataTo @ 0x100375724
//
// 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:52 +0000
//
__int64 __fastcall MusicDownloadManager::encodeDataTo(__int64 a1, __int64 a2)
{
__int64 *v2; // r14
unsigned __int64 v3; // rax
size_t v4; // rbx
_QWORD *v5; // rcx
_DWORD *v6; // rax
void *v7; // r15
__int64 *v8; // r14
unsigned __int64 v9; // rax
size_t v10; // rbx
_QWORD *v11; // rcx
_DWORD *v12; // rax
void *v13; // r15
__int64 *v14; // r14
unsigned __int64 v15; // rax
size_t v16; // rbx
_QWORD *v17; // rcx
_DWORD *v18; // rax
void *v19; // r15
__int64 v20; // r14
__int64 v21; // r14
__int64 i; // r15
__int64 v23; // rax
int v24; // edx
int v25; // ecx
unsigned int v26; // eax
std::string v28; // [rsp+10h] [rbp-70h] BYREF
std::string __s; // [rsp+30h] [rbp-50h] BYREF
DS_Dictionary::setDictForKey(a2, "MDLM_001", *(_QWORD *)(a1 + 344));
DS_Dictionary::setDictForKey(a2, "MDLM_003", *(_QWORD *)(a1 + 352));
DS_Dictionary::setIntegerForKey_1(a2, (__int64)"MDLM_002", *(unsigned int *)(a1 + 360));
v2 = *(__int64 **)(a1 + 624);
memset(&v28, 0, sizeof(v28));
if ( v2 )
{
v3 = -1;
v4 = 0;
v5 = v2;
do
{
v5 = (_QWORD *)*v5;
++v3;
++v4;
}
while ( v5 );
if ( v3 > 0x3FFFFFFFFFFFFFFELL )
sub_100093980();
v6 = operator new(v4 * 4);
v7 = v6;
v28.__r_.__value_.__r.__words[0] = (std::string::size_type)v6;
v28.__r_.__value_.__r.__words[2] = (std::string::size_type)&v6[v4];
do
{
*v6 = *((_DWORD *)v2 + 4);
v2 = (__int64 *)*v2;
++v6;
}
while ( v2 );
v28.__r_.__value_.__l.__size_ = (std::string::size_type)v6;
}
else
{
v7 = nullptr;
}
sub_1006513F0(&__s, &v28);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_004", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
if ( v7 )
operator delete(v7);
v8 = *(__int64 **)(a1 + 704);
memset(&v28, 0, sizeof(v28));
if ( v8 )
{
v9 = -1;
v10 = 0;
v11 = v8;
do
{
v11 = (_QWORD *)*v11;
++v9;
++v10;
}
while ( v11 );
if ( v9 > 0x3FFFFFFFFFFFFFFELL )
sub_100093980();
v12 = operator new(v10 * 4);
v13 = v12;
v28.__r_.__value_.__r.__words[0] = (std::string::size_type)v12;
v28.__r_.__value_.__r.__words[2] = (std::string::size_type)&v12[v10];
do
{
*v12 = *((_DWORD *)v8 + 4);
v8 = (__int64 *)*v8;
++v12;
}
while ( v8 );
v28.__r_.__value_.__l.__size_ = (std::string::size_type)v12;
}
else
{
v13 = nullptr;
}
sub_1006513F0(&__s, &v28);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_005", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
if ( v13 )
operator delete(v13);
v14 = *(__int64 **)(a1 + 664);
memset(&v28, 0, sizeof(v28));
if ( v14 )
{
v15 = -1;
v16 = 0;
v17 = v14;
do
{
v17 = (_QWORD *)*v17;
++v15;
++v16;
}
while ( v17 );
if ( v15 > 0x3FFFFFFFFFFFFFFELL )
sub_100093980();
v18 = operator new(v16 * 4);
v19 = v18;
v28.__r_.__value_.__r.__words[0] = (std::string::size_type)v18;
v28.__r_.__value_.__r.__words[2] = (std::string::size_type)&v18[v16];
do
{
*v18 = *((_DWORD *)v14 + 4);
v14 = (__int64 *)*v14;
++v18;
}
while ( v14 );
v28.__r_.__value_.__l.__size_ = (std::string::size_type)v18;
}
else
{
v19 = nullptr;
}
sub_1006513F0(&__s, &v28);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_011", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
if ( v19 )
operator delete(v19);
memset(&v28, 0, sizeof(v28));
v20 = *(_QWORD *)(a1 + 736) - *(_QWORD *)(a1 + 728);
if ( v20 )
{
v21 = (v20 >> 3 == 0) + (v20 >> 3);
for ( i = 0; v21 != i; ++i )
{
v23 = *(_QWORD *)(a1 + 728);
v24 = *(_DWORD *)(v23 + 8 * i);
v25 = *(_DWORD *)(v23 + 8 * i + 4);
if ( v25 <= 0 )
{
sprintf((char *)&__s, "%i", v24);
v26 = (unsigned int)v28.__r_.__value_.__l.0;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_41:
if ( !v28.__r_.__value_.__l.__size_ )
goto LABEL_46;
LABEL_45:
std::string::append(&v28, ",");
goto LABEL_46;
}
}
else
{
sprintf((char *)&__s, "%i:%i", v24, v25);
v26 = (unsigned int)v28.__r_.__value_.__l.0;
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_41;
}
if ( v26 >> 1 )
goto LABEL_45;
LABEL_46:
std::string::append(&v28, (const std::string::value_type *)&__s);
}
}
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_006", (__int64)&v28);
if ( (*(_BYTE *)&v28.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v28.__r_.__value_.__l.__data_);
sub_1006513F0(&__s, (_QWORD *)(a1 + 752));
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_007", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
sub_100657830(&__s);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_008", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
sub_100657830(&__s);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_009", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
*(_OWORD *)&v28.__r_.__value_.__r.__words[1] = 0;
v28.__r_.__value_.__r.__words[0] = (std::string::size_type)&v28.__r_.__value_.__l.__size_;
MusicDownloadManager::encodeCustomSFX(&__s, a1, &v28);
DS_Dictionary::setStringForKey_1(a2, (__int64)"MDLM_010", (__int64)&__s);
if ( (*(_BYTE *)&__s.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__s.__r_.__value_.__l.__data_);
sub_10001ADF0((__int64)&v28, (_QWORD *)v28.__r_.__value_.__l.__size_);
return __stack_chk_guard;
}