//
// cocos2d::CCImage::initWithImageFileThreadSafe from 0x18007feb0 to 0x18007ffca (282 bytes)
//
// 3 xrefs:
// > sub_1800ACB60 @ 0x1800acc8f
// > ??> @ 0x18014cf68
// > ??> @ 0x1801bf130
//
// 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
//
__int64 __fastcall cocos2d::CCImage::initWithImageFileThreadSafe(cocos2d::CCImage *a1, __int64 a2, int a3)
{
unsigned __int8 v6; // di
struct cocos2d::CCFileUtils *v7; // rax
__int64 v8; // rax
_BYTE *v9; // rbx
unsigned __int8 v10; // al
char v11; // al
int v13; // [rsp+48h] [rbp+20h] BYREF
v13 = 0;
v6 = 0;
v7 = cocos2d::CCFileUtils::sharedFileUtils();
v8 = (*(__int64 (__fastcall **)(struct cocos2d::CCFileUtils *, __int64, const char *, int *))(*(_QWORD *)v7 + 24LL))(
v7,
a2,
"rb",
&v13);
v9 = (_BYTE *)v8;
if ( v8 )
{
if ( v13 <= 0 )
goto LABEL_28;
if ( a3 == 1 )
{
LABEL_4:
v10 = cocos2d::CCImage::_initWithPngData(a1, (_QWORD *)v8, v13);
LABEL_27:
v6 = v10;
goto LABEL_28;
}
if ( a3 )
{
if ( a3 == 2 )
{
LABEL_23:
v10 = cocos2d::CCImage::_initWithTiffData(a1, v9, v13);
goto LABEL_27;
}
if ( a3 == 4 )
goto LABEL_28;
if ( v13 > 8
&& *(_BYTE *)v8 == 0x89
&& *(_BYTE *)(v8 + 1) == 80
&& *(_BYTE *)(v8 + 2) == 78
&& *(_BYTE *)(v8 + 3) == 71
&& *(_BYTE *)(v8 + 4) == 13
&& *(_BYTE *)(v8 + 5) == 10
&& *(_BYTE *)(v8 + 6) == 26
&& *(_BYTE *)(v8 + 7) == 10 )
{
goto LABEL_4;
}
if ( v13 <= 2 )
{
LABEL_28:
j_j_free_0(v9);
return v6;
}
v11 = *(_BYTE *)v8;
if ( v11 == 73 )
{
if ( v9[1] != 73 )
goto LABEL_28;
goto LABEL_23;
}
if ( v11 == 77 )
{
if ( v9[1] == 77 )
goto LABEL_23;
goto LABEL_28;
}
if ( v11 != -1 || v9[1] != 0xD8 )
goto LABEL_28;
}
v10 = cocos2d::CCImage::_initWithJpgData(a1, v9, v13);
goto LABEL_27;
}
return v6;
}