//
// sub_180084040 from 0x180084040 to 0x18008417e (318 bytes)
//
// 2 xrefs:
// > sub_180083740 @ 0x1800837af
// > ??> @ 0x1801b54f0
//
// 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_180084040(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_180101290[*a1] & 8) != 0 )
{
v4 = a1;
do
v6 = *++v4;
while ( (byte_180101290[v6] & 8) != 0 );
v3 = v4;
v5 = v4 - a1;
}
while ( 1 )
{
v7 = *v3;
if ( (byte_180101290[v7] & 0xC) == 0 )
{
do
v8 = *++v3;
while ( (byte_180101290[v8] & 0xC) == 0 );
LOBYTE(v7) = v8;
}
if ( (_BYTE)v7 == a2 )
break;
if ( (byte_180101290[(unsigned __int8)v7] & 8) != 0 )
{
*v3++ = 32;
if ( (byte_180101290[*v3] & 8) != 0 )
{
v9 = v3 + 1;
if ( (byte_180101290[v3[1]] & 8) != 0 )
{
do
v10 = *++v9;
while ( (byte_180101290[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_180101290[*v13] & 8) != 0 );
return v3 + 1;
}