//
// sub_9E4E70 from 0x9e4e70 to 0x9e4f9c (300 bytes)
//
// 1 xrefs:
// > ??> @ 0xc77a14
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:07:22 +0000
//
signed int __fastcall sub_9E4E70(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;
}