//
// cocos2d::CCTextureCache::addETCImage from 0xda6068 to 0xda6310 (680 bytes)
//
// 2 xrefs:
// > cocos2d::CCTextureCache::addImage @ 0xda804c
// > ??> @ 0x87910
//
// This function is hookable on this platform (idp: arm, 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 13:08:32 +0000
//
__int64 __fastcall cocos2d::CCTextureCache::addETCImage(cocos2d::CCTextureCache *this, const char *a2)
{
size_t v3; // x0
size_t v4; // x19
const char *v5; // x1
char *v6; // x3
const char *v7; // x26
__int64 v8; // x25
size_t v9; // x0
size_t v10; // x19
char *v11; // x3
__int64 v12; // x19
cocos2d::CCFileUtils *v13; // x0
unsigned __int64 v15; // x0
cocos2d::CCFileUtils *v16; // x21
char *v17; // x0
unsigned __int64 v18; // x0
__int64 v19; // x21
char *v20; // x0
__int64 v21; // x0
char *v22; // x1
cocos2d::CCTexture2D *v23; // x25
char *v24; // x1
const char *v25; // x1
__int64 v26; // x19
size_t v27; // x0
char *v29; // [xsp+58h] [xbp+58h]
__int64 v30; // [xsp+60h] [xbp+60h] BYREF
size_t v31; // [xsp+68h] [xbp+68h]
void *v32; // [xsp+70h] [xbp+70h]
char *v33[2]; // [xsp+78h] [xbp+78h] BYREF
char *v34; // [xsp+88h] [xbp+88h]
cocos2d::CCFileUtils *v35; // [xsp+90h] [xbp+90h] BYREF
size_t v36; // [xsp+98h] [xbp+98h]
void *v37; // [xsp+A0h] [xbp+A0h]
v30 = 0;
v31 = 0;
v32 = nullptr;
v3 = strlen(a2);
v4 = v3;
v5 = a2;
if ( v3 > 0x16 )
{
v18 = (v3 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v19 = v18 | 1;
v20 = (char *)operator new(v18);
v30 = v19;
v5 = a2;
v6 = v20;
v32 = v20;
v31 = v4;
}
else
{
LOBYTE(v30) = 2 * v3;
v6 = (char *)&v30 + 1;
if ( !v3 )
goto LABEL_3;
}
v6 = (char *)memcpy(v6, v5, v4);
LABEL_3:
v6[v4] = 0;
v7 = (char *)&v30 + 1;
v8 = *((_QWORD *)this + 7);
if ( (v30 & 1) != 0 )
v7 = (const char *)v32;
v35 = nullptr;
v36 = 0;
v37 = nullptr;
v9 = strlen(v7);
v10 = v9;
if ( v9 > 0x16 )
{
v15 = (v9 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v16 = (cocos2d::CCFileUtils *)(v15 | 1);
v17 = (char *)operator new(v15);
v35 = v16;
v11 = v17;
v37 = v17;
v36 = v10;
LABEL_13:
*((_BYTE *)memcpy(v11, v7, v10) + v10) = 0;
v12 = cocos2d::CCDictionary::objectForKey(v8, (__int64)&v35);
v13 = (cocos2d::CCFileUtils *)(unsigned __int8)v35;
if ( ((unsigned __int8)v35 & 1) == 0 )
goto LABEL_8;
goto LABEL_14;
}
LOBYTE(v35) = 2 * v9;
v11 = (char *)&v35 + 1;
if ( v9 )
goto LABEL_13;
BYTE1(v35) = 0;
v12 = cocos2d::CCDictionary::objectForKey(v8, (__int64)&v35);
v13 = (cocos2d::CCFileUtils *)(unsigned __int8)v35;
if ( ((unsigned __int8)v35 & 1) == 0 )
goto LABEL_8;
LABEL_14:
operator delete(v37);
LABEL_8:
if ( !v12 )
{
v21 = cocos2d::CCFileUtils::sharedFileUtils(v13);
v22 = (char *)&v30 + 1;
if ( (v30 & 1) != 0 )
v22 = (char *)v32;
(*(void (__fastcall **)(char **__return_ptr, __int64, char *, _QWORD))(*(_QWORD *)v21 + 48LL))(v33, v21, v22, 0);
v23 = (cocos2d::CCTexture2D *)operator new(0x68u);
cocos2d::CCTexture2D::CCTexture2D(v23);
v24 = (char *)v33 + 1;
if ( ((__int64)v33[0] & 1) != 0 )
v24 = v34;
if ( (unsigned __int8)cocos2d::CCTexture2D::initWithETCFile(v23, v24) )
{
v25 = (char *)&v30 + 1;
v26 = *((_QWORD *)this + 7);
if ( (v30 & 1) != 0 )
v25 = (const char *)v32;
v29 = (char *)v25;
v35 = nullptr;
v36 = 0;
v37 = nullptr;
v27 = strlen(v25);
std::string::__init((__int64 *)&v35, v29, v27);
cocos2d::CCDictionary::setObject(v26, v23, (__int64)&v35);
if ( ((unsigned __int8)v35 & 1) != 0 )
operator delete(v37);
v12 = (__int64)v23;
cocos2d::CCObject::autorelease(v23);
}
else
{
(*(void (__fastcall **)(cocos2d::CCTexture2D *))(*(_QWORD *)v23 + 16LL))(v23);
}
if ( ((__int64)v33[0] & 1) != 0 )
operator delete(v34);
}
if ( (v30 & 1) != 0 )
operator delete(v32);
return v12;
}