//
// sub_B4DAF0 from 0xb4daf0 to 0xb4dc58 (360 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb58318
// > sub_B57FA0 @ 0xb58f04
//
// 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
//
unsigned __int8 *__fastcall sub_B4DAF0(unsigned __int8 *a1)
{
unsigned __int8 *v1; // x22
unsigned __int8 *v2; // x19
int v3; // w0
unsigned __int8 *v4; // x23
unsigned __int8 *v6; // x0
void *v7; // [xsp+48h] [xbp+48h] BYREF
__int64 v8; // [xsp+50h] [xbp+50h]
v1 = a1;
v2 = a1;
v7 = nullptr;
v8 = 0;
while ( 1 )
{
v3 = *v2;
if ( (byte_F1EC70[*v2] & 1) == 0 )
goto LABEL_6;
if ( v3 == 60 )
break;
if ( v3 == 38 )
{
v2 = sub_B4D5DC(v2, (__int64)&v7);
}
else
{
if ( !*v2 )
{
if ( v7 )
{
memmove((char *)v7 - v8, v7, v2 - (_BYTE *)v7);
v6 = &v2[-v8];
}
else
{
v6 = v2;
}
if ( v1 < v6 )
{
while ( (byte_F1EC70[*(v6 - 1)] & 8) != 0 )
{
if ( --v6 == v1 )
goto LABEL_24;
}
}
v1 = v6;
LABEL_24:
*v1 = 0;
return v2;
}
LABEL_6:
++v2;
}
}
v4 = v2;
if ( v7 )
{
memmove((char *)v7 - v8, v7, v2 - (_BYTE *)v7);
v2 -= v8;
}
if ( v1 < v2 )
{
while ( (byte_F1EC70[*(v2 - 1)] & 8) != 0 )
{
if ( --v2 == v1 )
goto LABEL_15;
}
}
v1 = v2;
LABEL_15:
*v1 = 0;
return v4 + 1;
}