//
// sub_1402F3700 from 0x1402f3700 to 0x1402f3868 (360 bytes)
//
// 7 xrefs:
// > sub_1402F1B80 @ 0x1402f1c59
// > sub_1402F4450 @ 0x1402f44ed
// > sub_1402F4450 @ 0x1402f4532
// > ??> @ 0x140690228
// > ??> @ 0x14069023c
// > ??> @ 0x14069024c
// > ??> @ 0x1406d3e60
//
// 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
//
__int64 __fastcall sub_1402F3700(char *Src, char *a2, char *a3, __int64 a4, __int64 a5, void *a6, __int64 a7, char a8)
{
char *v8; // r10
char *v9; // rbx
__int64 result; // rax
char *v12; // rdi
__int64 v13; // r11
size_t v14; // rdi
__int128 v15; // [rsp+40h] [rbp-38h]
__int128 v16; // [rsp+40h] [rbp-38h]
__int128 v17; // [rsp+50h] [rbp-28h]
__int128 v18; // [rsp+50h] [rbp-28h]
__int128 v19; // [rsp+60h] [rbp-18h]
__int128 v20; // [rsp+60h] [rbp-18h]
if ( a2 != a3 )
{
v8 = a3;
v9 = Src;
if ( Src != a2 )
{
while ( 1 )
{
result = *(_DWORD *)v9 == 1;
if ( (*(_DWORD *)a2 == 1) < (unsigned int)result )
break;
v9 += 48;
--a4;
if ( v9 == a2 )
return result;
}
do
{
v12 = v8;
v13 = a5;
v8 -= 48;
--a5;
if ( a2 == v8 )
{
v20 = *(_OWORD *)a2;
v18 = *((_OWORD *)a2 + 1);
v16 = *((_OWORD *)a2 + 2);
result = (__int64)memmove(&v8[-(a2 - v9) + 48], v9, a2 - v9);
*(_OWORD *)v9 = v20;
*((_OWORD *)v9 + 1) = v18;
*((_OWORD *)v9 + 2) = v16;
return result;
}
}
while ( (*(_DWORD *)v8 == 1) >= (unsigned int)(*((_DWORD *)a2 - 12) == 1) );
if ( a4 == 1 )
{
v14 = v12 - a2;
v15 = *(_OWORD *)v9;
v17 = *((_OWORD *)v9 + 1);
v19 = *((_OWORD *)v9 + 2);
result = (__int64)memmove(v9, a2, v14);
*(_OWORD *)&v9[v14] = v15;
*(_OWORD *)&v9[v14 + 16] = v17;
*(_OWORD *)&v9[v14 + 32] = v19;
}
else
{
return sub_1402F3F80(v9, a2, v13, a6, a7, a8);
}
}
}
return result;
}