//
// sub_611638 from 0x611638 to 0x611754 (284 bytes)
//
// 6 xrefs:
// > sub_611760 @ 0x61179a
// > sub_612070 @ 0x61218a
// > sub_612070 @ 0x612312
// > sub_612070 @ 0x6123c0
// > sub_612070 @ 0x6123fa
// > sub_612070 @ 0x61244e
//
// 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
//
int __fastcall sub_611638(_DWORD **a1, unsigned int a2, const char *a3, int a4, __int64 a5, _QWORD *a6)
{
__int64 v9; // r8
_DWORD *v10; // r4
int result; // r0
int v12; // r5
int v13; // r5
void *v14; // r0
_WORD v15[24]; // [sp+0h] [bp-6Ch] BYREF
__int64 v16; // [sp+30h] [bp-3Ch]
v9 = a5;
v10 = off_ABAEAC(0x10u);
result = 27;
if ( v10 )
{
*v10 = 0;
if ( a2 > 2 )
{
v10[2] = a3;
v10[1] = a2;
if ( !a6 )
goto LABEL_6;
if ( a2 != 4 )
{
*a6 += a5;
goto LABEL_6;
}
if ( !strcmp("-", a3) )
{
LABEL_6:
if ( *a1 )
{
result = 0;
**a1 = v10;
*a1 = v10;
}
else
{
*a1 = v10;
return 0;
}
return result;
}
if ( !stat(a3, (struct stat *)v15) && (v15[8] & 0xF000) != 0x4000 )
{
*a6 += v16;
goto LABEL_6;
}
goto LABEL_11;
}
if ( a5 )
{
if ( HIDWORD(a5) - ((_DWORD)a5 != -1) < 0 == __OFSUB__(HIDWORD(a5), 0, (_DWORD)a5 == -1) )
{
LABEL_11:
v12 = 43;
LABEL_12:
off_ABAEB0(v10);
return v12;
}
}
else
{
v9 = strlen(a3);
}
if ( a2 )
{
v14 = off_ABAEAC(v9 + 1);
v13 = v9;
v10[2] = v14;
if ( !v14 )
{
v12 = 27;
goto LABEL_12;
}
memcpy(v14, a3, v9);
*(_BYTE *)(v10[2] + v9) = 0;
}
else
{
v13 = v9;
a2 = 1;
v10[2] = a3;
}
v10[3] = v13;
v10[1] = a2;
if ( a6 )
*a6 += v9;
goto LABEL_6;
}
return result;
}