//
// sub_B4DEC0 from 0xb4dec0 to 0xb4e030 (368 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb58318
// > sub_B57FA0 @ 0xb58f44
//
// 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_B4DEC0(unsigned __int8 *a1)
{
char *v1; // x1
_BYTE *v2; // x22
_BYTE *v3; // x19
__int64 v4; // x21
int v5; // w0
_BYTE *v6; // x23
__int64 v7; // x21
size_t v8; // x2
__int64 v10; // x21
_BYTE *v11; // x1
v1 = nullptr;
v2 = a1;
v3 = a1;
v4 = 0;
v5 = *a1;
while ( 1 )
{
if ( (byte_F1EC70[v5] & 1) == 0 )
goto LABEL_3;
if ( v5 == 60 )
break;
if ( v5 == 13 )
{
v5 = (unsigned __int8)v3[1];
*v3 = 10;
if ( v5 == 10 )
{
if ( v1 )
memmove(&v1[-v4], v1, v3 + 1 - v1);
v1 = v3 + 2;
v5 = (unsigned __int8)v3[2];
++v4;
v3 += 2;
}
else
{
++v3;
}
}
else
{
if ( !v5 )
{
if ( v1 )
{
v10 = -v4;
memmove(&v1[v10], v1, v3 - v1);
v11 = &v3[v10];
}
else
{
v11 = v3;
}
if ( v2 < v11 )
{
while ( (byte_F1EC70[(unsigned __int8)*(v11 - 1)] & 8) != 0 )
{
if ( --v11 == v2 )
goto LABEL_27;
}
}
v2 = v11;
LABEL_27:
*v2 = 0;
return v3;
}
LABEL_3:
v5 = (unsigned __int8)*++v3;
}
}
v6 = v3;
if ( v1 )
{
v7 = -v4;
v8 = v3 - v1;
v3 += v7;
memmove(&v1[v7], v1, v8);
}
if ( v2 < v3 )
{
while ( (byte_F1EC70[(unsigned __int8)*(v3 - 1)] & 8) != 0 )
{
if ( --v3 == v2 )
goto LABEL_16;
}
}
v2 = v3;
LABEL_16:
*v2 = 0;
return v6 + 1;
}