//
// LevelEditorLayer::getNextFreeSFXGroupID from 0x7b5144 to 0x7b5468 (804 bytes)
//
// 2 xrefs:
// > SetupSFXPopup::onPlusButton @ 0xb6d514
// > ??> @ 0x8e150
//
// 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 12:53:53 +0000
//
__int64 __fastcall LevelEditorLayer::getNextFreeSFXGroupID(LevelEditorLayer *a1, __int64 a2)
{
__int64 AllObjects; // x0
unsigned int *v4; // x1
__int64 *v5; // x21
__int64 *v6; // x22
__int64 v7; // x2
unsigned int NextHighestID; // w20
_QWORD *v9; // x0
_QWORD *v10; // x19
void *v11; // x0
int v13; // w4
unsigned __int64 v14; // x19
unsigned __int64 v15; // x24
unsigned __int64 v16; // x20
__int64 *v17; // x0
unsigned __int64 v18; // x1
unsigned __int64 v19; // x1
float v20; // s0
_BOOL8 v21; // x2
__int64 v22; // x0
unsigned __int64 v23; // x2
unsigned __int64 v24; // x1
void **v25; // x0
unsigned __int64 v26; // x2
unsigned __int64 v27; // x0
void *v28; // [xsp+68h] [xbp+68h] BYREF
void *v29; // [xsp+80h] [xbp+80h] BYREF
unsigned __int64 v30; // [xsp+88h] [xbp+88h]
void *v31; // [xsp+90h] [xbp+90h] BYREF
__int64 v32; // [xsp+98h] [xbp+98h]
float v33; // [xsp+A0h] [xbp+A0h]
v29 = nullptr;
v30 = 0;
v31 = nullptr;
v32 = 0;
v33 = 1.0;
LevelEditorLayer::addExclusionList((__int64)a1, a2, (unsigned __int64)&v29);
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( AllObjects )
{
v4 = *(unsigned int **)(AllObjects + 56);
if ( *v4 )
{
v5 = *((__int64 **)v4 + 2);
v6 = &v5[*v4 - 1];
if ( v5 <= v6 )
{
v7 = *v5;
if ( *v5 )
{
while ( 1 )
{
if ( (unsigned int)(*(_DWORD *)(v7 + 1028) - 3602) > 1 )
goto LABEL_6;
v13 = *(_DWORD *)(v7 + 1952);
if ( v13 <= 0 )
goto LABEL_6;
v14 = v30;
v15 = v13;
if ( v30 )
{
v16 = (v30 - 1) & v13;
if ( ((v30 - 1) & v30) != 0 )
v16 = v13 % v30;
v17 = *((__int64 **)v29 + v16);
if ( v17 )
{
while ( 1 )
{
v17 = (__int64 *)*v17;
if ( !v17 )
break;
v18 = v17[1];
v19 = ((v30 - 1) & v30) != 0 ? v18 % v30 : (v30 - 1) & v18;
if ( v16 != v19 )
break;
if ( v13 == *((_DWORD *)v17 + 4) )
goto LABEL_6;
}
}
}
else
{
v16 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(__int64)&v29,
v13,
(_DWORD *)(v7 + 1952),
(__int64)&v28);
v20 = (float)(unsigned __int64)(v32 + 1);
if ( v20 > (float)((float)v14 * v33) )
{
v21 = 1;
v22 = 2 * v14;
if ( v14 > 2 )
v21 = ((v14 - 1) & v14) != 0;
}
else
{
if ( v14 )
goto LABEL_29;
v21 = 1;
v22 = 0;
}
v23 = v21 + v22;
v24 = vcvtps_u32_f32(v20 / v33);
if ( v24 < v23 )
v24 = v23;
std::__hash_table,std::equal_to,std::allocator>::rehash(
(unsigned __int64)&v29,
v24);
v14 = v30;
if ( ((v14 - 1) & v14) == 0 )
{
v16 = (v30 - 1) & v15;
LABEL_29:
v25 = *((void ***)v29 + v16);
if ( !v25 )
goto LABEL_39;
goto LABEL_30;
}
v16 = v15 % v30;
v25 = *((void ***)v29 + v15 % v30);
if ( !v25 )
{
LABEL_39:
*(_QWORD *)v28 = v31;
v31 = v28;
*((_QWORD *)v29 + v16) = &v31;
if ( *(_QWORD *)v28 )
{
v26 = *(_QWORD *)(*(_QWORD *)v28 + 8LL);
if ( ((v14 - 1) & v14) != 0 )
v27 = v26 % v14;
else
v27 = (v14 - 1) & v26;
*((_QWORD *)v29 + v27) = v28;
}
goto LABEL_31;
}
LABEL_30:
*(_QWORD *)v28 = *v25;
*v25 = v28;
LABEL_31:
++v32;
LABEL_6:
if ( v6 >= ++v5 )
{
v7 = *v5;
if ( *v5 )
continue;
}
break;
}
}
}
}
}
NextHighestID = findNextHighestID(1, 1000, &v29);
v9 = v31;
if ( v31 )
{
do
{
v10 = (_QWORD *)*v9;
operator delete(v9);
v9 = v10;
}
while ( v10 );
}
v11 = v29;
v29 = nullptr;
if ( v11 )
operator delete(v11);
return NextHighestID;
}