//
// sub_F41540 from 0xf41540 to 0xf415fc (188 bytes)
//
// 3 xrefs:
// > sub_F417B8 @ 0xf417ec
// > sub_F417B8 @ 0xf41818
// > sub_F41864 @ 0xf41938
//
// 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:07 +0000
//
__int64 __fastcall sub_F41540(const char *a1, __int64 a2, __int64 a3)
{
int v5; // w20
int v6; // w19
void *v7; // x1
int v8; // w0
size_t v9; // x2
int v10; // w0
v5 = open(a1, 0);
if ( v5 < 0 )
return 0xFFFFFFFFLL;
v6 = 0;
while ( 1 )
{
v7 = (void *)(a2 + v6);
v8 = v5;
v9 = a3 - v6;
if ( v6 >= (int)a3 )
break;
while ( 1 )
{
v10 = read(v8, v7, v9);
if ( v10 < 0 )
break;
if ( v10 )
{
v6 += v10;
v8 = v5;
v7 = (void *)(a2 + v6);
v9 = a3 - v6;
if ( v6 < (int)a3 )
continue;
}
goto LABEL_7;
}
if ( *(_DWORD *)__errno() != 4 )
{
if ( !v6 )
v6 = -1;
break;
}
}
LABEL_7:
close(v5);
return (unsigned int)v6;
}