//
// LevelEditorLayer::getNextFreeSFXGroupID from 0x47a704 to 0x47a8f0 (492 bytes)
//
// 1 xrefs:
// > SetupSFXPopup::onPlusButton @ 0x6b0b72
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:49:14 +0000
//
int __fastcall LevelEditorLayer::getNextFreeSFXGroupID(LevelEditorLayer *a1, int a2)
{
int AllObjects; // r0
int NextHighestID; // r4
_DWORD *v6; // r3
int *v7; // r7
int *v8; // r10
int v9; // r11
int v10; // t1
int v11; // r6
unsigned int v12; // r4
unsigned int v13; // r9
int v14; // r5
_DWORD *v15; // r2
unsigned int v16; // r0
int v17; // r1
float v18; // s15
bool v19; // r5
unsigned int v20; // r5
unsigned int v21; // r1
void **v22; // r3
unsigned int v23; // r0
int v24; // r1
void *v25; // [sp+1Ch] [bp-28h] BYREF
int v26; // [sp+28h] [bp-1Ch] BYREF
unsigned int v27; // [sp+2Ch] [bp-18h]
void *v28; // [sp+30h] [bp-14h] BYREF
int v29; // [sp+34h] [bp-10h]
float v30; // [sp+38h] [bp-Ch]
v26 = 0;
v27 = 0;
v28 = nullptr;
v29 = 0;
v30 = 1.0;
LevelEditorLayer::addExclusionList((int)a1, a2, (int)&v26);
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( AllObjects )
{
v6 = *(_DWORD **)(AllObjects + 52);
if ( *v6 )
{
v7 = (int *)v6[3];
v8 = &v7[*v6 - 1];
while ( 1 )
{
while ( 1 )
{
LABEL_5:
if ( v7 <= v8 )
{
v10 = *v7++;
v9 = v10;
if ( v10 )
continue;
}
goto LABEL_2;
if ( (unsigned int)(*(_DWORD *)(v9 + 892) - 3602) <= 1 )
{
v11 = *(_DWORD *)(v9 + 1748);
if ( v11 > 0 )
break;
}
}
v12 = v27;
if ( v27 )
{
v13 = v27 - 1;
if ( ((v27 - 1) & v27) != 0 )
v14 = v11 % v27;
else
v14 = v13 & v11;
v15 = *(_DWORD **)(v26 + 4 * v14);
if ( v15 )
{
while ( 1 )
{
v15 = (_DWORD *)*v15;
if ( !v15 )
break;
v16 = v15[1];
v17 = ((v27 - 1) & v27) != 0 ? v16 % v27 : v13 & v16;
if ( v17 != v14 )
break;
if ( v15[2] == v11 )
goto LABEL_5;
}
}
}
else
{
v14 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)&v25,
(int)&v26,
v11,
(_DWORD *)(v9 + 1748));
v18 = (float)(unsigned int)(v29 + 1);
if ( v18 > (float)((float)v12 * v30) )
{
v19 = v12 > 2 && ((v12 - 1) & v12) == 0;
}
else
{
if ( v12 )
goto LABEL_29;
v19 = 0;
}
v20 = 2 * v12 + !v19;
v21 = (unsigned int)ceilf(v18 / v30);
if ( v21 < v20 )
v21 = v20;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v26, v21);
v12 = v27;
if ( ((v27 - 1) & v27) != 0 )
v14 = v11 % v27;
else
v14 = (v27 - 1) & v11;
LABEL_29:
v22 = *(void ***)(v26 + 4 * v14);
if ( v22 )
{
*(_DWORD *)v25 = *v22;
*v22 = v25;
}
else
{
*(_DWORD *)v25 = v28;
v28 = v25;
*(_DWORD *)(v26 + 4 * v14) = &v28;
if ( *(_DWORD *)v25 )
{
v23 = *(_DWORD *)(*(_DWORD *)v25 + 4);
if ( ((v12 - 1) & v12) != 0 )
v24 = v23 % v12;
else
v24 = (v12 - 1) & v23;
*(_DWORD *)(v26 + 4 * v24) = v25;
}
}
++v29;
}
}
}
LABEL_2:
NextHighestID = findNextHighestID(1, 1000, &v26);
std::__hash_table,std::equal_to,std::allocator>::~__hash_table((int)&v26);
return NextHighestID;
}