//
// sub_7D0270 from 0x7d0270 to 0x7d039c (300 bytes)
//
// 1 xrefs:
// > ??> @ 0xa30794
//
// 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
//
signed int __fastcall sub_7D0270(int a1, char *a2, signed int a3)
{
char *v3; // r6
signed int *v4; // r5
int v6; // r7
signed int v8; // r4
bool v9; // zf
int v10; // r3
int v11; // r0
int v13; // r0
v3 = a2;
if ( !a2 )
return 0;
v4 = *(signed int **)(a1 + 32);
if ( !v4 )
return 0;
v6 = *(_DWORD *)(a1 + 36);
if ( v6 )
{
v6 = 0;
BIO_clear_flags(a1, 15);
v8 = v4[3];
while ( 1 )
{
if ( v8 )
{
if ( v8 >= a3 )
v8 = a3;
memcpy(v3, (const void *)(v4[2] + v4[4]), v8);
v9 = a3 == v8;
v10 = v4[3] - v8;
a3 -= v8;
v3 += v8;
v6 += v8;
v4[4] += v8;
v4[3] = v10;
if ( v9 )
break;
}
if ( a3 > *v4 )
{
while ( 1 )
{
v13 = BIO_read(*(_DWORD *)(a1 + 36), v3, a3);
v8 = v13;
if ( v13 <= 0 )
break;
v6 += v13;
if ( a3 == v13 )
return v6;
a3 -= v13;
v3 += v13;
}
LABEL_12:
BIO_copy_next_retry(a1);
if ( !v8 )
return v6;
if ( v6 <= 0 )
return v8;
else
return v6;
}
v11 = BIO_read(*(_DWORD *)(a1 + 36), v4[2], *v4);
v8 = v11;
if ( v11 <= 0 )
goto LABEL_12;
v4[4] = 0;
v4[3] = v11;
}
}
return v6;
}