//
// LevelEditorLayer::getNextFreeTimerID from 0x479040 to 0x479390 (848 bytes)
//
// 2 xrefs:
// > IDNameBrowserPopup::onFormNextFree @ 0x78fe46
// > IDNameInput::onNextFree @ 0x793bba
//
// 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:13 +0000
//
int __fastcall LevelEditorLayer::getNextFreeTimerID(LevelEditorLayer *a1, int a2)
{
unsigned int v3; // r2
LevelSettingsObject *v4; // r0
int AllObjects; // r0
_DWORD *i; // r8
unsigned int v7; // r4
unsigned int v8; // r7
unsigned int v9; // r11
int v10; // r5
_DWORD *v11; // r3
unsigned int v12; // r0
int v13; // r1
float v14; // s15
bool v15; // r5
unsigned int v16; // r5
unsigned int v17; // r1
_DWORD *v18; // r3
unsigned int v19; // r0
int v20; // r1
int *v21; // r3
int v22; // r5
_DWORD *v23; // r3
unsigned int v24; // r11
_DWORD *v25; // r8
int NextHighestID; // r4
_DWORD *v28; // r3
_DWORD *v29; // t1
int v30; // r2
unsigned int v31; // r7
unsigned int v32; // r4
unsigned int v33; // r9
int v34; // r5
_DWORD *v35; // r3
unsigned int v36; // r0
int v37; // r1
float v38; // s15
bool v39; // r5
unsigned int v40; // r5
unsigned int v41; // r1
void **v42; // r3
unsigned int v43; // r0
int v44; // r1
_DWORD v45[3]; // [sp+10h] [bp-34h] BYREF
void *v46; // [sp+1Ch] [bp-28h] BYREF
int v47; // [sp+28h] [bp-1Ch] BYREF
unsigned int v48; // [sp+2Ch] [bp-18h]
void *v49; // [sp+30h] [bp-14h] BYREF
int v50; // [sp+34h] [bp-10h]
float v51; // [sp+38h] [bp-Ch]
v47 = 0;
v48 = 0;
v49 = nullptr;
v50 = 0;
v51 = 1.0;
LevelEditorLayer::addExclusionList((int)a1, a2, (int)&v47);
v4 = *((LevelSettingsObject **)a1 + 521);
if ( v4 )
{
for ( i = (_DWORD *)LevelSettingsObject::getIDNames(v4, 4u, v3)[2]; ; i = (_DWORD *)*i )
{
if ( !i )
goto LABEL_2;
v7 = v48;
v8 = i[2];
if ( v48 )
{
v9 = v48 - 1;
if ( ((v48 - 1) & v48) != 0 )
v10 = v8 % v48;
else
v10 = v8 & v9;
v11 = *(_DWORD **)(v47 + 4 * v10);
if ( v11 )
{
while ( 1 )
{
v11 = (_DWORD *)*v11;
if ( !v11 )
break;
v12 = v11[1];
v13 = ((v48 - 1) & v48) != 0 ? v12 % v48 : v9 & v12;
if ( v13 != v10 )
break;
if ( v11[2] == v8 )
goto LABEL_34;
}
}
}
else
{
v10 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)v45,
(int)&v47,
v8,
i + 2);
v14 = (float)(unsigned int)(v50 + 1);
if ( v14 > (float)((float)v7 * v51) )
break;
if ( !v7 )
{
v15 = 0;
LABEL_21:
v16 = 2 * v7 + !v15;
v17 = (unsigned int)ceilf(v14 / v51);
if ( v17 < v16 )
v17 = v16;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v47, v17);
v7 = v48;
if ( ((v48 - 1) & v48) != 0 )
v10 = v8 % v48;
else
v10 = (v48 - 1) & v8;
}
v18 = *(_DWORD **)(v47 + 4 * v10);
if ( v18 )
{
*(_DWORD *)v45[0] = *v18;
*v18 = v45[0];
}
else
{
*(_DWORD *)v45[0] = v49;
v49 = (void *)v45[0];
*(_DWORD *)(v47 + 4 * v10) = &v49;
if ( *(_DWORD *)v45[0] )
{
v19 = *(_DWORD *)(*(_DWORD *)v45[0] + 4);
if ( ((v7 - 1) & v7) != 0 )
v20 = v19 % v7;
else
v20 = (v7 - 1) & v19;
*(_DWORD *)(v47 + 4 * v20) = v45[0];
}
}
++v50;
LABEL_34:
;
}
v15 = v7 > 2 && ((v7 - 1) & v7) == 0;
goto LABEL_21;
}
LABEL_2:
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( AllObjects )
{
v21 = *(int **)(AllObjects + 52);
v22 = *v21;
if ( *v21 )
{
v23 = (_DWORD *)v21[3];
v24 = (unsigned int)&v23[v22 - 1];
v25 = v23;
while ( 1 )
{
while ( 1 )
{
LABEL_37:
if ( (unsigned int)v25 <= v24 )
{
v29 = (_DWORD *)*v25++;
v28 = v29;
if ( v29 )
continue;
}
goto LABEL_38;
if ( v28[271] == 1 )
{
v30 = v28[223];
if ( (unsigned int)(v30 - 3614) <= 1 || v30 == 3617 )
break;
}
}
v31 = v28[375];
v32 = v48;
v45[0] = v31;
if ( v48 )
{
v33 = v48 - 1;
if ( ((v48 - 1) & v48) != 0 )
v34 = v31 % v48;
else
v34 = v31 & v33;
v35 = *(_DWORD **)(v47 + 4 * v34);
if ( v35 )
{
while ( 1 )
{
v35 = (_DWORD *)*v35;
if ( !v35 )
break;
v36 = v35[1];
v37 = ((v48 - 1) & v48) != 0 ? v36 % v48 : v33 & v36;
if ( v37 != v34 )
break;
if ( v35[2] == v31 )
goto LABEL_37;
}
}
}
else
{
v34 = 0;
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)&v46,
(int)&v47,
v31,
v45);
v38 = (float)(unsigned int)(v50 + 1);
if ( v38 > (float)((float)v32 * v51) )
{
v39 = v32 > 2 && ((v32 - 1) & v32) == 0;
}
else
{
if ( v32 )
goto LABEL_69;
v39 = 0;
}
v40 = 2 * v32 + !v39;
v41 = (unsigned int)ceilf(v38 / v51);
if ( v41 < v40 )
v41 = v40;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)&v47, v41);
v32 = v48;
if ( ((v48 - 1) & v48) != 0 )
v34 = v31 % v48;
else
v34 = (v48 - 1) & v31;
LABEL_69:
v42 = *(void ***)(v47 + 4 * v34);
if ( v42 )
{
*(_DWORD *)v46 = *v42;
*v42 = v46;
}
else
{
*(_DWORD *)v46 = v49;
v49 = v46;
*(_DWORD *)(v47 + 4 * v34) = &v49;
if ( *(_DWORD *)v46 )
{
v43 = *(_DWORD *)(*(_DWORD *)v46 + 4);
if ( ((v32 - 1) & v32) != 0 )
v44 = v43 % v32;
else
v44 = (v32 - 1) & v43;
*(_DWORD *)(v47 + 4 * v44) = v46;
}
}
++v50;
}
}
}
LABEL_38:
NextHighestID = findNextHighestID(1, 1000, &v47);
std::__hash_table,std::equal_to,std::allocator>::~__hash_table((int)&v47);
return NextHighestID;
}