//
// sub_180007A50 from 0x180007a50 to 0x180007bf3 (419 bytes)
//
// 39 xrefs:
// > sub_180007DF0 @ 0x180007e63
// > cocos2d::CCPrettyPrinter::setIndentLevel @ 0x180008080
// > cocos2d::CCPrettyPrinter::visit @ 0x180008138
// > cocos2d::CCPrettyPrinter::visit @ 0x1800081ad
// > cocos2d::CCPrettyPrinter::visit @ 0x180008275
// > cocos2d::CCPrettyPrinter::visit @ 0x1800082fb
// > cocos2d::CCPrettyPrinter::visit @ 0x1800083a0
// > cocos2d::CCPrettyPrinter::visit @ 0x180008531
// > cocos2d::CCPrettyPrinter::visit @ 0x1800085a8
// > cocos2d::CCPrettyPrinter::visit @ 0x18000869d
// > cocos2d::CCPrettyPrinter::visit @ 0x18000874e
// > cocos2d::CCPrettyPrinter::visit @ 0x1800087cc
// > cocos2d::CCPrettyPrinter::visit @ 0x1800088ad
// > cocos2d::CCPrettyPrinter::visit @ 0x180008963
// > cocos2d::CCPrettyPrinter::visit @ 0x180008ade
// > cocos2d::CCPrettyPrinter::visit @ 0x180008b6b
// > cocos2d::CCPrettyPrinter::visit @ 0x180008bec
// > cocos2d::CCPrettyPrinter::visit @ 0x180008ce1
// > cocos2d::CCPrettyPrinter::visit @ 0x180008dc4
// > cocos2d::CCPrettyPrinter::visit @ 0x180008e9b
// > cocos2d::CCPrettyPrinter::visit @ 0x180008f4c
// > cocos2d::CCPrettyPrinter::visit @ 0x180008fca
// > cocos2d::CCPrettyPrinter::visit @ 0x180009072
// > cocos2d::CCPrettyPrinter::visit @ 0x18000912e
// > cocos2d::CCPrettyPrinter::visit @ 0x18000940e
// > cocos2d::CCPrettyPrinter::visit @ 0x18000948f
// > cocos2d::CCPrettyPrinter::visitObject @ 0x1800095ba
// > cocos2d::CCDictionary::getFirstKey @ 0x18000a4ce
// > cocos2d::CCLabelAtlas::initWithString @ 0x180047661
// > cocos2d::CCRenderTexture::saveToFile @ 0x180062801
// > sub_180067790 @ 0x180067816
// > cocos2d::CCUserDefault::initXMLFilePath @ 0x1800a2d19
// > cocos2d::CCUserDefault::initXMLFilePath @ 0x1800a2dc8
// > cocos2d::CCTextFieldTTF::insertText @ 0x1800b98d0
// > cocos2d::CCTextFieldTTF::setString @ 0x1800b9d0f
// > ??> @ 0x18013a8e8
// > ??> @ 0x18013a8f8
// > ??> @ 0x18013a918
// > ??> @ 0x1801b7b28
//
// 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:21:18 +0000
//
_QWORD *__fastcall sub_180007A50(_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; // r12
unsigned __int64 v12; // rcx
size_t v13; // rcx
_QWORD *v14; // rdi
size_t v15; // rax
__int64 v16; // rax
char *v17; // r15
_QWORD *v18; // 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)) )
{
v15 = 0x8000000000000027uLL;
}
else
{
v6 = v10;
if ( v10 < v11 + v12 )
v6 = v11 + v12;
v13 = v6 + 1;
if ( v6 == -1 )
{
v14 = nullptr;
goto LABEL_15;
}
if ( v13 < 0x1000 )
{
v14 = (_QWORD *)sub_1800E4AC0(v13);
goto LABEL_15;
}
v15 = v6 + 40;
if ( v6 + 40 < (unsigned __int64)(v6 + 1) )
Concurrency::cancel_current_task();
}
v16 = sub_1800E4AC0(v15);
if ( !v16 )
goto LABEL_20;
v14 = (_QWORD *)((v16 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*(v14 - 1) = v16;
LABEL_15:
Src[2] = v9;
v17 = (char *)v14 + v5;
Src[3] = v6;
if ( v11 <= 0xF )
{
memcpy(v14, Src, v5);
memcpy((char *)v14 + v5, a4, Size);
v17[Size] = 0;
goto LABEL_22;
}
v18 = (_QWORD *)*Src;
memcpy(v14, (const void *)*Src, v5);
memcpy((char *)v14 + v5, a4, Size);
v17[Size] = 0;
if ( v11 + 1 >= 0x1000 )
{
if ( (unsigned __int64)v18 - *(v18 - 1) - 8 <= 0x1F )
{
v18 = (_QWORD *)*(v18 - 1);
goto LABEL_19;
}
LABEL_20:
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
LABEL_19:
j_j_free_0(v18);
LABEL_22:
*Src = v14;
return Src;
}