//
// sub_1004C97AC from 0x1004c97ac to 0x1004c9b10 (868 bytes)
//
// 2 xrefs:
// > EditorSFXManager::encodeDataTo @ 0x1004ca474
// > sub_1004CAA78 @ 0x1004caa90
//
// 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 11:06:24 +0000
//
void __usercall sub_1004C97AC(__int64 a1@, std::string *a2@)
{
_QWORD *i; // x22
__int64 *v5; // x23
__int64 v6; // x0
unsigned int j; // w21
__int64 v8; // x0
__int64 v9; // x8
__int64 v10; // x21
__int64 v11; // x0
_QWORD *v12; // x3
int v13; // w8
__int64 *v14; // x24
__int64 v15; // x28
__int64 *v16; // x0
float v17; // s0
int v18; // w10
const std::string::value_type *v19; // x1
std::string::size_type v20; // x2
unsigned int k; // w23
__int64 v22; // x0
std::string::value_type *v23; // x1
std::string::size_type v24; // x2
const std::string::value_type *v25; // x1
std::string::size_type v26; // x2
_QWORD **v27; // [xsp+20h] [xbp-100h] BYREF
_QWORD *v28[2]; // [xsp+28h] [xbp-F8h] BYREF
void *__p; // [xsp+38h] [xbp-E8h] BYREF
void *v30; // [xsp+40h] [xbp-E0h]
__int64 v31; // [xsp+48h] [xbp-D8h]
std::string::value_type v32[8]; // [xsp+50h] [xbp-D0h] BYREF
std::string::size_type v33; // [xsp+58h] [xbp-C8h]
unsigned __int8 v34; // [xsp+67h] [xbp-B9h]
std::string::value_type __s[8]; // [xsp+70h] [xbp-B0h] BYREF
__int64 v36; // [xsp+78h] [xbp-A8h]
unsigned __int8 v37; // [xsp+87h] [xbp-99h]
char __str[16]; // [xsp+B0h] [xbp-70h] BYREF
__p = nullptr;
v30 = nullptr;
v31 = 0;
for ( i = *(_QWORD **)(a1 + 16); i; i = (_QWORD *)*i )
{
v5 = (__int64 *)i[3];
if ( v5 )
{
v6 = *v5;
if ( *v5 )
{
for ( j = 0; j < (unsigned int)sub_1002E757C(v6); ++j )
{
v8 = sub_1002E75A0(*v5, j);
if ( v8 )
{
v9 = *(unsigned int *)(v8 + 1864);
if ( (int)v9 >= 1 )
{
*(_QWORD *)__s = v9 | ((unsigned __int64)*(unsigned int *)(v8 + 1868) << 32);
sub_100011A50((__int64)&__p, __s);
}
}
v6 = *v5;
}
}
}
}
v28[0] = nullptr;
v28[1] = nullptr;
v27 = v28;
v10 = MusicDownloadManager::sharedState();
v11 = GameManager::sharedState();
if ( GameManager::getGameVariable(v11, "0233") )
v12 = &v27;
else
v12 = nullptr;
sub_1001D7714(v10, &__p, (__int64 **)(a1 + 120), (__int64)v12);
v13 = 1;
if ( *(_QWORD *)(a1 + 136) )
v13 = 2;
snprintf(__str, 0x10u, "%d;", v13);
sub_100009900(a2, __str);
v14 = *(__int64 **)(a1 + 16);
if ( v14 )
{
while ( 1 )
{
v15 = v14[3];
if ( v15 )
{
if ( *(_QWORD *)v15 && (unsigned int)sub_1002E757C(*(_QWORD *)v15) )
break;
}
LABEL_48:
v14 = (__int64 *)*v14;
if ( !v14 )
goto LABEL_49;
}
snprintf(__s, 0x40u, "%d,%d,%d,%d", 1, *((_DWORD *)v14 + 4), 2, *(_DWORD *)(v15 + 8));
std::string::append(a2, __s);
v16 = sub_100019268((_QWORD *)(a1 + 80), (int *)v14 + 4);
if ( v16 )
{
v17 = *((float *)v16 + 5);
if ( v17 > 0.0 )
{
snprintf(v32, 0x20u, ",%d,%g", 3, v17);
std::string::append(a2, v32);
}
}
if ( (*(char *)(v15 + 39) & 0x8000000000000000LL) != 0 )
{
if ( !*(_QWORD *)(v15 + 24) )
goto LABEL_34;
}
else if ( !*(_BYTE *)(v15 + 39) )
{
goto LABEL_34;
}
std::string::push_back(a2, 44);
v18 = *(char *)(v15 + 39);
if ( v18 >= 0 )
v19 = (const std::string::value_type *)(v15 + 16);
else
v19 = *(const std::string::value_type **)(v15 + 16);
if ( v18 >= 0 )
v20 = *(unsigned __int8 *)(v15 + 39);
else
v20 = *(_QWORD *)(v15 + 24);
std::string::append(a2, v19, v20);
LABEL_34:
std::string::push_back(a2, 59);
for ( k = 0; k < (unsigned int)sub_1002E757C(*(_QWORD *)v15); ++k )
{
if ( k )
std::string::push_back(a2, 58);
v22 = sub_1002E75A0(*(_QWORD *)v15, k);
sub_1004C8EF4(v22, (__int64)v32);
if ( (v34 & 0x80u) == 0 )
v23 = v32;
else
v23 = *(std::string::value_type **)v32;
if ( (v34 & 0x80u) == 0 )
v24 = v34;
else
v24 = v33;
std::string::append(a2, v23, v24);
if ( (char)v34 < 0 )
operator delete(*(void **)v32);
}
std::string::push_back(a2, 59);
goto LABEL_48;
}
LABEL_49:
if ( *(_QWORD *)(a1 + 136) )
{
std::string::append(a2, "M|");
MusicDownloadManager::encodeCustomSFXMappingEntries((std::string *)(a1 + 120), (__int64)__s);
v25 = (v37 & 0x80u) == 0 ? __s : *(const std::string::value_type **)__s;
v26 = (v37 & 0x80u) == 0 ? v37 : v36;
std::string::append(a2, v25, v26);
if ( (char)v37 < 0 )
operator delete(*(void **)__s);
}
sub_1000187C4((__int64)&v27, v28[0]);
if ( __p )
{
v30 = __p;
operator delete(__p);
}
}