//
// sub_1402F3510 from 0x1402f3510 to 0x1402f36f7 (487 bytes)
//
// 6 xrefs:
// > sub_1402F1B80 @ 0x1402f1bf6
// > sub_1402F1B80 @ 0x1402f1c0b
// > ??> @ 0x1406901e4
// > ??> @ 0x1406901fc
// > ??> @ 0x14069020c
// > ??> @ 0x1406d3e30
//
// 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
//
char *__fastcall sub_1402F3510(char *Src, char *a2, __int64 a3, _OWORD *a4)
{
char *v8; // rax
unsigned __int64 v9; // rbx
char *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 i; // rdi
v8 = Src;
if ( a3 > 32 )
{
v9 = ((unsigned __int64)(a3 - 33) >> 5) + 1;
do
{
v8 = sub_1402F1A60(v8, v8 + 1536);
--v9;
}
while ( v9 );
}
result = sub_1402F1A60(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 = &v11[48 * v16 + 1536];
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);
result = (char *)sub_1402F3E50(a4, (__int64)&a4[3 * a3]);
for ( i = 128; a3 > i; i *= 4 )
{
sub_1402F3E50(Src, (__int64)a2);
result = (char *)sub_1402F3E50(a4, (__int64)&a4[3 * a3]);
}
return result;
}
}
}
return result;
}