//
// sub_180007900 from 0x180007900 to 0x180007a8b (395 bytes)
//
// 62 xrefs:
// > sub_180007CF0 @ 0x180007d63
// > cocos2d::CCPrettyPrinter::setIndentLevel @ 0x180007f5f
// > cocos2d::CCPrettyPrinter::visit @ 0x18000800f
// > cocos2d::CCPrettyPrinter::visit @ 0x180008083
// > cocos2d::CCPrettyPrinter::visit @ 0x180008141
// > cocos2d::CCPrettyPrinter::visit @ 0x1800081cf
// > cocos2d::CCPrettyPrinter::visit @ 0x18000826c
// > cocos2d::CCPrettyPrinter::visit @ 0x180008360
// > cocos2d::CCPrettyPrinter::visit @ 0x1800083d6
// > cocos2d::CCPrettyPrinter::visit @ 0x1800084f8
// > cocos2d::CCPrettyPrinter::visit @ 0x180008597
// > cocos2d::CCPrettyPrinter::visit @ 0x180008618
// > cocos2d::CCPrettyPrinter::visit @ 0x1800086f8
// > cocos2d::CCPrettyPrinter::visit @ 0x18000879f
// > cocos2d::CCPrettyPrinter::visit @ 0x180008a07
// > cocos2d::CCPrettyPrinter::visit @ 0x180008a77
// > cocos2d::CCPrettyPrinter::visit @ 0x180008afd
// > cocos2d::CCPrettyPrinter::visit @ 0x180008bf7
// > cocos2d::CCPrettyPrinter::visit @ 0x180008cda
// > cocos2d::CCPrettyPrinter::visit @ 0x180008dce
// > cocos2d::CCPrettyPrinter::visit @ 0x180008e75
// > cocos2d::CCPrettyPrinter::visit @ 0x180008ef2
// > cocos2d::CCPrettyPrinter::visit @ 0x180008f8c
// > cocos2d::CCPrettyPrinter::visit @ 0x18000905c
// > cocos2d::CCPrettyPrinter::visit @ 0x180009329
// > cocos2d::CCPrettyPrinter::visit @ 0x1800093a9
// > cocos2d::CCPrettyPrinter::visitObject @ 0x1800094fd
// > cocos2d::CCDictionary::getFirstKey @ 0x18000a3e7
// > DS_Dictionary::copyFile @ 0x18001951e
// > DS_Dictionary::copyFile @ 0x1800196c1
// > DS_Dictionary::loadRootSubDictFromCompressedFile @ 0x18001bb1b
// > DS_Dictionary::loadRootSubDictFromFile @ 0x18001beca
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x18001d4bd
// > DS_Dictionary::saveRootSubDictToFile @ 0x18001dcb1
// > cocos2d::CCLabelAtlas::initWithString @ 0x180045f26
// > cocos2d::CCRenderTexture::saveToFile @ 0x1800605e9
// > sub_180065350 @ 0x1800653d6
// > cocos2d::CCFileUtils::addSearchPath @ 0x18006d929
// > cocos2d::CCFileUtils::addSuffix @ 0x18006df9f
// > cocos2d::CCFileUtils::getFileData @ 0x18006ff7c
// > cocos2d::CCFileUtils::getFileData @ 0x18006ffdf
// > cocos2d::CCFileUtils::removeSearchPath @ 0x180070f45
// > cocos2d::CCFileUtils::setSearchPaths @ 0x1800714a8
// > cocos2d::CCFileUtils::setSearchResolutionsOrder @ 0x18007183a
// > cocos2d::CCFileUtilsWin32::getWritablePath @ 0x18007a823
// > cocos2d::CCFileUtilsWin32::getWritablePath @ 0x18007a958
// > cocos2d::CCSpriteFrameCache::addSpriteFramesWithFile @ 0x180091735
// > cocos2d::CCUserDefault::initXMLFilePath @ 0x18009f040
// > cocos2d::CCUserDefault::initXMLFilePath @ 0x18009f0ed
// > cocos2d::ZipUtils::base64DecodeEnc @ 0x1800a2d13
// > cocos2d::ZipUtils::base64EncodeEnc @ 0x1800a2f4d
// > cocos2d::ZipUtils::base64URLDecode @ 0x1800a3146
// > cocos2d::ZipUtils::base64URLEncode @ 0x1800a3276
// > cocos2d::ZipUtils::compressString @ 0x1800a3c69
// > cocos2d::ZipUtils::compressString @ 0x1800a3cc7
// > cocos2d::CCTMXMapInfo::textHandler @ 0x1800b2448
// > cocos2d::CCTextFieldTTF::insertText @ 0x1800b5c67
// > cocos2d::CCTextFieldTTF::setString @ 0x1800b6131
// > ??> @ 0x180131ad8
// > ??> @ 0x180131ae8
// > ??> @ 0x180131b08
// > ??> @ 0x1801adb04
//
// 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
//
_QWORD *__fastcall sub_180007900(_QWORD *Src, unsigned __int64 a2, __int64 a3, const void *a4, size_t Size)
{
size_t v5; // r14
__int64 v6; // rbx
size_t v9; // rbp
unsigned __int64 v10; // rdx
unsigned __int64 v11; // r13
__int64 v12; // rcx
size_t v13; // rcx
void *v14; // rax
_QWORD *v15; // rdi
char *v16; // r15
_QWORD *v17; // rbx
v5 = Src[2];
v6 = 0x7FFFFFFFFFFFFFFFLL;
if ( 0x7FFFFFFFFFFFFFFFLL - v5 < a2 )
std::vector::_Xlen();
v9 = v5 + a2;
v10 = (v5 + a2) | 0xF;
v11 = Src[3];
if ( v10 > 0x7FFFFFFFFFFFFFFFLL || (v12 = v11 >> 1, v11 > 0x7FFFFFFFFFFFFFFFLL - (v11 >> 1)) )
{
v13 = 0x8000000000000027uLL;
}
else
{
v6 = v10;
if ( v10 < v12 + v11 )
v6 = v12 + v11;
if ( (unsigned __int64)(v6 + 1) < 0x1000 )
{
if ( v6 == -1 )
v15 = nullptr;
else
v15 = operator new(v6 + 1);
goto LABEL_15;
}
v13 = v6 + 40;
if ( v6 + 40 < (unsigned __int64)(v6 + 1) )
Concurrency::cancel_current_task();
}
v14 = operator new(v13);
if ( !v14 )
goto LABEL_20;
v15 = (_QWORD *)(((unsigned __int64)v14 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*(v15 - 1) = v14;
LABEL_15:
Src[2] = v9;
v16 = (char *)v15 + v5;
Src[3] = v6;
if ( v11 <= 0xF )
{
memcpy(v15, Src, v5);
memcpy((char *)v15 + v5, a4, Size);
v16[Size] = 0;
goto LABEL_22;
}
v17 = (_QWORD *)*Src;
memcpy(v15, (const void *)*Src, v5);
memcpy((char *)v15 + v5, a4, Size);
v16[Size] = 0;
if ( v11 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v17 - *(v17 - 1) - 8 <= 0x1F )
{
v17 = (_QWORD *)*(v17 - 1);
goto LABEL_19;
}
LABEL_20:
invalid_parameter_noinfo_noreturn();
}
LABEL_19:
j_j_free_0(v17);
LABEL_22:
*Src = v15;
return Src;
}