//
// sub_140051590 from 0x140051590 to 0x14005161c (140 bytes)
//
// 88 xrefs:
// > FMODAudioEngine::queuedEffectFinishedLoading @ 0x14005b276
// > MultilineBitmapFont::initWithFont @ 0x14006c0a7
// > AccountLoginLayer::onSubmit @ 0x14007cd22
// > AccountLoginLayer::onSubmit @ 0x14007cdb9
// > AccountLoginLayer::onSubmit @ 0x14007ceb0
// > EditLevelLayer::init @ 0x1400d5558
// > EditorPauseLayer::saveLevel @ 0x1400dde28
// > EditorPauseLayer::saveLevel @ 0x1400dde50
// > EditorUI::doCopyObjects @ 0x140113293
// > GameLevelManager::uploadUserMessage @ 0x14015b017
// > GameLevelManager::uploadUserMessage @ 0x14015b09f
// > GameLevelManager::uploadComment @ 0x14015db54
// > GameLevelManager::uploadFriendRequest @ 0x140160631
// > GJGameLevel::create @ 0x14016bff7
// > GJGameLevel::storeNewLocalScore @ 0x14016d5cd
// > GJGameLevel::dataLoaded @ 0x14016e387
// > GJGameLevel::dataLoaded @ 0x14016e40b
// > GJGameLevel::dataLoaded @ 0x14016e479
// > GJGameLevel::dataLoaded @ 0x14016e4a5
// > GJGameLevel::dataLoaded @ 0x14016e4de
// > GJGameLevel::dataLoaded @ 0x14016e50a
// > GJGameLevel::dataLoaded @ 0x14016e536
// > GJGameLevel::dataLoaded @ 0x14016e562
// > GJGameLevel::dataLoaded @ 0x14016e5a4
// > GJGameLevel::dataLoaded @ 0x14016e5d0
// > GJGameLevel::dataLoaded @ 0x14016ea0a
// > GJGameLevel::dataLoaded @ 0x14016eafc
// > GJGameLevel::dataLoaded @ 0x14016eb28
// > GJGameLevel::dataLoaded @ 0x14016ed52
// > GJGameLevel::dataLoaded @ 0x14016edec
// > GJGameLevel::dataLoaded @ 0x14016ee86
// > GJLevelList::dataLoaded @ 0x140177d4f
// > GJLevelList::dataLoaded @ 0x140177d7d
// > GJLevelList::dataLoaded @ 0x140177dab
// > GameManager::playSFXTrigger @ 0x14017bd46
// > GameManager::dataLoaded @ 0x140186c08
// > GameManager::dataLoaded @ 0x140186c34
// > GameManager::dataLoaded @ 0x14018779f
// > GameManager::dataLoaded @ 0x1401877cb
// > GameManager::dataLoaded @ 0x1401877f7
// > GameManager::dataLoaded @ 0x140187823
// > GameManager::dataLoaded @ 0x14018784f
// > GameManager::dataLoaded @ 0x14018787b
// > GameManager::dataLoaded @ 0x14018790a
// > GameManager::dataLoaded @ 0x14018794c
// > GameManager::dataLoaded @ 0x140187978
// > GameManager::dataLoaded @ 0x1401879c0
// > GameManager::dataLoaded @ 0x140187a64
// > GameManager::firstLoad @ 0x1401889b5
// > GameObject::createAndAddParticle @ 0x140198c11
// > GameObject::setupCustomSprites @ 0x1401b8b0d
// > GameObject::setupCustomSprites @ 0x1401b8b3d
// > GameObject::setupCustomSprites @ 0x1401b8b6e
// > GameObject::setupCustomSprites @ 0x1401b8baa
// > GameObject::setupCustomSprites @ 0x1401b8bda
// > GameObject::setupCustomSprites @ 0x1401b93fb
// > GameObject::setupCustomSprites @ 0x1401b9613
// > GJBaseGameLayer::updateSpecialLabels @ 0x140239494
// > GJMultiplayerManager::uploadComment @ 0x140283673
// > GJObjectDecoder::getDecodedObject @ 0x1402841bc
// > GJObjectDecoder::getDecodedObject @ 0x14028446e
// > GJAccountSettingsLayer::init @ 0x1402923a2
// > GJAccountSettingsLayer::init @ 0x1402923e7
// > GJAccountSettingsLayer::init @ 0x14029242c
// > GJAccountSettingsLayer::init @ 0x140292471
// > GJAccountSettingsLayer::init @ 0x1402924b6
// > GJAccountSettingsLayer::init @ 0x1402924fb
// > GJAccountSettingsLayer::init @ 0x140292540
// > GJAccountSettingsLayer::closeAccInputNodes @ 0x140293fb1
// > GJSmartTemplate::dataLoaded @ 0x1402b55a0
// > InfoLayer::loadPage @ 0x1402be4c6
// > LevelEditorLayer::init @ 0x1402d2972
// > LevelEditorLayer::createObjectsFromSetup @ 0x1402d3c97
// > LevelEditorLayer::createObjectsFromString @ 0x1402d43a2
// > LevelListLayer::init @ 0x14030372a
// > MusicDownloadManager::pathForSongFolder @ 0x14033f45d
// > MusicDownloadManager::pathForSongFolder @ 0x14033f4a1
// > MusicDownloadManager::pathForSFXFolder @ 0x14033f78d
// > MusicDownloadManager::pathForSFXFolder @ 0x14033f7d1
// > NumberInputLayer::onNumber @ 0x140348a35
// > PlayLayer::levelComplete @ 0x1403a80ff
// > PlayLayer::processCreateObjectsFromSetup @ 0x1403ad487
// > CreateParticlePopup::init @ 0x14042c217
// > CreateParticlePopup::init @ 0x14042c375
// > ParticleGameObject::customObjectSetup @ 0x14049fd07
// > AnimatedGameObject::deactivateObject @ 0x1404a3c48
// > ??> @ 0x1406c4da0
// > ??> @ 0x1406c4dac
//
// 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_140051590(__int64 a1, __int64 a2)
{
unsigned __int64 v4; // rdx
_QWORD *v5; // rcx
if ( a1 != a2 )
{
v4 = *(_QWORD *)(a1 + 24);
if ( v4 > 0xF )
{
v5 = *(_QWORD **)a1;
if ( v4 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v5 - *(v5 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v5 = (_QWORD *)*(v5 - 1);
}
j_j_free(v5);
}
*(_QWORD *)(a1 + 24) = 15;
*(_QWORD *)(a1 + 16) = 0;
*(_BYTE *)a1 = 0;
*(_OWORD *)a1 = *(_OWORD *)a2;
*(_OWORD *)(a1 + 16) = *(_OWORD *)(a2 + 16);
*(_QWORD *)(a2 + 16) = 0;
*(_QWORD *)(a2 + 24) = 15;
*(_BYTE *)a2 = 0;
}
return a1;
}