//
// sub_B4D3E8 from 0xb4d3e8 to 0xb4d4d8 (240 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb589f0
// > sub_B57FA0 @ 0xb58fbc
//
// 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_B4D3E8(unsigned __int8 *a1, unsigned __int8 a2)
{
int v2; // w21
_BYTE *v3; // x19
__int64 v4; // x22
char *v5; // x1
int v6; // w3
__int64 v7; // x22
char *v8; // x0
_BYTE *v9; // x22
v2 = a2;
v3 = a1;
v4 = 0;
v5 = nullptr;
v6 = *a1;
while ( 1 )
{
if ( (byte_F1EC70[v6] & 2) == 0 )
goto LABEL_3;
if ( v2 == v6 )
break;
if ( v6 == 13 )
{
v6 = (unsigned __int8)v3[1];
*v3 = 10;
if ( v6 == 10 )
{
if ( v5 )
memmove(&v5[-v4], v5, v3 + 1 - v5);
v5 = v3 + 2;
v6 = (unsigned __int8)v3[2];
++v4;
v3 += 2;
}
else
{
++v3;
}
}
else
{
if ( !v6 )
return nullptr;
LABEL_3:
v6 = (unsigned __int8)*++v3;
}
}
if ( v5 )
{
v7 = -v4;
v8 = &v5[v7];
v9 = &v3[v7];
memmove(v8, v5, v3 - v5);
}
else
{
v9 = v3;
}
*v9 = 0;
return v3 + 1;
}