//
// sub_740ED8 from 0x740ed8 to 0x740f76 (158 bytes)
//
// 5 xrefs:
// > gzread @ 0x741036
// > gzread @ 0x7410de
// > gzungetc @ 0x741250
// > gzgets @ 0x74135c
// > gzgets @ 0x74136c
//
// 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_740ED8(unsigned int *a1)
{
unsigned int v2; // r3
unsigned int v4; // r5
unsigned int v5; // r6
unsigned int v6; // r2
unsigned int v7; // r5
ssize_t v8; // r0
unsigned int v9; // r2
int *v10; // r0
char *v11; // r0
while ( 1 )
{
v2 = a1[11];
if ( v2 == 1 )
break;
if ( v2 == 2 )
{
v9 = a1[9];
a1[25] = 2 * a1[6];
a1[24] = v9;
if ( sub_740D94(a1) == -1 )
return -1;
}
else if ( !v2 )
{
if ( sub_740BF8((int)a1) == -1 )
return -1;
if ( !a1[11] )
return 0;
}
if ( *a1 || a1[13] && !a1[22] )
return 0;
}
v4 = a1[6];
v5 = a1[9];
v6 = 0;
*a1 = 0;
v7 = 2 * v4;
while ( 1 )
{
v8 = read(a1[4], (void *)(v5 + v6), v7 - v6);
if ( v8 <= 0 )
break;
v6 = v8 + *a1;
*a1 = v6;
if ( v7 <= v6 )
goto LABEL_14;
}
if ( v8 )
{
v10 = (int *)_errno();
v11 = strerror(*v10);
sub_740B68(a1, -1, v11);
return -1;
}
a1[13] = 1;
LABEL_14:
a1[1] = a1[9];
return 0;
}