//
// sub_180082D30 from 0x180082d30 to 0x180082dec (188 bytes)
//
// 2 xrefs:
// > sub_180083740 @ 0x18008378b
// > ??> @ 0x1801b5448
//
// 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_180082D30(unsigned __int8 *a1, char a2)
{
unsigned __int8 *v3; // rdx
__int64 v5; // rdi
__int64 i; // rax
unsigned __int8 *v8; // rax
v3 = nullptr;
v5 = 0;
while ( 1 )
{
for ( i = *a1; (byte_180101290[i] & 2) == 0; ++a1 )
i = a1[1];
if ( (_BYTE)i == a2 )
break;
if ( (_BYTE)i == 13 )
{
*a1++ = 10;
if ( *a1 == 10 )
{
if ( v3 )
memmove(&v3[-v5], v3, a1 - v3);
v3 = ++a1;
++v5;
}
}
else
{
if ( !(_BYTE)i )
return nullptr;
++a1;
}
}
if ( v3 )
{
memmove(&v3[-v5], v3, a1 - v3);
v8 = &a1[-v5];
}
else
{
v8 = a1;
}
*v8 = 0;
return a1 + 1;
}