//
// sub_B4E72C from 0xb4e72c to 0xb4e884 (344 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb589f0
// > sub_B57FA0 @ 0xb5868c
//
// 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_B4E72C(unsigned __int8 *a1, unsigned __int8 a2)
{
unsigned __int8 *v2; // x19
int v3; // w21
int v4; // w3
unsigned __int8 v5; // w0
unsigned __int8 *v6; // x1
int v7; // t1
__int64 v8; // x22
unsigned __int8 *v9; // x2
__int64 v10; // x0
int v11; // t1
unsigned __int8 *v12; // x24
unsigned __int8 *v14; // x21
__int64 v15; // x22
size_t v16; // x2
v2 = a1;
v3 = a2;
v4 = *a1;
v5 = byte_F1EC70[*a1];
if ( (v5 & 8) != 0 )
{
v6 = v2;
do
{
v7 = *++v6;
v4 = v7;
v5 = byte_F1EC70[v7];
}
while ( (v5 & 8) != 0 );
v8 = v6 - v2;
v2 = v6;
}
else
{
v8 = 0;
v6 = nullptr;
}
LABEL_5:
while ( (v5 & 0xC) == 0 )
{
LABEL_14:
v4 = *++v2;
v5 = byte_F1EC70[v4];
}
while ( 1 )
{
if ( v3 == v4 )
{
v14 = v2;
if ( v6 )
{
v15 = -v8;
v16 = v2 - v6;
v2 += v15;
memmove(&v6[v15], v6, v16);
}
do
*v2-- = 0;
while ( (byte_F1EC70[*v2] & 8) != 0 );
return v14 + 1;
}
if ( (v5 & 8) == 0 )
break;
v4 = v2[1];
*v2 = 32;
v9 = v2 + 1;
v5 = byte_F1EC70[v4];
if ( (v5 & 8) == 0 )
{
++v2;
goto LABEL_5;
}
v10 = v2[2];
v2 += 2;
if ( (byte_F1EC70[v10] & 8) != 0 )
{
do
v11 = *++v2;
while ( (byte_F1EC70[v11] & 8) != 0 );
}
v12 = (unsigned __int8 *)(v2 - v9);
if ( v6 )
memmove(&v6[-v8], v6, v9 - v6);
v4 = *v2;
v8 += (__int64)v12;
v6 = v2;
v5 = byte_F1EC70[*v2];
if ( (v5 & 0xC) == 0 )
goto LABEL_14;
}
if ( v4 )
goto LABEL_14;
return nullptr;
}