//
// LevelEditorLayer::getLevelString from 0x1003fc654 to 0x1003fc8c4 (624 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::saveLevel @ 0x100404be4
// > LevelEditorLayer::doAutoSave @ 0x10040b45c
// > LevelEditorLayer::doAutoBackup @ 0x10040b808
//
// 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:04:36 +0000
//
void **__usercall LevelEditorLayer::getLevelString@(__int64 a1@, std::string *a2@)
{
int v4; // w0
const std::string::value_type *p_p; // x1
std::string::size_type v6; // x2
__int64 v7; // x8
unsigned int *v8; // x9
__int64 v9; // x8
__int64 *v10; // x26
unsigned __int64 v11; // x27
__int64 v12; // x22
__int64 v13; // x23
bool v14; // w24
char v15; // w19
const void **v16; // x0
__int64 v17; // x25
char v18; // w8
const std::string::value_type *v19; // x1
std::string::size_type v20; // x2
std::string *v22; // [xsp+0h] [xbp-B0h]
void *__p; // [xsp+8h] [xbp-A8h] BYREF
std::string::size_type v24; // [xsp+10h] [xbp-A0h]
unsigned __int8 v25; // [xsp+1Fh] [xbp-91h]
_OWORD v26[2]; // [xsp+20h] [xbp-90h] BYREF
int v27; // [xsp+40h] [xbp-70h]
char v28; // [xsp+57h] [xbp-59h] BYREF
void **v29; // [xsp+58h] [xbp-58h] BYREF
GJBaseGameLayer::generateSpawnRemap((_QWORD *)a1);
GJBaseGameLayer::calculateColorGroups(a1);
memset(v26, 0, sizeof(v26));
v27 = 1065353216;
*(_BYTE *)(a1 + 14018) = 0;
v22 = a2;
sub_100009900(a2, "");
v4 = sub_1002E757C(*(_QWORD *)(a1 + 3280));
std::string::reserve(a2, (unsigned int)(200 * v4));
sub_1003FC928(&__p, *(_QWORD *)(a1 + 3272));
if ( (v25 & 0x80u) == 0 )
p_p = (const std::string::value_type *)&__p;
else
p_p = (const std::string::value_type *)__p;
if ( (v25 & 0x80u) == 0 )
v6 = v25;
else
v6 = v24;
std::string::append(a2, p_p, v6);
if ( (char)v25 < 0 )
operator delete(__p);
std::string::append(a2, ";");
qsort(
*(void **)(*(_QWORD *)(*(_QWORD *)(a1 + 3280) + 56LL) + 16LL),
**(unsigned int **)(*(_QWORD *)(a1 + 3280) + 56LL),
8u,
(int (__cdecl *)(const void *, const void *))sub_1003F5FA4);
v7 = *(_QWORD *)(a1 + 3280);
if ( !v7 )
return sub_10008DD98((void **)v26);
v8 = *(unsigned int **)(v7 + 56);
v9 = *v8;
if ( !(_DWORD)v9 )
return sub_10008DD98((void **)v26);
v10 = *((__int64 **)v8 + 2);
v11 = (unsigned __int64)&v10[v9 - 1];
v12 = 1;
do
{
v13 = *v10;
if ( !*v10 )
return sub_10008DD98((void **)v26);
if ( (*(_BYTE *)(v13 + 1303) & 1) != 0 )
goto LABEL_34;
sub_1002FAC50(*v10);
v14 = sub_1002FF120(v13);
v15 = 1;
do
{
sub_1002FAD40(v13, v15 & 1, 1, &__p);
v16 = sub_1001BD934(v26, (__int64 *)&__p);
if ( v16 )
{
v17 = v12;
LODWORD(v12) = *((_DWORD *)v16 + 10);
if ( (v15 & 1) != 0 )
goto LABEL_17;
}
else
{
v29 = &__p;
*(_DWORD *)(sub_10041167C(v26, &__p, &unk_10076E63B, &v29, &v28) + 40) = v12;
v17 = (unsigned int)(v12 + 1);
if ( (v15 & 1) != 0 )
{
LABEL_17:
*(_DWORD *)(v13 + 1320) = v12;
goto LABEL_20;
}
}
*(_DWORD *)(v13 + 1324) = v12;
LABEL_20:
if ( (char)v25 < 0 )
operator delete(__p);
v18 = v14 & v15;
v12 = v17;
v15 = 0;
}
while ( (v18 & 1) != 0 );
(*(void (__fastcall **)(void **__return_ptr, __int64, __int64))(*(_QWORD *)v13 + 1392LL))(&__p, v13, a1);
if ( (v25 & 0x80u) == 0 )
v19 = (const std::string::value_type *)&__p;
else
v19 = (const std::string::value_type *)__p;
if ( (v25 & 0x80u) == 0 )
v20 = v25;
else
v20 = v24;
std::string::append(v22, v19, v20);
std::string::append(v22, ";");
if ( (*(_BYTE *)(a1 + 14018) & 1) == 0 )
*(_BYTE *)(a1 + 14018) = *(_BYTE *)(v13 + 1259);
if ( (char)v25 < 0 )
operator delete(__p);
v12 = v17;
LABEL_34:
++v10;
}
while ( (unsigned __int64)v10 <= v11 );
return sub_10008DD98((void **)v26);
}