//
// sub_100649400 from 0x100649400 to 0x1006494fb (251 bytes)
//
// 1 xrefs:
// > ??> @ 0x100985ef8
//
// 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_100649400(_BYTE *a1, char a2, __int64 a3)
{
__int64 v4; // r15
char *v5; // rsi
__int64 v6; // rcx
_BYTE *v7; // rbx
__int64 v8; // r13
__int64 v9; // rax
char *v10; // rax
_BYTE *v11; // rbx
__int64 v13; // [rsp+0h] [rbp-30h]
v4 = -1;
v5 = nullptr;
v6 = 0;
while ( 1 )
{
v7 = a1;
v8 = 0;
do
v9 = (unsigned __int8)a1[v8++];
while ( (a7_0[v9] & 2) == 0 );
if ( (_BYTE)v9 == a2 )
break;
a1 += v8;
if ( (_DWORD)v9 == 13 )
{
*(a1 - 1) = 10;
if ( *a1 == 10 )
{
if ( v5 )
{
if ( &v7[v8] < v5 )
sub_1007CDD40(a1, v5, a3, v6);
v13 = v6;
memmove(&v5[-v6], v5, v8 + v7 - v5);
v6 = v13;
}
a1 = &v7[v8 + 1];
++v6;
--v4;
v5 = a1;
}
}
else if ( !(_DWORD)v9 )
{
return nullptr;
}
}
v10 = &a1[v8 - 1];
if ( v5 )
{
if ( v5 > v10 )
sub_1007CDD70(a1, v5, a3, v6);
memmove(&v5[-v6], v5, a1 - v5 + v8 - 1);
v10 = &a1[v4 + v8];
}
v11 = &a1[v8];
*v10 = 0;
return v11;
}