//
// sub_76E7A4 from 0x76e7a4 to 0x76e922 (382 bytes)
//
// 0 xrefs:
//
// 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_76E7A4(int a1, char *a2, int a3)
{
int v4; // r8
char *v5; // r5
signed int v6; // r4
char *v7; // r3
char *v8; // r2
int v9; // r6
int v10; // r0
int v11; // r1
int v12; // r0
unsigned int v13; // r3
int v14; // r3
int v15; // r0
int v16; // r8
_BYTE *v17; // r1
_BYTE *v18; // r3
int v19; // r8
int v20; // r0
int v21; // r3
int v23; // r3
int v25; // r1
int v26; // r3
unsigned int v27; // r2
int v28; // r3
v4 = *(unsigned __int8 *)(a1 + 80);
v5 = a2;
v6 = a3;
if ( *(_BYTE *)(a1 + 80) )
{
v7 = *(char **)(a1 + 8);
if ( a3 <= 0 )
{
v9 = 0;
v8 = *(char **)(a1 + 4);
}
else
{
v8 = *(char **)(a1 + 4);
if ( v7 == v8 )
{
--v6;
v9 = 1;
v5 = a2 + 1;
*a2 = *v7;
v25 = *(unsigned __int8 *)(a1 + 80);
v7 = (char *)(*(_DWORD *)(a1 + 8) + 1);
*(_DWORD *)(a1 + 8) = v7;
if ( !v25 )
goto LABEL_8;
v8 = *(char **)(a1 + 4);
v9 = 1;
}
else
{
v9 = 0;
}
}
v10 = *(_DWORD *)(a1 + 76);
v11 = *(_DWORD *)(a1 + 60);
*(_BYTE *)(a1 + 80) = 0;
*(_DWORD *)(a1 + 12) = v10;
v12 = *(_DWORD *)(a1 + 72);
*(_DWORD *)(a1 + 4) = v11;
if ( v7 != v8 )
++v12;
*(_DWORD *)(a1 + 72) = v12;
*(_DWORD *)(a1 + 8) = v12;
}
else
{
v9 = *(unsigned __int8 *)(a1 + 70);
if ( *(_BYTE *)(a1 + 70) )
{
if ( (*(int (__fastcall **)(int, int))(*(_DWORD *)a1 + 52))(a1, -1) == -1 )
return v4;
v23 = *(_DWORD *)(a1 + 60);
v9 = v4;
*(_DWORD *)(a1 + 20) = v4;
*(_DWORD *)(a1 + 16) = v4;
*(_DWORD *)(a1 + 24) = v4;
*(_BYTE *)(a1 + 70) = v4;
*(_DWORD *)(a1 + 4) = v23;
*(_DWORD *)(a1 + 8) = v23;
*(_DWORD *)(a1 + 12) = v23;
}
}
LABEL_8:
v13 = *(_DWORD *)(a1 + 64);
if ( v13 <= 1 )
v14 = 1;
else
v14 = v13 - 1;
if ( v6 <= v14 )
return v9 + sub_7610B0(a1, v5, v6);
v15 = *(_DWORD *)(a1 + 84);
if ( !v15 )
sub_772FE4(0);
v16 = (*(_DWORD *)(a1 + 44) >> 3) & 1;
if ( ((*(int (__fastcall **)(int))(*(_DWORD *)v15 + 24))(v15) & v16) == 0 )
return v9 + sub_7610B0(a1, v5, v6);
v17 = *(_BYTE **)(a1 + 8);
v18 = *(_BYTE **)(a1 + 12);
v19 = v18 - v17;
if ( v18 != v17 )
{
v6 -= v19;
memcpy(v5, v17, v18 - v17);
v9 += v19;
v5 += v19;
*(_DWORD *)(a1 + 8) += v19;
}
while ( 1 )
{
v20 = sub_77A0DC(a1 + 36, v5, v6);
if ( v20 == -1 )
sub_77356C("basic_filebuf::xsgetn error reading the file");
if ( !v20 )
break;
v6 -= v20;
v9 += v20;
if ( !v6 )
goto LABEL_31;
v5 += v20;
}
if ( v6 )
{
v21 = *(_DWORD *)(a1 + 60);
*(_DWORD *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 24) = 0;
*(_BYTE *)(a1 + 69) = 0;
*(_DWORD *)(a1 + 4) = v21;
*(_DWORD *)(a1 + 8) = v21;
*(_DWORD *)(a1 + 12) = v21;
return v9;
}
LABEL_31:
if ( (*(_DWORD *)(a1 + 44) & 0x11) != 0 )
{
v27 = *(_DWORD *)(a1 + 64);
v28 = *(_DWORD *)(a1 + 60);
*(_DWORD *)(a1 + 4) = v28;
*(_DWORD *)(a1 + 8) = v28;
*(_DWORD *)(a1 + 12) = v28;
if ( v27 > 1 )
{
*(_DWORD *)(a1 + 20) = v28;
*(_DWORD *)(a1 + 16) = v28;
*(_DWORD *)(a1 + 24) = v27 - 1 + v28;
goto LABEL_34;
}
}
else
{
v26 = *(_DWORD *)(a1 + 60);
*(_DWORD *)(a1 + 4) = v26;
*(_DWORD *)(a1 + 8) = v26;
*(_DWORD *)(a1 + 12) = v26;
}
*(_DWORD *)(a1 + 20) = 0;
*(_DWORD *)(a1 + 16) = 0;
*(_DWORD *)(a1 + 24) = 0;
LABEL_34:
*(_BYTE *)(a1 + 69) = 1;
return v9;
}