//
// cocos2d::CCImage::initWithImageFile from 0x10047ee40 to 0x10047f024 (484 bytes)
//
// 2 xrefs:
// > cocos2d::CCTextureCache::addImage @ 0x1006c1022
// > cocos2d::CCTextureCache::reloadTexture @ 0x1006c1c96
//
// 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 12:30:39 +0000
//
__int64 __fastcall cocos2d::CCImage::initWithImageFile(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 v5; // rax
std::string::pointer data; // r15
const char *v7; // rdi
signed __int64 v8; // rsi
std::string::pointer v9; // rax
std::string::size_type size; // rdx
const char *v11; // rcx
char *v12; // rsi
const char *v13; // r8
char *v14; // rdx
__int64 v15; // rax
void *v16; // r15
unsigned int v17; // ebx
stat v19; // [rsp+10h] [rbp-C0h] BYREF
std::string v20; // [rsp+A0h] [rbp-30h] BYREF
v5 = cocos2d::CCFileUtils::sharedFileUtils(a1, a2);
(*(void (__fastcall **)(std::string *, __int64, __int64, _QWORD))(*(_QWORD *)v5 + 48LL))(&v20, v5, a2, 0);
data = v20.__r_.__value_.__s.__data_;
v7 = v20.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) != 0 )
v7 = v20.__r_.__value_.__l.__data_;
v8 = (signed __int64)&v19;
if ( stat_INODE64(v7, &v19) || v19.st_mode <= 0xFFFu )
{
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) != 0 )
{
v9 = v20.__r_.__value_.__l.__data_;
size = v20.__r_.__value_.__l.__size_;
if ( !v20.__r_.__value_.__l.__size_ )
goto LABEL_31;
}
else
{
size = *(_BYTE *)&v20.__r_.__value_.__l.0 >> 1;
v9 = v20.__r_.__value_.__s.__data_;
if ( !(*(_BYTE *)&v20.__r_.__value_.__l.0 >> 1) )
goto LABEL_31;
}
v11 = &v9[size];
v7 = v9;
v12 = &v9[size];
while ( 1 )
{
v13 = v7 + 2;
while ( 1 )
{
v7 = v13 - 1;
if ( *(v13 - 2) == 64 )
break;
++v13;
if ( v7 == v11 )
goto LABEL_20;
}
if ( v7 == v11 )
break;
if ( *v7 == 50 )
{
if ( v13 == v11 )
break;
v7 = v13 - 1;
if ( *v13 == 120 )
v12 = (char *)(v13 - 2);
}
}
LABEL_20:
LOBYTE(v7) = v12 != v11;
v8 = v12 - v9;
LOBYTE(v8) = v8 != -1;
if ( ((unsigned __int8)v8 & (unsigned __int8)v7) == 0 && size )
{
v7 = v9;
v14 = &v9[size];
do
{
v8 = (signed __int64)v7;
while ( 1 )
{
v7 = (const char *)(v8 + 1);
if ( *(_BYTE *)v8 == 46 )
break;
++v8;
if ( v7 == v11 )
{
v8 = (signed __int64)v14;
goto LABEL_28;
}
}
v14 = (char *)v8;
}
while ( v7 != v11 );
LABEL_28:
if ( (const char *)v8 != v11 )
{
v8 = (unsigned __int64)(unsigned int)(v8 - (_DWORD)v9) << 32;
if ( v8 != 0xFFFFFFFF00000000LL )
{
v8 >>= 32;
v7 = (const char *)&v20;
std::string::insert(&v20, v8, "@2x");
}
}
}
}
LABEL_31:
*(_QWORD *)&v19.st_dev = 0;
v15 = cocos2d::CCFileUtils::sharedFileUtils(v7, v8);
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) != 0 )
data = v20.__r_.__value_.__l.__data_;
v16 = (void *)(*(__int64 (__fastcall **)(__int64, std::string::pointer, const char *, stat *))(*(_QWORD *)v15 + 32LL))(
v15,
data,
"rb",
&v19);
v17 = cocos2d::CCImage::initWithImageData(a1, v16, (unsigned int)v19.st_dev, a3, 0, 0, 8);
if ( v16 )
operator delete[](v16);
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v20.__r_.__value_.__l.__data_);
return v17;
}