//
// sub_F3E724 from 0xf3e724 to 0xf3e9ec (712 bytes)
//
// 3 xrefs:
// > gzopen @ 0xf3e9f4
// > gzopen64 @ 0xf3ea00
// > gzdopen @ 0xf3ea54
//
// This function is hookable on this platform (idp: arm, 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 13:13:06 +0000
//
void **__fastcall sub_F3E724(const char *a1, int a2, unsigned __int8 *a3)
{
void **v5; // x0
void **v6; // x19
unsigned __int8 *v7; // x2
int v8; // w1
int v9; // w23
int v10; // w22
int v11; // t1
int v13; // t1
int v14; // w0
char *v15; // x0
__int64 v16; // x3
int v17; // w2
int v18; // w1
int v19; // w0
void *v20; // x0
__off_t v21; // x0
int v22; // w1
int v23; // w0
size_t maxlena; // [xsp+48h] [xbp+48h]
if ( !a1 )
return nullptr;
v5 = (void **)malloc(0xE8u);
v6 = v5;
if ( !v5 )
return nullptr;
v7 = a3;
*((_DWORD *)v5 + 10) = 0;
v5[14] = nullptr;
v8 = *a3;
*((_DWORD *)v5 + 11) = 0x2000;
*((_DWORD *)v5 + 6) = 0;
v5[11] = (void *)0xFFFFFFFFLL;
*((_DWORD *)v5 + 16) = 0;
if ( !v8 )
goto LABEL_10;
v9 = 0;
v10 = 0;
do
{
while ( 2 )
{
if ( (unsigned __int8)(v8 - 48) > 9u )
{
switch ( v8 )
{
case '+':
goto LABEL_10;
case 'F':
*((_DWORD *)v5 + 23) = 4;
goto LABEL_6;
case 'R':
*((_DWORD *)v5 + 23) = 3;
goto LABEL_6;
case 'T':
*((_DWORD *)v5 + 16) = 1;
goto LABEL_6;
case 'a':
*((_DWORD *)v5 + 6) = 1;
goto LABEL_6;
case 'e':
v10 = 1;
goto LABEL_6;
case 'f':
*((_DWORD *)v5 + 23) = 1;
goto LABEL_6;
case 'h':
*((_DWORD *)v5 + 23) = 2;
goto LABEL_6;
case 'r':
*((_DWORD *)v5 + 6) = 7247;
goto LABEL_6;
case 'w':
v13 = *++v7;
v8 = v13;
*((_DWORD *)v5 + 6) = 31153;
if ( !v13 )
goto LABEL_13;
continue;
case 'x':
v9 = 1;
goto LABEL_6;
default:
goto LABEL_6;
}
}
break;
}
*((_DWORD *)v5 + 22) = v8 - 48;
LABEL_6:
v11 = *++v7;
v8 = v11;
}
while ( v11 );
LABEL_13:
v14 = *((_DWORD *)v5 + 6);
if ( !v14 )
{
LABEL_10:
free(v6);
return nullptr;
}
if ( v14 == 7247 )
{
if ( *((_DWORD *)v6 + 16) )
goto LABEL_10;
*((_DWORD *)v6 + 16) = 1;
}
maxlena = strlen(a1) + 1;
v15 = (char *)malloc(maxlena);
v6[4] = v15;
if ( !v15 )
goto LABEL_10;
snprintf(v15, maxlena, "%s", a1);
v17 = *((_DWORD *)v6 + 6);
if ( v10 )
v18 = 655360;
else
v18 = 0x20000;
if ( v17 != 7247 )
{
if ( v9 )
v16 = 705;
else
v16 = 577;
if ( v9 )
v19 = 1217;
else
v19 = 1089;
if ( v17 == 31153 )
v19 = v16;
v18 |= v19;
}
if ( (a2 & 0x80000000) == 0 )
{
*((_DWORD *)v6 + 7) = a2;
goto LABEL_33;
}
v23 = open(a1, v18, 438, v16);
*((_DWORD *)v6 + 7) = v23;
a2 = v23;
if ( v23 == -1 )
{
free(v6[4]);
goto LABEL_10;
}
v17 = *((_DWORD *)v6 + 6);
LABEL_33:
if ( v17 == 1 )
{
*((_DWORD *)v6 + 6) = 31153;
}
else if ( v17 == 7247 )
{
v21 = lseek(a2, 0, 1);
v6[9] = (void *)v21;
v22 = *((_DWORD *)v6 + 6);
if ( v21 == -1 )
v6[9] = nullptr;
*(_DWORD *)v6 = 0;
if ( v22 == 7247 )
{
*((_DWORD *)v6 + 20) = 0;
*((_DWORD *)v6 + 21) = 0;
*((_DWORD *)v6 + 17) = 0;
}
goto LABEL_36;
}
*(_DWORD *)v6 = 0;
LABEL_36:
v20 = v6[14];
*((_DWORD *)v6 + 26) = 0;
if ( v20 )
{
if ( *((_DWORD *)v6 + 27) != -4 )
free(v20);
v6[14] = nullptr;
}
*((_DWORD *)v6 + 27) = 0;
v6[2] = nullptr;
*((_DWORD *)v6 + 32) = 0;
return v6;
}