//
// sub_B4DD60 from 0xb4dd60 to 0xb4dec0 (352 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb589f0
// > sub_B57FA0 @ 0xb58fac
//
// 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_B4DD60(unsigned __int8 *a1, unsigned __int8 a2)
{
int v2; // w21
_BYTE *v3; // x19
int v4; // w1
_BYTE *v5; // x0
void *v7; // [xsp+48h] [xbp+48h] BYREF
__int64 v8; // [xsp+50h] [xbp+50h]
v2 = a2;
v3 = a1;
v7 = nullptr;
v8 = 0;
v4 = *a1;
LABEL_2:
if ( (byte_F1EC70[v4] & 2) != 0 )
{
if ( v2 != v4 )
goto LABEL_4;
}
else
{
while ( 1 )
{
do
v4 = (unsigned __int8)*++v3;
while ( (byte_F1EC70[v4] & 2) == 0 );
if ( v2 == v4 )
break;
LABEL_4:
switch ( v4 )
{
case 13:
v4 = (unsigned __int8)v3[1];
*v3 = 10;
if ( v4 == 10 )
{
if ( v7 )
memmove((char *)v7 - v8, v7, v3 + 1 - (_BYTE *)v7);
v7 = v3 + 2;
++v8;
v4 = (unsigned __int8)v3[2];
v3 += 2;
}
else
{
++v3;
}
goto LABEL_2;
case 38:
v3 = sub_B4D5DC(v3, (__int64)&v7);
v4 = (unsigned __int8)*v3;
goto LABEL_2;
case 0:
return nullptr;
}
}
}
if ( v7 )
{
memmove((char *)v7 - v8, v7, v3 - (_BYTE *)v7);
v5 = &v3[-v8];
}
else
{
v5 = v3;
}
*v5 = 0;
return v3 + 1;
}