//
// sub_100653860 from 0x100653860 to 0x100653bb7 (855 bytes)
//
// 2 xrefs:
// > LevelSettingsObject::objectFromDict @ 0x1000dc5ee
// > EditorSFXManager::deserializeAll @ 0x1008e1f4e
//
// 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:50 +0000
//
void __fastcall sub_100653860(unsigned __int8 *a1, __int64 a2, int a3)
{
__int64 v3; // r15
unsigned int v4; // eax
void **v5; // rbx
__int64 v6; // rcx
std::string *v7; // rdi
const std::string *v8; // r13
int v9; // ebx
const char *data; // rdi
int v11; // eax
__int64 v12; // rsi
unsigned int v13; // eax
__int64 *v14; // rax
__int64 *v15; // rcx
int v16; // edx
int v17; // edx
__int64 *v18; // r12
__int64 *v19; // r14
int v20; // eax
int v21; // eax
char *v22; // r15
__int64 v23; // rax
void **v24; // rbx
void **v25; // r14
void **v26; // rdi
__int64 v27; // [rsp+8h] [rbp-98h]
__int64 v28; // [rsp+10h] [rbp-90h]
__int64 **v29; // [rsp+20h] [rbp-80h]
void *__p[2]; // [rsp+30h] [rbp-70h] BYREF
__int64 v32; // [rsp+40h] [rbp-60h]
void *v33[2]; // [rsp+50h] [rbp-50h] BYREF
__int64 v34; // [rsp+60h] [rbp-40h]
int v35; // [rsp+74h] [rbp-2Ch]
v3 = a2;
v35 = a3;
if ( !a3 )
{
sub_100056AB0(a2, *(_QWORD **)(a2 + 8));
*(_QWORD *)a2 = a2 + 8;
*(_OWORD *)(a2 + 8) = 0;
}
v4 = *a1;
if ( (v4 & 1) != 0 )
{
if ( !*((_QWORD *)a1 + 1) )
return;
}
else if ( !(v4 >> 1) )
{
return;
}
*(_OWORD *)v33 = 0;
v34 = 0;
sub_10064E0E0(a1, "|", (__int64)v33);
v5 = (void **)v33[0];
if ( v33[1] != v33[0] )
{
v29 = (__int64 **)(a2 + 8);
v6 = 0;
v28 = (0xAAAAAAAAAAAAAAABLL * (((char *)v33[1] - (char *)v33[0]) >> 3) == 0)
- 0x5555555555555555LL * (((char *)v33[1] - (char *)v33[0]) >> 3);
while ( 1 )
{
v5 = (void **)v33[0];
if ( *(int *)(v3 + 16) >= 1000 )
break;
*(_OWORD *)__p = 0;
v32 = 0;
v27 = v6;
sub_10064E0E0((unsigned __int8 *)v33[0] + 24 * v6, ":", (__int64)__p);
v8 = (const std::string *)__p[0];
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)__p[1] - (char *)__p[0]) >> 3) < 3 )
goto LABEL_46;
if ( (*(_BYTE *)__p[0] & 1) != 0 )
{
v9 = atoi(*((const char **)__p[0] + 2));
if ( (*(_BYTE *)&v8[1].__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_18:
data = v8[1].__r_.__value_.__s.__data_;
goto LABEL_19;
}
}
else
{
v9 = atoi((const char *)__p[0] + 1);
if ( (*(_BYTE *)&v8[1].__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_18;
}
data = v8[1].__r_.__value_.__l.__data_;
LABEL_19:
v11 = atoi(data);
v12 = (unsigned int)v11;
if ( v9 <= 0 || v11 <= 0 )
goto LABEL_47;
v13 = (unsigned int)v8[2].__r_.__value_.__l.0;
if ( (v13 & 1) != 0 )
{
if ( !v8[2].__r_.__value_.__l.__size_ )
goto LABEL_47;
}
else if ( !(v13 >> 1) )
{
goto LABEL_47;
}
v14 = *v29;
if ( ((unsigned __int8)v35 & (*v29 != nullptr)) == 1 )
{
v15 = *v29;
do
{
v16 = *((_DWORD *)v15 + 8);
if ( v9 >= v16 )
{
if ( v9 <= v16 )
{
v17 = *((_DWORD *)v15 + 9);
if ( (int)v12 < v17 )
goto LABEL_27;
if ( (int)v12 <= v17 )
goto LABEL_46;
}
++v15;
}
LABEL_27:
v15 = (__int64 *)*v15;
}
while ( v15 );
}
v18 = (__int64 *)v29;
LABEL_35:
v19 = v18;
if ( v14 )
{
while ( 1 )
{
v18 = v14;
v20 = *((_DWORD *)v14 + 8);
if ( v9 < v20 )
{
LABEL_34:
v14 = (__int64 *)*v18;
goto LABEL_35;
}
if ( v9 <= v20 )
{
v21 = *((_DWORD *)v18 + 9);
if ( (int)v12 < v21 )
goto LABEL_34;
if ( (int)v12 <= v21 )
break;
}
v14 = (__int64 *)v18[1];
if ( !v14 )
{
v19 = v18 + 1;
goto LABEL_42;
}
}
v22 = (char *)v18;
}
else
{
LABEL_42:
v22 = (char *)operator new(0x40u);
*((_QWORD *)v22 + 4) = (v12 << 32) | (unsigned int)v9;
*(_OWORD *)(v22 + 40) = 0;
*((_QWORD *)v22 + 7) = 0;
*(_OWORD *)v22 = 0;
*((_QWORD *)v22 + 2) = v18;
*v19 = (__int64)v22;
v23 = **(_QWORD **)a2;
if ( v23 )
*(_QWORD *)a2 = v23;
sub_10001B680(*(__int64 **)(a2 + 8), (__int64 *)v22);
++*(_QWORD *)(a2 + 16);
}
std::string::operator=((std::string *)(v22 + 40), v8 + 2);
v8 = (const std::string *)__p[0];
v3 = a2;
LABEL_46:
if ( v8 )
{
LABEL_47:
v24 = (void **)__p[1];
v7 = (std::string *)v8;
if ( __p[1] != v8 )
{
do
{
if ( (*(_BYTE *)(v24 - 3) & 1) != 0 )
operator delete(*(v24 - 1));
v24 -= 3;
}
while ( v24 != (void **)v8 );
v7 = (std::string *)__p[0];
}
__p[1] = (void *)v8;
operator delete(v7);
}
v6 = v27 + 1;
if ( v27 + 1 == v28 )
{
v5 = (void **)v33[0];
break;
}
}
}
if ( v5 )
{
v25 = (void **)v33[1];
v26 = v5;
if ( v33[1] != v5 )
{
do
{
if ( (*(_BYTE *)(v25 - 3) & 1) != 0 )
operator delete(*(v25 - 1));
v25 -= 3;
}
while ( v25 != v5 );
v26 = (void **)v33[0];
}
v33[1] = v5;
operator delete(v26);
}
}