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