//
// sub_14005E660 from 0x14005e660 to 0x14005e775 (277 bytes)
//
// 88 xrefs:
// > FMODAudioEngine::FMODAudioEngine @ 0x1400535ac
// > CollisionBlockPopup::onNextItemID @ 0x14008b6c9
// > CollisionBlockPopup::onNextItemID @ 0x14008b72c
// > EditorUI::copyObjects @ 0x140112e8a
// > EditorUI::dynamicGroupUpdate @ 0x140118957
// > EditorUI::dynamicGroupUpdate @ 0x140118973
// > EditorUI::dynamicGroupUpdate @ 0x140118b0c
// > EditorUI::dynamicGroupUpdate @ 0x140118db6
// > EditorUI::assignNewGroups @ 0x140119304
// > EditorUI::createLoop @ 0x140119891
// > EditorUI::createLoop @ 0x140119b09
// > EditorUI::editGroup @ 0x14011f426
// > EditorUI::onAssignNewGroupID @ 0x1401225ac
// > sub_1402044D0 @ 0x140204bca
// > GJBaseGameLayer::playKeyframeAnimation @ 0x140217c11
// > GJBaseGameLayer::prepareSavePositionObjects @ 0x140219858
// > GJBaseGameLayer::prepareSavePositionObjects @ 0x140219eb4
// > GJBaseGameLayer::sortGroups @ 0x140224319
// > GJBaseGameLayer::generateTargetGroups @ 0x140224fa1
// > GJBaseGameLayer::generateTargetGroups @ 0x140225111
// > GJBaseGameLayer::generateVisibilityGroups @ 0x1402315d7
// > GJBaseGameLayer::generateVisibilityGroups @ 0x14023171d
// > GJBaseGameLayer::generateVisibilityGroups @ 0x14023192e
// > GJBaseGameLayer::preUpdateVisibility @ 0x140236297
// > GJBaseGameLayer::processSFXObjects @ 0x140241a54
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x1402439e8
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x140244038
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x1402442ea
// > sub_14024E220 @ 0x14024e362
// > sub_1402515A0 @ 0x1402516c9
// > sub_1402515A0 @ 0x1402516ee
// > sub_1402515A0 @ 0x140251716
// > sub_140253DB0 @ 0x140253de2
// > sub_140253DB0 @ 0x140253dfe
// > sub_140253DB0 @ 0x140253e1d
// > sub_140258050 @ 0x14025818e
// > sub_140258050 @ 0x1402581a9
// > sub_140258050 @ 0x1402581c4
// > sub_140258050 @ 0x14025821c
// > sub_140258050 @ 0x140258266
// > GJBaseGameLayer::GJBaseGameLayer @ 0x1402d0639
// > LevelEditorLayer::getNextFreeGroupID @ 0x1402da7ce
// > LevelEditorLayer::getNextFreeItemID @ 0x1402da9a5
// > LevelEditorLayer::getNextFreeOrderChannel @ 0x1402daad8
// > LevelEditorLayer::getNextFreeEditorLayer @ 0x1402dac18
// > LevelEditorLayer::getNextFreeEnterChannel @ 0x1402dad48
// > LevelEditorLayer::getNextFreeAreaEffectID @ 0x1402dae75
// > LevelEditorLayer::getNextFreeGradientID @ 0x1402daf85
// > LevelEditorLayer::getNextColorChannel @ 0x1402db0a6
// > LevelEditorLayer::resetUnusedColorChannels @ 0x1402db46c
// > LevelEditorLayer::duplicateKeyframeAnimation @ 0x1402e193e
// > sub_1402E2EF0 @ 0x1402e2fee
// > sub_1402E3B00 @ 0x1402e3bb7
// > sub_1402E3B00 @ 0x1402e3c55
// > sub_1402E3B00 @ 0x1402e3c91
// > sub_1402E3B00 @ 0x1402e3cab
// > sub_1402E3B00 @ 0x1402e3cc5
// > sub_1402E3B00 @ 0x1402e3fc3
// > sub_1402E3B00 @ 0x1402e423a
// > LevelTools::getLevelList @ 0x140324fe0
// > sub_14033B4D0 @ 0x14033b652
// > MusicDownloadManager::sharedState @ 0x14033cd23
// > MusicDownloadManager::sharedState @ 0x14033cd3e
// > PlayerObject::PlayerObject @ 0x1403856e9
// > PlayerObject::PlayerObject @ 0x1403858d3
// > PlayLayer::PlayLayer @ 0x1403a4faa
// > sub_1403A53B0 @ 0x1403a5409
// > sub_1403A53B0 @ 0x1403a54f0
// > PlayLayer::loadDefaultColors @ 0x1403b1c7d
// > PlayerCheckpoint::create @ 0x1403bb138
// > PlayerCheckpoint::create @ 0x1403bb181
// > SetGroupIDLayer::onNextGroupID1 @ 0x1403fc09b
// > SetGroupIDLayer::onNextFreeEditorLayer1 @ 0x1403fcfab
// > SetGroupIDLayer::onNextFreeEditorLayer2 @ 0x1403fd04b
// > SetGroupIDLayer::onNextFreeOrderChannel @ 0x1403fd8ab
// > SetupObjectOptions2Popup::onPlusButton @ 0x140400fde
// > SetupAreaMoveTriggerPopup::onNextFreeEffectID @ 0x14040da0e
// > SetupEnterEffectPopup::onNextFreeEnterChannel @ 0x14042058e
// > SetupGradientPopup::onPlusButton @ 0x140421cc3
// > SetupInteractObjectPopup::onPlusButton @ 0x14042437a
// > SetupKeyframePopup::onCustomButton @ 0x140426749
// > SetupPickupTriggerPopup::onPlusButton @ 0x14043725e
// > SetupRotateGameplayPopup::onPlusButton @ 0x140441f3e
// > SetupSFXPopup::onPlusButton @ 0x140448f60
// > SetupSFXPopup::onPlusButton @ 0x140448fb6
// > SetupSFXPopup::onPlusButton @ 0x1404490a7
// > SetupSFXPopup::onPlusButton @ 0x1404490fd
// > ??> @ 0x1406c5784
//
// 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
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall sub_14005E660(__int64 a1, _DWORD *a2, __int64 a3)
{
_QWORD *v4; // rax
__int64 v5; // rbx
_QWORD *v6; // rdi
_QWORD *v7; // rcx
__int64 v8; // rax
_QWORD *v9; // rax
__int64 v11; // [rsp+40h] [rbp+18h] BYREF
v11 = a3;
*(_DWORD *)a1 = *a2;
*(_QWORD *)(a1 + 8) = 0;
*(_QWORD *)(a1 + 16) = 0;
v4 = operator new(0x18u);
*v4 = v4;
v4[1] = v4;
*(_QWORD *)(a1 + 8) = v4;
*(_QWORD *)(a1 + 24) = 0;
*(_QWORD *)(a1 + 32) = 0;
*(_QWORD *)(a1 + 40) = 0;
*(_QWORD *)(a1 + 48) = 7;
*(_QWORD *)(a1 + 56) = 8;
*(_DWORD *)a1 = 1065353216;
v5 = *(_QWORD *)(a1 + 8);
v11 = v5;
if ( (unsigned __int64)(*(__int64 *)(a1 + 32) >> 3) >= 0x10 )
{
sub_140060560(0, *(_QWORD *)(a1 + 32), &v11);
}
else
{
v6 = operator new(0x80u);
v7 = *(_QWORD **)(a1 + 24);
v8 = (__int64)(*(_QWORD *)(a1 + 40) - (_QWORD)v7) >> 3;
if ( v8 )
{
if ( (unsigned __int64)(8 * v8) >= 0x1000 )
{
if ( (unsigned __int64)v7 - *(v7 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v7 = (_QWORD *)*(v7 - 1);
}
j_j_free(v7);
}
*(_QWORD *)(a1 + 24) = v6;
v9 = v6 + 16;
*(_QWORD *)(a1 + 32) = v6 + 16;
*(_QWORD *)(a1 + 40) = v6 + 16;
do
*v6++ = v5;
while ( v6 != v9 );
}
return a1;
}