//
// cocos2d::CCImage::saveToFile from 0x7ec29c to 0x7ec442 (422 bytes)
//
// 2 xrefs:
// > cocos2d::CCRenderTexture::saveToFile @ 0x7e0ef6
// > cocos2d::CCRenderTexture::saveToFile @ 0x7e1038
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:00 +0000
//
int __fastcall cocos2d::CCImage::saveToFile(cocos2d::CCImage *this, const char *a2, int a3)
{
size_t v6; // r0
unsigned int v7; // r3
unsigned __int8 *v8; // r11
unsigned int v9; // r3
unsigned __int8 *v11; // r11
unsigned int v12; // r1
unsigned __int8 *v13; // r2
char *v14; // r9
char *v15; // r3
char v16; // r0
int v17; // r0
unsigned __int8 *v18; // r10
unsigned int v19; // [sp+14h] [bp-30h]
unsigned __int8 *v20; // [sp+14h] [bp-30h]
unsigned __int8 *v21[2]; // [sp+1Ch] [bp-28h] BYREF
int v22; // [sp+24h] [bp-20h] BYREF
size_t v23; // [sp+28h] [bp-1Ch]
char *v24; // [sp+2Ch] [bp-18h]
int v25; // [sp+30h] [bp-14h] BYREF
size_t v26; // [sp+34h] [bp-10h]
unsigned __int8 *v27; // [sp+38h] [bp-Ch]
if ( !a2 )
return 0;
v22 = 0;
v23 = 0;
v24 = nullptr;
v6 = strlen(a2);
std::string::__init(&v22, a2, v6);
if ( (v22 & 1) != 0 )
{
if ( v23 <= 4 )
goto LABEL_13;
v25 = 0;
v26 = 0;
v27 = nullptr;
std::string::__init(&v25, v24, v23);
}
else
{
if ( (unsigned __int8)v22 <= 9u )
goto LABEL_13;
v25 = v22;
v26 = v23;
v27 = (unsigned __int8 *)v24;
}
v11 = (unsigned __int8 *)&v25 + 1;
v12 = 0;
while ( (v25 & 1) == 0 )
{
if ( v12 >= (int)(unsigned __int8)v25 >> 1 )
{
v7 = (int)(unsigned __int8)v25 >> 1;
goto LABEL_8;
}
v13 = (unsigned __int8 *)&v25 + 1;
LABEL_19:
v14 = (char *)&v13[v12];
v19 = v12;
if ( (v22 & 1) != 0 )
v15 = v24;
else
v15 = (char *)&v22 + 1;
v16 = tolower((unsigned __int8)v15[v12]);
v12 = v19 + 1;
*v14 = v16;
}
v7 = v26;
v13 = v27;
if ( v12 < v26 )
goto LABEL_19;
v11 = v27;
LABEL_8:
if ( v7 > 3 )
{
v20 = &v11[v7];
std::__search(
v21,
v11,
&v11[v7],
".png",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v21[0] != v20 && v21[0] - v11 != -1 )
{
v17 = cocos2d::CCImage::_saveImageToPNG(this, a2, a3);
goto LABEL_28;
}
}
if ( (v25 & 1) != 0 )
{
v8 = v27;
v9 = v26;
}
else
{
v9 = (int)(unsigned __int8)v25 >> 1;
v8 = (unsigned __int8 *)&v25 + 1;
}
if ( v9 > 3 )
{
v18 = &v8[v9];
std::__search(
v21,
v8,
&v8[v9],
".jpg",
(unsigned __int8 *)"",
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v21[0] != v18 && v21[0] - v8 != -1 )
{
v17 = cocos2d::CCImage::_saveImageToJPG(this, a2);
LABEL_28:
if ( v17 )
{
std::string::~string((int)&v25);
std::string::~string((int)&v22);
return 1;
}
}
}
std::string::~string((int)&v25);
LABEL_13:
std::string::~string((int)&v22);
return 0;
}