//
// sub_140418480 from 0x140418480 to 0x140418737 (695 bytes)
//
// 5 xrefs:
// > sub_1404172E0 @ 0x1404173ec
// > ??> @ 0x1408c86b8
// > ??> @ 0x1408c86c8
// > ??> @ 0x1408c86dc
// > ??> @ 0x140926450
//
// 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:32:05 +0000
//
void *__fastcall sub_140418480(char *Src, _BYTE *a2, char *a3, __int64 a4, __int64 a5, char *Srca, __int64 a7, char a8)
{
char *v11; // rdi
char *v12; // r8
char *v13; // r15
_OWORD *v14; // rdx
char *v15; // r9
char *v16; // rbx
__int128 v17; // xmm0
void *result; // rax
__int128 v19; // xmm0
size_t v20; // rbp
__int64 v21; // rbx
char *v22; // r9
char *v23; // rdx
char *v24; // r8
__int128 v25; // xmm0
char *v26; // r9
char *v27; // r9
if ( a4 <= a5 && a4 <= a7 )
{
v11 = Srca;
memmove(Srca, Src, a2 - Src);
v12 = &Srca[a2 - Src];
v13 = v12 - 48;
*(_OWORD *)Src = *(_OWORD *)a2;
v14 = Src + 48;
v15 = a2 + 48;
*((_OWORD *)Src + 1) = *((_OWORD *)a2 + 1);
*((_OWORD *)Src + 2) = *((_OWORD *)a2 + 2);
while ( 1 )
{
v16 = (char *)(v14 + 3);
if ( (*(_DWORD *)v15 == 1) >= (unsigned int)(*(_DWORD *)v11 == 1) )
{
*v14 = *(_OWORD *)v11;
v14[1] = *((_OWORD *)v11 + 1);
v19 = *((_OWORD *)v11 + 2);
v11 += 48;
v14[2] = v19;
if ( v11 == v13 )
{
v20 = a3 - v15;
result = memmove(v16, v15, v20);
*(_OWORD *)&v16[v20] = *(_OWORD *)v13;
*(_OWORD *)&v16[v20 + 16] = *((_OWORD *)v13 + 1);
*(_OWORD *)&v16[v20 + 32] = *((_OWORD *)v13 + 2);
return result;
}
}
else
{
*v14 = *(_OWORD *)v15;
v14[1] = *((_OWORD *)v15 + 1);
v17 = *((_OWORD *)v15 + 2);
v15 += 48;
v14[2] = v17;
if ( v15 == a3 )
return memmove(v16, v11, v12 - v11);
}
v14 += 3;
}
}
if ( a5 > a7 )
return (void *)sub_140418FE0(Src, (_DWORD)a2, (_DWORD)a3, a4, a5, Srca, a7, a8);
v21 = a3 - a2;
memmove(Srca, a2, a3 - a2);
v22 = a3 - 48;
*(_OWORD *)v22 = *((_OWORD *)a2 - 3);
v23 = &Srca[v21 - 48];
v24 = a2 - 96;
*((_OWORD *)v22 + 1) = *((_OWORD *)a2 - 2);
*((_OWORD *)v22 + 2) = *((_OWORD *)a2 - 1);
while ( 1 )
{
while ( 1 )
{
v22 -= 48;
if ( (*(_DWORD *)v23 == 1) < (unsigned int)(*(_DWORD *)v24 == 1) )
break;
*(_OWORD *)v22 = *(_OWORD *)v23;
*((_OWORD *)v22 + 1) = *((_OWORD *)v23 + 1);
v25 = *((_OWORD *)v23 + 2);
v23 -= 48;
*((_OWORD *)v22 + 2) = v25;
if ( Srca == v23 )
{
v26 = v22 - 48;
*(_OWORD *)v26 = *(_OWORD *)v24;
*((_OWORD *)v26 + 1) = *((_OWORD *)v24 + 1);
*((_OWORD *)v26 + 2) = *((_OWORD *)v24 + 2);
result = memmove(&v26[-(v24 - Src)], Src, v24 - Src);
*(_OWORD *)Src = *(_OWORD *)Srca;
*((_OWORD *)Src + 1) = *((_OWORD *)Srca + 1);
*((_OWORD *)Src + 2) = *((_OWORD *)Srca + 2);
return result;
}
}
*(_OWORD *)v22 = *(_OWORD *)v24;
*((_OWORD *)v22 + 1) = *((_OWORD *)v24 + 1);
*((_OWORD *)v22 + 2) = *((_OWORD *)v24 + 2);
if ( Src == v24 )
break;
v24 -= 48;
}
v27 = v22 - 48;
*(_OWORD *)v27 = *(_OWORD *)v23;
*((_OWORD *)v27 + 1) = *((_OWORD *)v23 + 1);
*((_OWORD *)v27 + 2) = *((_OWORD *)v23 + 2);
return memmove(&v27[-(v23 - Srca)], Srca, v23 - Srca);
}