//
// sub_FF4550 from 0xff4550 to 0xff4718 (456 bytes)
//
// 2 xrefs:
// > sub_FF4718 @ 0xff4724
// > sub_FF4730 @ 0xff4778
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:15:47 +0000
//
__int64 __fastcall sub_FF4550(__int64 a1, char *a2, int a3)
{
__int64 v3; // x21
__int64 v7; // x23
int v8; // w4
__int64 v9; // x2
int v10; // w3
int v11; // w0
int v12; // w19
const void *v13; // x1
int v14; // w3
__int64 v15; // x0
__int64 v16; // x2
int v17; // w0
unsigned int v18; // w19
int v19; // w2
__int64 result; // x0
int v21; // w0
v3 = *(_QWORD *)(a1 + 48);
if ( !v3 )
return 0;
v7 = *(_QWORD *)(a1 + 56);
if ( !v7 )
return (unsigned int)v7;
LODWORD(v7) = 0;
BIO_clear_flags(a1, 15);
v8 = *(_DWORD *)(v3 + 4);
while ( 1 )
{
v9 = *(unsigned int *)(v3 + 32);
v10 = *(_DWORD *)(v3 + 36);
v11 = v9 + v10;
v12 = v8 - (v9 + v10);
if ( v12 >= a3 )
{
memcpy((void *)(*(_QWORD *)(v3 + 24) + v11), a2, a3);
*(_DWORD *)(v3 + 32) += a3;
return (unsigned int)(v7 + a3);
}
if ( (_DWORD)v9 )
break;
LABEL_13:
*(_DWORD *)(v3 + 36) = 0;
while ( a3 >= v8 )
{
v21 = BIO_write(*(_QWORD *)(a1 + 56), a2, (unsigned int)a3);
v18 = v21;
a2 += v21;
if ( v21 <= 0 )
goto LABEL_10;
a3 -= v21;
LODWORD(v7) = v7 + v21;
if ( !a3 )
return (unsigned int)v7;
v8 = *(_DWORD *)(v3 + 4);
}
}
if ( v12 <= 0 )
{
while ( 1 )
{
v17 = BIO_write(*(_QWORD *)(a1 + 56), *(_QWORD *)(v3 + 24) + v10, v9);
v18 = v17;
if ( v17 <= 0 )
break;
LABEL_8:
v19 = *(_DWORD *)(v3 + 32);
v10 = v17 + *(_DWORD *)(v3 + 36);
*(_DWORD *)(v3 + 36) = v10;
v9 = (unsigned int)(v19 - v17);
*(_DWORD *)(v3 + 32) = v9;
if ( !(_DWORD)v9 )
{
v8 = *(_DWORD *)(v3 + 4);
goto LABEL_13;
}
}
}
else
{
v13 = a2;
a2 += v12;
a3 -= v12;
memcpy((void *)(*(_QWORD *)(v3 + 24) + v11), v13, v12);
LODWORD(v7) = v7 + v12;
v14 = *(_DWORD *)(v3 + 36);
v15 = *(_QWORD *)(a1 + 56);
v16 = (unsigned int)(v12 + *(_DWORD *)(v3 + 32));
*(_DWORD *)(v3 + 32) = v16;
v17 = BIO_write(v15, *(_QWORD *)(v3 + 24) + v14, v16);
v18 = v17;
if ( v17 > 0 )
goto LABEL_8;
}
LABEL_10:
BIO_copy_next_retry(a1);
result = (unsigned int)v7;
if ( v18 )
{
if ( (_DWORD)v7 )
return (unsigned int)v7;
else
return v18;
}
return result;
}