//
// sub_7D35A4 from 0x7d35a4 to 0x7d36a4 (256 bytes)
//
// 2 xrefs:
// > ??> @ 0xa30814
// > ??> @ 0xa3083c
//
// 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_7D35A4(int a1, _BYTE *a2, signed int a3)
{
signed int *v3; // r7
signed int v7; // r4
int v8; // r3
int v9; // r2
int v10; // t1
int v11; // r7
bool v12; // cc
int v14; // r3
v3 = *(signed int **)(*(_DWORD *)(a1 + 32) + 4);
BIO_clear_flags(a1, 15);
v7 = *v3;
if ( *v3 >= a3 )
v7 = a3 - 1;
if ( v7 > 0 )
{
v8 = 0;
v9 = v3[1] - 1;
while ( 1 )
{
v10 = *(unsigned __int8 *)++v9;
if ( v10 == 10 )
break;
if ( ++v8 == v7 )
goto LABEL_7;
}
v7 = v8 + 1;
LABEL_7:
v11 = *(_DWORD *)(*(_DWORD *)(a1 + 32) + 4);
BIO_clear_flags(a1, 15);
if ( (unsigned int)v7 >= *(_DWORD *)v11 )
v7 = *(_DWORD *)v11;
v12 = (int)a2 <= 0;
if ( a2 )
v12 = v7 <= 0;
if ( !v12 )
{
memcpy(a2, *(const void **)(v11 + 4), v7);
v14 = *(_DWORD *)(v11 + 4) + v7;
*(_DWORD *)v11 -= v7;
*(_DWORD *)(v11 + 4) = v14;
LABEL_18:
a2[v7] = 0;
return v7;
}
if ( !*(_DWORD *)v11 )
{
v7 = *(_DWORD *)(a1 + 28);
if ( !v7 )
return v7;
BIO_set_flags(a1, 9);
}
if ( v7 > 0 )
goto LABEL_18;
return v7;
}
*a2 = 0;
return 0;
}