//
// sub_1402D1460 from 0x1402d1460 to 0x1402d1568 (264 bytes)
//
// 13 xrefs:
// > CollisionBlockPopup::onNextItemID @ 0x14008b7de
// > LevelEditorLayer::getNextFreeGroupID @ 0x1402da951
// > LevelEditorLayer::getNextFreeItemID @ 0x1402daa78
// > LevelEditorLayer::getNextFreeOrderChannel @ 0x1402dabbd
// > LevelEditorLayer::getNextFreeEditorLayer @ 0x1402dacdf
// > LevelEditorLayer::getNextFreeEnterChannel @ 0x1402dae15
// > LevelEditorLayer::getNextFreeAreaEffectID @ 0x1402daf22
// > LevelEditorLayer::getNextFreeGradientID @ 0x1402db035
// > SetupSFXPopup::onPlusButton @ 0x140449062
// > SetupSFXPopup::onPlusButton @ 0x1404491b8
// > ??> @ 0x14068dd1c
// > ??> @ 0x14068dd2c
// > ??> @ 0x1406d2ee8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_1402D1460(int a1, signed int a2, _QWORD *a3)
{
unsigned int v3; // r9d
__int64 v5; // rbx
__int64 v6; // rdi
unsigned int v7; // r11d
unsigned __int64 v8; // rdx
__int64 v9; // rax
v3 = 1;
if ( a1 >= 1 )
v3 = a1;
if ( (int)v3 <= a2 )
{
v5 = a3[6];
v6 = a3[3];
while ( 1 )
{
v7 = v3;
v8 = 0x100000001B3LL
* (((unsigned __int64)v3 >> 24)
^ (0x100000001B3LL
* (BYTE2(v3)
^ (0x100000001B3LL * ((0x100000001B3LL * ((unsigned __int8)v3 ^ 0xCBF29CE484222325uLL)) ^ BYTE1(v3))))));
v9 = *(_QWORD *)(v6 + 16 * (v8 & v5) + 8);
if ( v9 != a3[1] )
{
if ( v3 == *(_DWORD *)(v9 + 16) )
goto LABEL_11;
while ( v9 != *(_QWORD *)(v6 + 16 * (v8 & v5)) )
{
v9 = *(_QWORD *)(v9 + 8);
if ( v3 == *(_DWORD *)(v9 + 16) )
goto LABEL_11;
}
}
v9 = 0;
LABEL_11:
if ( v9 )
{
if ( (int)++v3 <= a2 )
continue;
}
return v7;
}
}
return v3;
}