//
// cocos2d::CCRenderTexture::saveToFile from 0xafa4dc to 0xafa660 (388 bytes)
//
// 1 xrefs:
// > ??> @ 0x3c3d8
//
// 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
//
bool cocos2d::CCRenderTexture::saveToFile(cocos2d::CCRenderTexture *a1, const char *a2)
{
cocos2d::CCImage *v3; // x20
cocos2d::CCFileUtils *v4; // x0
size_t v5; // x0
const char **v6; // x0
const char *v7; // x22
void *v8; // x0
bool v9; // w0
char *v10; // x1
bool v11; // w24
unsigned int *v13; // x22
int v14; // w0
unsigned int *v15; // x2
int v16; // w1
__int64 v17; // [xsp+50h] [xbp+50h] BYREF
v3 = cocos2d::CCRenderTexture::newCCImage(a1, 1);
if ( !v3 )
return 0;
v4 = cocos2d::CCFileUtils::sharedFileUtils();
v4->init((cocos2d::CCFileUtils *)&v17);
v5 = strlen(a2);
v6 = (const char **)sub_D15FD4(&v17, a2, v5);
v7 = *v6;
*v6 = &byte_124B6C8;
v8 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v17 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v8);
}
v9 = cocos2d::CCImage::saveToFile(v3, v7, 1);
v10 = (char *)(v7 - 24);
v11 = v9;
if ( v7 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v7 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v7 - 2);
*((_DWORD *)v7 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v10);
}
v3->~CCImage_0(v3);
return v11;
}