//
// sub_B4D4D8 from 0xb4d4d8 to 0xb4d5dc (260 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb58318
// > sub_B57FA0 @ 0xb58f24
//
// 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
//
_BYTE *__fastcall sub_B4D4D8(unsigned __int8 *a1)
{
char *v1; // x1
_BYTE *v2; // x19
__int64 v3; // x21
int v4; // w3
__int64 v5; // x21
char *v6; // x0
_BYTE *v7; // x21
__int64 v9; // x21
char *v10; // x0
_BYTE *v11; // x21
v1 = nullptr;
v2 = a1;
v3 = 0;
v4 = *a1;
while ( 1 )
{
if ( (byte_F1EC70[v4] & 1) == 0 )
goto LABEL_3;
if ( v4 == 60 )
break;
if ( v4 == 13 )
{
v4 = (unsigned __int8)v2[1];
*v2 = 10;
if ( v4 == 10 )
{
if ( v1 )
memmove(&v1[-v3], v1, v2 + 1 - v1);
v1 = v2 + 2;
v4 = (unsigned __int8)v2[2];
++v3;
v2 += 2;
}
else
{
++v2;
}
}
else
{
if ( !v4 )
{
if ( v1 )
{
v9 = -v3;
v10 = &v1[v9];
v11 = &v2[v9];
memmove(v10, v1, v2 - v1);
}
else
{
v11 = v2;
}
*v11 = 0;
return v2;
}
LABEL_3:
v4 = (unsigned __int8)*++v2;
}
}
if ( v1 )
{
v5 = -v3;
v6 = &v1[v5];
v7 = &v2[v5];
memmove(v6, v1, v2 - v1);
}
else
{
v7 = v2;
}
*v7 = 0;
return v2 + 1;
}