//
// sub_14003F200 from 0x14003f200 to 0x14003f30d (269 bytes)
//
// 167 xrefs:
// > sub_140005660 @ 0x1400056f0
// > sub_14003EC10 @ 0x14003ec71
// > sub_14003F310 @ 0x14003f371
// > FMODAudioState::FMODAudioState @ 0x14005bf40
// > FMODAudioEngine::FMODAudioEngine @ 0x14005c013
// > FMODAudioEngine::FMODAudioEngine @ 0x14005c072
// > FMODAudioEngine::FMODAudioEngine @ 0x14005c190
// > FMODAudioEngine::FMODAudioEngine @ 0x14005c1ef
// > FMODAudioEngine::FMODAudioEngine @ 0x14005c29d
// > FMODAudioEngine::stopMusicNotInSet @ 0x140065247
// > sub_1400666C0 @ 0x140066721
// > sub_1400669E0 @ 0x140066a41
// > sub_140066D70 @ 0x140066dd1
// > sub_1400673C0 @ 0x140067421
// > sub_14006A400 @ 0x14006a475
// > sub_14006B280 @ 0x14006b2f5
// > sub_14006B5B0 @ 0x14006b611
// > sub_140080E00 @ 0x140080eba
// > sub_14008C7D0 @ 0x14008c8a4
// > sub_140092600 @ 0x140092674
// > GJOptionsLayer::GJOptionsLayer @ 0x1401801fd
// > EditorSFXManager::sharedState @ 0x1401851c5
// > EditorSFXManager::deserializeAll @ 0x14018946c
// > sub_140189D00 @ 0x14018a022
// > sub_14018C500 @ 0x14018c561
// > EditorUI::EditorUI @ 0x1401a9007
// > EditorUI::onGoToFreeLayer @ 0x1401b55c9
// > EditorUI::dynamicGroupUpdate @ 0x1401b82e4
// > EditorUI::dynamicGroupUpdate @ 0x1401b8343
// > EditorUI::dynamicGroupUpdate @ 0x1401b8503
// > EditorUI::dynamicGroupUpdate @ 0x1401b8883
// > EditorUI::assignNewGroups @ 0x1401b8f9c
// > EditorUI::createLoop @ 0x1401b95f9
// > EditorUI::createLoop @ 0x1401b98a6
// > EditorUI::createGradientFromSelection @ 0x1401b9ee8
// > sub_1401BA030 @ 0x1401ba0ae
// > EditorUI::editGroup @ 0x1401be9b4
// > EditorUI::copyObjects @ 0x1401c57cc
// > EditorUI::pasteObjects @ 0x1401c64a8
// > GameLevelManager::getStarLevelsString @ 0x14021f7ec
// > GameLevelManager::getStarLevelsString @ 0x14021f842
// > GameLevelManager::verifyContainerOnlyHasLevels @ 0x140224f0a
// > GameManager::recountUserStats @ 0x1402804b0
// > GameSettingsLayer::create @ 0x1402c278a
// > sub_1402F9D00 @ 0x1402f9d61
// > sub_14030A660 @ 0x14030a9cc
// > sub_14030A660 @ 0x14030aafa
// > sub_14030A660 @ 0x14030ad03
// > sub_14030A660 @ 0x14030ad62
// > GJBaseGameLayer::playKeyframeAnimation @ 0x14031f301
// > GJBaseGameLayer::prepareSavePositionObjects @ 0x140320e23
// > GJBaseGameLayer::prepareSavePositionObjects @ 0x14032162a
// > GJBaseGameLayer::prepareSavePositionObjects @ 0x14032167f
// > GJBaseGameLayer::spawnObject @ 0x1403228b2
// > GJBaseGameLayer::generateSpawnRemap @ 0x140325655
// > GJBaseGameLayer::registerSpawnRemap @ 0x140325815
// > GJBaseGameLayer::sortGroups @ 0x14032bff9
// > GJBaseGameLayer::removeFromGroupParents @ 0x14032c745
// > GJBaseGameLayer::generateTargetGroups @ 0x14032d792
// > GJBaseGameLayer::generateTargetGroups @ 0x14032d93f
// > GJBaseGameLayer::generateTargetGroups @ 0x14032ded5
// > GJBaseGameLayer::generateVisibilityGroups @ 0x14033a118
// > GJBaseGameLayer::generateVisibilityGroups @ 0x14033a294
// > GJBaseGameLayer::generateVisibilityGroups @ 0x14033a5ca
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x14033d7e7
// > GJBaseGameLayer::preUpdateVisibility @ 0x14033f1d1
// > GJBaseGameLayer::processSFXObjects @ 0x14034bb38
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034db3a
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e255
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e2cc
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e325
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e39c
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e3f5
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e46c
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e4e3
// > GJBaseGameLayer::processActivatedAudioTriggers @ 0x14034e670
// > sub_140354D00 @ 0x140354d61
// > sub_140355170 @ 0x1403551d1
// > sub_140355560 @ 0x1403555cc
// > sub_14035E2B0 @ 0x14035e30b
// > sub_14035E470 @ 0x14035e4dc
// > sub_14036F8B0 @ 0x14036f911
// > sub_14036FA70 @ 0x14036fad1
// > sub_14036FC00 @ 0x14036fc61
// > sub_14036FF10 @ 0x14036ff71
// > sub_1403700D0 @ 0x140370131
// > sub_14038CC90 @ 0x14038ccf9
// > sub_14038CFB0 @ 0x14038d01c
// > sub_14038D060 @ 0x14038d0c1
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c4073
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c413d
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c420b
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c42d3
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c4381
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c4434
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c44e7
// > IDNameBrowserPopup::onFormNextFree @ 0x1403c4593
// > IDNameInput::onNextFree @ 0x1403c8ea4
// > IDNameInput::onNextFree @ 0x1403c8fc1
// > IDNameInput::onNextFree @ 0x1403c9065
// > IDNameInput::onNextFree @ 0x1403c9181
// > IDNameInput::onNextFree @ 0x1403c92a1
// > IDNameInput::onNextFree @ 0x1403c93c1
// > IDNameInput::onNextFree @ 0x1403c94f1
// > IDNameInput::onNextFree @ 0x1403c9595
// > IDNameInput::collectMatches @ 0x1403ca5d2
// > GJBaseGameLayer::GJBaseGameLayer @ 0x1403eb871
// > GJBaseGameLayer::GJBaseGameLayer @ 0x1403ebbd5
// > sub_1403ECAC0 @ 0x1403ecc2a
// > LevelEditorLayer::getNextFreeGroupID @ 0x1403f7d87
// > LevelEditorLayer::getNextFreeItemID @ 0x1403f800e
// > LevelEditorLayer::getNextFreeBlockID @ 0x1403f824e
// > LevelEditorLayer::getNextFreeTimerID @ 0x1403f847e
// > LevelEditorLayer::getNextFreeControlID @ 0x1403f86ae
// > LevelEditorLayer::getNextFreeOrderChannel @ 0x1403f88c6
// > LevelEditorLayer::getNextFreeEditorLayer @ 0x1403f8b36
// > LevelEditorLayer::getNextFreeEnterChannel @ 0x1403f8d9f
// > LevelEditorLayer::getNextFreeAreaEffectID @ 0x1403f8fc4
// > LevelEditorLayer::getNextFreeSFXID @ 0x1403f9254
// > LevelEditorLayer::getNextFreeSFXGroupID @ 0x1403f94cc
// > LevelEditorLayer::getNextFreeGradientID @ 0x1403f973e
// > LevelEditorLayer::getNextColorChannel @ 0x1403f9965
// > LevelEditorLayer::resetUnusedColorChannels @ 0x1403f9d23
// > sub_140402950 @ 0x140402a89
// > sub_140402950 @ 0x140402d06
// > sub_140402950 @ 0x140403009
// > sub_140403620 @ 0x14040374e
// > sub_140403620 @ 0x140403828
// > sub_140403620 @ 0x14040389f
// > sub_140403620 @ 0x140403916
// > sub_140403620 @ 0x1404039af
// > sub_140403620 @ 0x140403a26
// > sub_140403620 @ 0x140403a9d
// > sub_140403620 @ 0x140403b14
// > sub_140403620 @ 0x140403da9
// > sub_140403620 @ 0x140403e51
// > sub_140403620 @ 0x140404125
// > sub_140403620 @ 0x140404570
// > sub_140405690 @ 0x140405781
// > sub_140405690 @ 0x14040598b
// > sub_140406240 @ 0x14040632b
// > sub_140406240 @ 0x140406390
// > DrawGridLayer::create @ 0x14040a161
// > LevelSettingsObject::getIDNames @ 0x14040dc60
// > sub_14040E0F0 @ 0x14040e197
// > sub_140414680 @ 0x1404146e1
// > sub_140417E40 @ 0x140417ea1
// > sub_140418AD0 @ 0x140418b34
// > MusicDownloadManager::onDownloadNewsFeedCompleted @ 0x140491f2d
// > SongInfoObject::getArtistNames @ 0x140496375
// > PlayerObject::PlayerObject @ 0x1404e38a3
// > PlayLayer::processLoadedMoveActions @ 0x14050dc49
// > PlayLayer::loadDefaultColors @ 0x140510729
// > CheckpointObject::CheckpointObject @ 0x140521090
// > SetGroupIDLayer::onNextFreeEditorLayer1 @ 0x140593784
// > SetGroupIDLayer::onNextFreeEditorLayer2 @ 0x140593904
// > SetGroupIDLayer::onNextFreeOrderChannel @ 0x140594294
// > SetupObjectOptions2Popup::onPlusButton @ 0x140597d99
// > SetupEnterEffectPopup::onNextFreeEnterEffectID @ 0x1405b5a29
// > SetupKeyframePopup::onCustomButton @ 0x1405bbc66
// > SetupRotateGameplayPopup::onPlusButton @ 0x1405d6fd9
// > SetupSFXPopup::onPlusButton @ 0x1405de7dc
// > SetupSFXPopup::onPlusButton @ 0x1405de8f9
// > ??> @ 0x140884940
// > ??> @ 0x140884958
// > ??> @ 0x140884968
// > ??> @ 0x14090f290
//
// This function is hookable on this platform (idp: pc, 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 11:25:28 +0000
//
unsigned __int64 __fastcall sub_14003F200(__int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 *v5; // rcx
__int64 v6; // r14
unsigned __int64 *v7; // rax
unsigned __int64 *v8; // rcx
unsigned __int64 *v9; // rdi
__int64 v10; // rdx
unsigned __int64 result; // rax
unsigned __int64 v12; // [rsp+50h] [rbp+18h] BYREF
v12 = a3;
v5 = *(unsigned __int64 **)a1;
if ( (__int64)(*(_QWORD *)(a1 + 8) - (_QWORD)v5) >> 3 >= a2 )
return sub_14003EC90(v5, *(unsigned __int64 **)(a1 + 8), &v12);
if ( a2 > 0x1FFFFFFFFFFFFFFFLL )
sub_140009CF0();
v6 = a2;
v7 = sub_14003D460(8 * a2);
v8 = *(unsigned __int64 **)a1;
v9 = v7;
v10 = (__int64)(*(_QWORD *)(a1 + 16) - *(_QWORD *)a1) >> 3;
if ( v10 )
{
if ( (unsigned __int64)(8 * v10) >= 0x1000 )
{
if ( (unsigned __int64)v8 - *(v8 - 1) - 8 > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
v8 = (unsigned __int64 *)*(v8 - 1);
}
j_j_free(v8);
}
result = (unsigned __int64)&v9[v6];
*(_QWORD *)a1 = v9;
*(_QWORD *)(a1 + 8) = &v9[v6];
*(_QWORD *)(a1 + 16) = &v9[v6];
if ( v9 != &v9[v6] )
{
do
*v9++ = a3;
while ( v9 != (unsigned __int64 *)result );
}
return result;
}