//
// sub_B4D304 from 0xb4d304 to 0xb4d3e8 (228 bytes)
//
// 2 xrefs:
// > sub_B57FA0 @ 0xb58318
// > sub_B57FA0 @ 0xb58f54
//
// 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_B4D304(_BYTE *a1)
{
_BYTE *v1; // x1
int v2; // w2
_BYTE *v3; // x3
_BYTE *v4; // x1
_BYTE *v6; // x5
v1 = a1 + 1;
while ( 1 )
{
do
{
v2 = (unsigned __int8)*(v1 - 1);
v3 = v1++ - 1;
}
while ( (byte_F1EC70[v2] & 1) == 0 );
if ( v2 == 60 )
break;
if ( !v2 )
{
if ( a1 < v3 && (byte_F1EC70[(unsigned __int8)*(v3 - 1)] & 8) != 0 )
{
v4 = v3;
while ( --v4 != a1 )
{
if ( (byte_F1EC70[(unsigned __int8)*(v4 - 1)] & 8) == 0 )
{
*v4 = 0;
return v3;
}
}
}
else
{
a1 = v3;
}
*a1 = 0;
return v3;
}
}
v6 = v3;
if ( a1 < v3 && (byte_F1EC70[(unsigned __int8)*(v3 - 1)] & 8) != 0 )
{
while ( --v3 != a1 )
{
if ( (byte_F1EC70[(unsigned __int8)*(v3 - 1)] & 8) == 0 )
{
*v3 = 0;
return v6 + 1;
}
}
}
else
{
a1 = v3;
}
*a1 = 0;
return v6 + 1;
}