//
// sub_1404170E0 from 0x1404170e0 to 0x1404172dc (508 bytes)
//
// 5 xrefs:
// > sub_140414F70 @ 0x140414fe6
// > sub_140414F70 @ 0x140414ffb
// > ??> @ 0x1408c83cc
// > ??> @ 0x1408c83dc
// > ??> @ 0x14092624c
//
// 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
//
__int64 __fastcall sub_1404170E0(char *Src, char *a2, __int64 a3, _OWORD *a4)
{
char *v8; // rax
unsigned __int64 v9; // rbx
__int64 result; // rax
char *v11; // r9
__int64 v12; // rbp
_OWORD *v13; // rcx
__int64 v14; // rbp
char *v15; // rbx
__int64 v16; // rax
char *v17; // r10
char *v18; // rsi
_OWORD *v19; // rdi
__int128 v20; // xmm0
size_t v21; // rbx
char *v22; // rdx
__int128 v23; // xmm0
__int64 v24; // rdi
__int64 v25; // rsi
v8 = Src;
if ( a3 > 32 )
{
v9 = ((unsigned __int64)(a3 - 33) >> 5) + 1;
do
{
v8 = sub_140414E50(v8, v8 + 1536);
--v9;
}
while ( v9 );
}
result = (__int64)sub_140414E50(v8, a2);
if ( a3 > 32 )
{
v11 = Src;
v12 = a3;
v13 = a4;
while ( 1 )
{
v14 = v12 - 32;
v15 = v11 + 1536;
v16 = 32;
v17 = v11 + 1536;
if ( v14 < 32 )
v16 = v14;
v12 = v14 - v16;
v18 = &v15[48 * v16];
while ( 1 )
{
v19 = v13 + 3;
if ( (*(_DWORD *)v17 == 1) >= (unsigned int)(*(_DWORD *)v11 == 1) )
break;
*v13 = *(_OWORD *)v17;
v13[1] = *((_OWORD *)v17 + 1);
v20 = *((_OWORD *)v17 + 2);
v17 += 48;
v13[2] = v20;
if ( v17 == v18 )
{
v21 = v15 - v11;
v22 = v11;
goto LABEL_15;
}
LABEL_13:
v13 += 3;
}
*v13 = *(_OWORD *)v11;
v13[1] = *((_OWORD *)v11 + 1);
v23 = *((_OWORD *)v11 + 2);
v11 += 48;
v13[2] = v23;
if ( v11 != v15 )
goto LABEL_13;
v22 = v17;
v21 = v18 - v17;
LABEL_15:
memmove(v13 + 3, v22, v21);
v13 = (_OWORD *)((char *)v19 + v21);
v11 = v18;
if ( v12 <= 32 )
{
memmove(v13, v18, a2 - v18);
v24 = 64;
sub_140418350(a4, (__int64)&a4[3 * a3]);
result = a3 - 1;
if ( a3 - 1 >= 128 )
{
v25 = result / 2;
do
{
sub_140418350(Src, (__int64)a2);
v24 *= 4;
result = sub_140418350(a4, (__int64)&a4[3 * a3]);
}
while ( v25 >= v24 );
}
return result;
}
}
}
return result;
}