//
// cocos2d::CCImage::initWithImageFile from 0x18007fcd0 to 0x18007fea3 (467 bytes)
//
// 4 xrefs:
// > cocos2d::CCTextureCache::addImage @ 0x1800ab71b
// > cocos2d::CCTextureCache::reloadTexture @ 0x1800acf9f
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bf124
//
// 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 11:22:02 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall cocos2d::CCImage::initWithImageFile(cocos2d::CCImage *a1, __int64 a2, int a3)
{
unsigned __int8 v6; // di
struct cocos2d::CCFileUtils *v7; // rax
struct cocos2d::CCFileUtils *v8; // rax
void **v9; // rdx
__int64 v10; // rax
_BYTE *v11; // rbx
unsigned __int8 v12; // al
char v13; // al
void *v14; // rcx
int v16; // [rsp+30h] [rbp-48h] BYREF
void *Block[3]; // [rsp+38h] [rbp-40h] BYREF
unsigned __int64 v18; // [rsp+50h] [rbp-28h]
v6 = 0;
v16 = 0;
v7 = cocos2d::CCFileUtils::sharedFileUtils();
(*(void (__fastcall **)(struct cocos2d::CCFileUtils *, void **, __int64, _QWORD))(*(_QWORD *)v7 + 40LL))(
v7,
Block,
a2,
0);
v8 = cocos2d::CCFileUtils::sharedFileUtils();
v9 = Block;
if ( v18 > 0xF )
v9 = (void **)Block[0];
v10 = (*(__int64 (__fastcall **)(struct cocos2d::CCFileUtils *, void **, const char *, int *))(*(_QWORD *)v8 + 24LL))(
v8,
v9,
"rb",
&v16);
v11 = (_BYTE *)v10;
if ( v10 )
{
if ( v16 <= 0 )
goto LABEL_31;
if ( a3 == 1 )
{
LABEL_6:
v12 = cocos2d::CCImage::_initWithPngData(a1, (_QWORD *)v10, v16);
LABEL_30:
v6 = v12;
goto LABEL_31;
}
if ( a3 )
{
if ( a3 == 2 )
{
v12 = cocos2d::CCImage::_initWithTiffData(a1, (void *)v10, v16);
goto LABEL_30;
}
if ( a3 == 4 )
goto LABEL_31;
if ( v16 > 8
&& *(_BYTE *)v10 == 0x89
&& *(_BYTE *)(v10 + 1) == 80
&& *(_BYTE *)(v10 + 2) == 78
&& *(_BYTE *)(v10 + 3) == 71
&& *(_BYTE *)(v10 + 4) == 13
&& *(_BYTE *)(v10 + 5) == 10
&& *(_BYTE *)(v10 + 6) == 26
&& *(_BYTE *)(v10 + 7) == 10 )
{
goto LABEL_6;
}
if ( v16 <= 2 )
goto LABEL_31;
v13 = *(_BYTE *)v10;
if ( v13 == 73 )
{
if ( v11[1] != 73 )
goto LABEL_31;
goto LABEL_26;
}
if ( v13 == 77 )
{
if ( v11[1] == 77 )
{
LABEL_26:
v12 = cocos2d::CCImage::_initWithTiffData(a1, v11, v16);
goto LABEL_30;
}
LABEL_31:
j_j_free_0(v11);
goto LABEL_32;
}
if ( v13 != -1 || v11[1] != 0xD8 )
goto LABEL_31;
}
v12 = cocos2d::CCImage::_initWithJpgData(a1, v11, v16);
goto LABEL_30;
}
LABEL_32:
if ( v18 > 0xF )
{
v14 = Block[0];
if ( v18 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free_0(v14);
}
return v6;
}