//
// cocos2d::CCRenderTexture::saveToFile from 0x180062750 to 0x180062942 (498 bytes)
//
// 2 xrefs:
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bd744
//
// 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:51 +0000
//
// Hidden C++ exception states: #wind=3
_BOOL8 __fastcall cocos2d::CCRenderTexture::saveToFile(cocos2d::CCRenderTexture *a1, const char *a2)
{
bool v3; // bl
cocos2d::CCImage *v4; // r14
struct cocos2d::CCFileUtils *v5; // rax
_QWORD *v6; // rdi
size_t v7; // rsi
__int64 v8; // rcx
unsigned __int64 v9; // rdx
_QWORD *v10; // rax
char *v11; // rbx
_BYTE *v12; // rcx
const char *v13; // rdx
char *v14; // r8
char *v16[2]; // [rsp+38h] [rbp-70h] BYREF
__int128 v17; // [rsp+48h] [rbp-60h]
void *Block; // [rsp+58h] [rbp-50h] BYREF
__m128i si128; // [rsp+68h] [rbp-40h]
v3 = 0;
v4 = cocos2d::CCRenderTexture::newCCImage(a1, 1);
if ( v4 )
{
v5 = cocos2d::CCFileUtils::sharedFileUtils();
v6 = (_QWORD *)(*(__int64 (__fastcall **)(struct cocos2d::CCFileUtils *, void **))(*(_QWORD *)v5 + 136LL))(
v5,
&Block);
v7 = strlen(a2);
v8 = v6[2];
v9 = v6[3];
if ( v7 > v9 - v8 )
{
v6 = sub_180007A50(v6, v7, 0, a2, v7);
}
else
{
v6[2] = v8 + v7;
v10 = v6;
if ( v9 > 0xF )
v10 = (_QWORD *)*v6;
v11 = (char *)v10 + v8;
memmove((char *)v10 + v8, a2, v7);
v11[v7] = 0;
}
*(_OWORD *)v16 = 0;
v17 = 0;
*(_OWORD *)v16 = *(_OWORD *)v6;
v17 = *((_OWORD *)v6 + 1);
v6[2] = 0;
v6[3] = 15;
*(_BYTE *)v6 = 0;
if ( si128.m128i_i64[1] > 0xFuLL )
{
v12 = Block;
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v12 = *((_BYTE **)Block - 1);
if ( (unsigned __int64)((_BYTE *)Block - v12 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v12);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_1800EC500);
LOBYTE(Block) = 0;
v13 = (const char *)v16;
if ( *((_QWORD *)&v17 + 1) > 0xFu )
v13 = v16[0];
v3 = cocos2d::CCImage::saveToFile(v4, v13, 1);
if ( *((_QWORD *)&v17 + 1) > 0xFu )
{
v14 = v16[0];
if ( (unsigned __int64)(*((_QWORD *)&v17 + 1) + 1LL) >= 0x1000 )
{
v14 = *((char **)v16[0] - 1);
if ( (unsigned __int64)(v16[0] - v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v14);
}
(*(void (__fastcall **)(cocos2d::CCImage *, __int64))(*(_QWORD *)v4 + 8LL))(v4, 1);
}
return v3;
}