//
// sub_D1641C from 0xd1641c to 0xd164d8 (188 bytes)
//
// 100 xrefs:
// > PlatformToolbox::spriteFromSavedFile @ 0x4ecee0
// > FontObject::parseConfigFile @ 0x56ae84
// > CCAnimateFrameCache::addCustomSpriteFramesWithFile @ 0x573b58
// > sub_58820C @ 0x5882b8
// > MultilineBitmapFont::readColorInfo @ 0x58a220
// > MultilineBitmapFont::readColorInfo @ 0x58a2b0
// > MultilineBitmapFont::readColorInfo @ 0x58a3c0
// > MultilineBitmapFont::readColorInfo @ 0x58a3e0
// > MultilineBitmapFont::readColorInfo @ 0x58a490
// > MultilineBitmapFont::readColorInfo @ 0x58a5d4
// > MultilineBitmapFont::readColorInfo @ 0x58a6d8
// > MultilineBitmapFont::readColorInfo @ 0x58a8a0
// > sub_58B5D4 @ 0x58b62c
// > ObjectManager::setup @ 0x58b990
// > sub_595654 @ 0x595700
// > CCTextInputNode::onTextFieldDetachWithIME @ 0x5a3f38
// > CCTextInputNode::onTextFieldDetachWithIME @ 0x5a401c
// > CCTextInputNode::onTextFieldInsertText @ 0x5a4804
// > FMODAudioEngine::createStream @ 0x5abee0
// > FMODAudioEngine::preloadMusic @ 0x5b65f0
// > CommentCell::loadFromComment @ 0x61703c
// > sub_642030 @ 0x6420dc
// > EditorUI::pasteObjects @ 0x6bf264
// > ShareLevelLayer::init @ 0x6e46bc
// > LevelBrowserLayer::getItemsMatchingSearch @ 0x6e98b0
// > GameLevelManager::onUploadCommentCompleted @ 0x6f9384
// > AnimatedGameObject::displayFrameChanged @ 0x7530b4
// > SongInfoLayer::init @ 0x7dfb14
// > InfoLayer::init @ 0x7e4c60
// > sub_8265A8 @ 0x826600
// > sub_827328 @ 0x827390
// > sub_827328 @ 0x827438
// > MusicSearchResult::getFilesMatchingSearch @ 0x82e8d0
// > SFXSearchResult::updateObjects @ 0x8328dc
// > sub_856530 @ 0x8565dc
// > GJBaseGameLayer::updateLayerCapacity @ 0x86d100
// > FriendRequestPopup::loadFromGJFriendRequest @ 0x8ccbc0
// > GJMessagePopup::onReply @ 0x8d0e60
// > SecretLayer::onSubmit @ 0x904280
// > GauntletLayer::setupGauntlet @ 0x91e51c
// > sub_934CB4 @ 0x934d60
// > SecretLayer2::onSubmit @ 0x943290
// > SecretLayer4::onSubmit @ 0x9492c0
// > GJMultiplayerManager::ProcessHttpRequest @ 0x980fa8
// > ShareListLayer::init @ 0xa79940
// > SecretGame01Layer::resetGame @ 0xa942b0
// > cocos2d::extension::AssetsManager::update @ 0xa976b0
// > cocos2d::extension::WebSocket::init @ 0xaade24
// > cocos2d::extension::WebSocket::init @ 0xaade6c
// > cocos2d::extension::WebSocket::init @ 0xaadebc
// > cocos2d::extension::WebSocket::init @ 0xaadf24
// > cocos2d::extension::WebSocket::init @ 0xaadf9c
// > sub_AD18EC @ 0xad1b44
// > cocos2d::CCBMFontConfiguration::parseInfoArguments @ 0xae3378
// > cocos2d::CCBMFontConfiguration::parseCommonArguments @ 0xae34c4
// > cocos2d::CCBMFontConfiguration::parseCommonArguments @ 0xae3534
// > cocos2d::CCBMFontConfiguration::parseCommonArguments @ 0xae35bc
// > cocos2d::CCBMFontConfiguration::parseCommonArguments @ 0xae363c
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae388c
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae38fc
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3990
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3a1c
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3aa8
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3b34
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3bc0
// > cocos2d::CCBMFontConfiguration::parseCharacterDefinition @ 0xae3c4c
// > cocos2d::CCBMFontConfiguration::parseKerningEntry @ 0xae3fc0
// > cocos2d::CCBMFontConfiguration::parseKerningEntry @ 0xae4030
// > cocos2d::CCBMFontConfiguration::parseKerningEntry @ 0xae40c4
// > cocos2d::CCFileUtils::addSuffix @ 0xb043b8
// > cocos2d::CCFileUtilsAndroid::isAbsolutePath @ 0xb0b10c
// > cocos2d::CCFileUtilsAndroid::isFileExist @ 0xb0b31c
// > cocos2d::CCImage::saveToFile @ 0xb0d1f4
// > cocos2d::CCImage::saveToFile @ 0xb0d294
// > cocos2d::CCImage::initWithString @ 0xb0d4cc
// > cocos2d::CCImage::initWithStringShadowStroke @ 0xb0d900
// > cocos2d::CCTextureCache::addImage @ 0xb35108
// > cocos2d::CCTextureCache::addImage @ 0xb351a8
// > cocos2d::CCTextureCache::addImage @ 0xb3527c
// > cocos2d::CCTextureCache::addImage @ 0xb3535c
// > cocos2d::CCTextureCache::addImage @ 0xb35384
// > cocos2d::CCTextureCache::addImage @ 0xb353a4
// > cocos2d::CCTextureCache::addImage @ 0xb353d0
// > cocos2d::CCTextureCache::addImage @ 0xb353f4
// > cocos2d::VolatileTexture::reloadAllTextures @ 0xb35c20
// > std::deque>::_M_push_back_aux @ 0xb35ff0
// > std::deque>::_M_push_back_aux @ 0xb36050
// > std::deque>::_M_push_back_aux @ 0xb36070
// > std::deque>::_M_push_back_aux @ 0xb36098
// > std::deque>::_M_push_back_aux @ 0xb360b8
// > std::deque>::_M_push_back_aux @ 0xb360e0
// > std::deque>::_M_push_back_aux @ 0xb36100
// > std::deque>::_M_push_back_aux @ 0xb362dc
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xb37c70
// > cocos2d::CCTexturePVR::initWithContentsOfFile @ 0xb37dc8
// > sub_B41824 @ 0xb418d0
// > DS_Dictionary::split @ 0xb47090
// > DS_Dictionary::addBoolValuesToMapForKeySpecial @ 0xb49a10
// > DS_Dictionary::addBoolValuesToMapForKeySpecial @ 0xb49ac0
// > DS_Dictionary::addBoolValuesToMapForKeySpecial @ 0xb49ae0
//
// 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
//
unsigned __int64 __fastcall sub_D1641C(__int64 *a1, char *a2, unsigned __int64 a3, unsigned __int64 a4)
{
__int64 v4; // x21
unsigned __int64 v5; // x20
__int64 v6; // x19
unsigned __int64 v8; // x22
unsigned __int64 v9; // x20
size_t v10; // x23
char *v11; // x24
int v12; // w25
unsigned __int64 v13; // x2
int v14; // w0
v4 = *a1;
v5 = *(_QWORD *)(*a1 - 24);
if ( a4 )
{
v6 = -1;
if ( a4 <= v5 )
{
v8 = v5 - a4;
if ( a3 <= v5 - a4 )
{
v9 = a3 + 1;
v6 = a3;
v10 = a4 - 1;
v11 = a2 + 1;
v12 = (unsigned __int8)*a2;
while ( 1 )
{
v13 = v9;
if ( *(unsigned __int8 *)(v4 + v6) == v12 )
{
v14 = memcmp((const void *)(v4 + v9), v11, v10);
v13 = v9;
if ( !v14 )
break;
}
++v9;
++v6;
if ( v13 > v8 )
return -1;
}
}
}
}
else if ( a3 > v5 )
{
return -1;
}
else
{
return a3;
}
return v6;
}