//
// sub_180087000 from 0x180087000 to 0x18008713e (318 bytes)
//
// 2 xrefs:
// > sub_180086730 @ 0x18008679f
// > ??> @ 0x1801bf790
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:22:04 +0000
//
unsigned __int8 *__fastcall sub_180087000(unsigned __int8 *a1, char a2)
{
unsigned __int8 *v3; // rbx
unsigned __int8 *v4; // rdx
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // rcx
__int64 v8; // rax
unsigned __int8 *v9; // rdi
__int64 v10; // rax
signed __int64 v11; // rsi
unsigned __int8 *v13; // rcx
v3 = a1;
v4 = nullptr;
v5 = 0;
if ( (byte_1801079B0[*a1] & 8) != 0 )
{
v4 = a1;
do
v6 = *++v4;
while ( (byte_1801079B0[v6] & 8) != 0 );
v3 = v4;
v5 = v4 - a1;
}
while ( 1 )
{
v7 = *v3;
if ( (byte_1801079B0[v7] & 0xC) == 0 )
{
do
v8 = *++v3;
while ( (byte_1801079B0[v8] & 0xC) == 0 );
LOBYTE(v7) = v8;
}
if ( (_BYTE)v7 == a2 )
break;
if ( (byte_1801079B0[*v3] & 8) != 0 )
{
*v3++ = 32;
if ( (byte_1801079B0[*v3] & 8) != 0 )
{
v9 = v3 + 1;
if ( (byte_1801079B0[v3[1]] & 8) != 0 )
{
do
v10 = *++v9;
while ( (byte_1801079B0[v10] & 8) != 0 );
}
v11 = v9 - v3;
if ( v4 )
memmove(&v4[-v5], v4, v3 - v4);
v3 = v9;
v4 = v9;
v5 += v11;
}
}
else
{
if ( !(_BYTE)v7 )
return nullptr;
++v3;
}
}
if ( v4 )
{
memmove(&v4[-v5], v4, v3 - v4);
v13 = &v3[-v5];
}
else
{
v13 = v3;
}
do
*v13-- = 0;
while ( (byte_1801079B0[*v13] & 8) != 0 );
return v3 + 1;
}