//
// sub_14003BCE0 from 0x14003bce0 to 0x14003bda7 (199 bytes)
//
// 26 xrefs:
// > sub_14004ED00 @ 0x14004eea8
// > sub_14004ED00 @ 0x14004efed
// > CCTextInputNode::onTextFieldInsertText @ 0x14005081b
// > FMODAudioEngine::preloadMusic @ 0x14005ca23
// > FMODAudioEngine::createStream @ 0x14005cca7
// > MultilineBitmapFont::readColorInfo @ 0x14006c87a
// > MultilineBitmapFont::readColorInfo @ 0x14006c919
// > MultilineBitmapFont::readColorInfo @ 0x14006cacc
// > MultilineBitmapFont::readColorInfo @ 0x14006cbef
// > MultilineBitmapFont::readColorInfo @ 0x14006cc89
// > MultilineBitmapFont::readColorInfo @ 0x14006ce12
// > MultilineBitmapFont::readColorInfo @ 0x14006cec2
// > ObjectManager::replaceAllOccurencesOfString @ 0x14006f68f
// > EditorUI::pasteObjects @ 0x140113659
// > GameLevelManager::onUploadCommentCompleted @ 0x14015e879
// > GJBaseGameLayer::updateLayerCapacity @ 0x14020cd70
// > GJMessagePopup::onReply @ 0x1402984f5
// > InfoLayer::init @ 0x1402bb64d
// > LevelBrowserLayer::getItemsMatchingSearch @ 0x1402cf261
// > sub_14033B0F0 @ 0x14033b158
// > sub_14033B0F0 @ 0x14033b28a
// > MusicSearchResult::getFilesMatchingSearch @ 0x140347a36
// > SFXSearchResult::updateObjects @ 0x140348110
// > SecretLayer4::onSubmit @ 0x1403f0f25
// > SongInfoLayer::init @ 0x140493372
// > ??> @ 0x1406c3e10
//
// 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_14003BCE0(__int64 a1, size_t a2, size_t a3, char *a4, size_t Size)
{
int v8; // r14d
size_t v9; // rbp
char *v10; // rbx
if ( Size > a2 || a3 > a2 - Size )
return -1;
if ( !Size )
return a3;
v8 = *a4;
v9 = a2 + a1 - Size;
v10 = (char *)memchr((const void *)(a3 + a1), v8, a2 - Size + 1 - a3);
if ( !v10 )
return -1;
while ( memcmp(v10, a4, Size) )
{
v10 = (char *)memchr(v10 + 1, v8, v9 - (_QWORD)v10);
if ( !v10 )
return -1;
}
return (__int64)&v10[-a1];
}