//
// sub_1004B55E8 from 0x1004b55e8 to 0x1004b56a4 (188 bytes)
//
// 4 xrefs:
// > sub_10044E290 @ 0x10044e2f8
// > sub_1004AAC58 @ 0x1004aac64
// > sub_1004B9970 @ 0x1004b9aa4
// > sub_1004BAE94 @ 0x1004baf9c
//
// 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 sub_1004B55E8(const char *a1, int a2, _DWORD *a3, FILE **a4)
{
FILE *v6; // x0
FILE *v7; // x21
FILE *v9; // x0
int v10; // w22
off_t v11; // x0
if ( a2 == 1 )
{
v9 = fopen(a1, "wb");
if ( !v9 )
return 18;
v7 = v9;
LABEL_9:
v10 = 0;
LABEL_10:
*a4 = v7;
*a3 = v10;
return 0;
}
if ( a2 )
{
v7 = nullptr;
goto LABEL_9;
}
v6 = fopen(a1, "rb");
if ( v6 )
{
v7 = v6;
if ( fseeko(v6, 0, 2) )
return 13;
v11 = ftello(v7);
if ( v11 < 0 )
return 13;
v10 = v11;
if ( fseeko(v7, 0, 0) )
return 13;
goto LABEL_10;
}
return 18;
}