//
// sub_100649830 from 0x100649830 to 0x100649975 (325 bytes)
//
// 4 xrefs:
// > ??> @ 0x100985f28
// > ??> @ 0x100985f38
// > ??> @ 0x100985f48
// > ??> @ 0x100985f58
//
// 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_100649830(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rcx
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // r15
unsigned __int8 *v6; // rax
unsigned __int8 *v7; // rbx
unsigned __int8 *v8; // r12
__int64 v9; // rcx
__int64 v10; // rdx
__int64 v11; // rcx
bool v12; // cf
size_t v13; // rbx
__int64 v14; // rax
v2 = nullptr;
if ( (a7_0[*a1] & 8) != 0 )
{
v3 = 0;
do
v4 = a1[++v3];
while ( (a7_0[v4] & 8) != 0 );
a1 += v3;
v2 = a1;
}
else
{
v3 = 0;
}
LABEL_6:
v5 = v3;
v6 = v2;
v7 = a1;
while ( 1 )
{
do
{
v8 = v7;
v9 = *v7;
v10 = (unsigned __int8)a7_0[v9];
++v7;
}
while ( (v10 & 0xC) == 0 );
if ( (_BYTE)v9 == (_BYTE)a2 )
break;
if ( (v10 & 8) != 0 )
{
*v8 = 32;
if ( (a7_0[v8[1]] & 8) != 0 )
{
v3 = v5;
a1 = v7;
do
{
v11 = *++a1;
++v3;
}
while ( (a7_0[v11] & 8) != 0 );
v2 = a1;
if ( v6 )
{
v12 = v7 < v6;
v13 = v7 - v6;
if ( v12 )
sub_1007CDEC0(a1, a2, v10, a1);
memmove(&v6[-v5], v6, v13);
v2 = a1;
a2 = (unsigned int)a2;
}
goto LABEL_6;
}
}
else if ( !(_BYTE)v9 )
{
return nullptr;
}
}
if ( v6 )
{
if ( v6 > v8 )
sub_1007CDEF0(a1);
memmove(&v6[-v5], v6, v8 - v6);
v8 -= v5;
}
do
{
*v8 = 0;
v14 = *--v8;
}
while ( (a7_0[v14] & 8) != 0 );
return v7;
}