//
// convert_to_stat_mode from 0x180129504 to 0x18012963f (315 bytes)
//
// 3 xrefs:
// > common_stat<_stat64i32> @ 0x1801291ad
// > common_stat_handle_file_opened<_stat64i32> @ 0x1801292bd
// > ??> @ 0x180202a98
//
// 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
//
unsigned __int16 __fastcall convert_to_stat_mode(__int16 a1, const wchar_t *a2)
{
char v2; // di
bool v5; // zf
char v6; // dl
const wchar_t *v7; // rcx
__int16 v8; // ax
unsigned __int16 v9; // bx
wchar_t *v10; // rax
const wchar_t *v11; // rsi
unsigned __int16 v12; // ax
v2 = 1;
if ( (a1 & 0x10) != 0 )
goto LABEL_15;
if ( !a2 )
goto LABEL_14;
if ( (unsigned __int16)(*a2 - 65) > 0x19u && (*a2 < 0x61u || *a2 > 0x7Au) || (v5 = a2[1] == 58, v6 = 1, !v5) )
v6 = 0;
v7 = a2;
if ( v6 )
v7 = a2 + 2;
if ( !*v7 || (*v7 == 92 || *v7 == 47) && !v7[1] )
LABEL_15:
v8 = 16704;
else
LABEL_14:
v8 = -32512;
v9 = v8 | ~(a1 << 7) & 0x80;
if ( !a2
|| (v10 = wcsrchr(a2, 0x2Eu), (v11 = v10) == nullptr)
|| wcsicmp(v10, L".exe") && wcsicmp(v11, L".cmd") && wcsicmp(v11, L".bat") && wcsicmp(v11, L".com") )
{
v2 = 0;
}
v12 = v9 | 0x40;
if ( !v2 )
v12 = v9;
return v12 | (v12 >> 3) & 0x38 | ((unsigned __int16)(v12 | (v12 >> 3) & 0x38) >> 6) & 7;
}