//
// cocos2d::CCImage::initWithImageFileThreadSafe from 0x18007ccb0 to 0x18007cdca (282 bytes)
//
// 3 xrefs:
// > sub_1800A9340 @ 0x1800a94a7
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b4e54
//
// 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
//
__int64 __fastcall cocos2d::CCImage::initWithImageFileThreadSafe(
cocos2d::CCImage *this,
const char *a2,
enum cocos2d::CCImage::EImageFormat 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 *, const char *, const char *, int *))v7->addSearchResolutionsOrder)(
v7,
a2,
"rb",
&v13);
v9 = (_BYTE *)v8;
if ( v8 )
{
if ( v13 > 0 )
{
switch ( a3 )
{
case kFmtPng:
LABEL_4:
v10 = cocos2d::CCImage::_initWithPngData(this, (_QWORD *)v8, v13);
LABEL_23:
v6 = v10;
goto LABEL_24;
case kFmtJpg:
LABEL_22:
v10 = cocos2d::CCImage::_initWithJpgData(this, v9, v13);
goto LABEL_23;
case kFmtTiff:
goto LABEL_28;
}
if ( a3 != kFmtRawData )
{
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 )
{
v11 = *(_BYTE *)v8;
if ( v11 == 73 )
{
if ( v9[1] != 73 )
{
LABEL_20:
if ( v11 != -1 || v9[1] != 0xD8 )
goto LABEL_24;
goto LABEL_22;
}
}
else
{
if ( v11 != 77 )
goto LABEL_20;
if ( v9[1] != 77 )
goto LABEL_24;
}
LABEL_28:
v10 = cocos2d::CCImage::_initWithTiffData(this, v9, v13);
goto LABEL_23;
}
}
}
LABEL_24:
j_j_free_0(v9);
}
return v6;
}