//
// strncpy from 0x180128b60 to 0x180128cc2 (354 bytes)
//
// 22 xrefs:
// > sub_180020140 @ 0x180020337
// > sub_1800F6380 @ 0x1800f63db
// > sub_1800F6380 @ 0x1800f63f7
// > sub_1800F6380 @ 0x1800f6458
// > sub_1800F6380 @ 0x1800f646f
// > sub_1800F6380 @ 0x1800f64ea
// > sub_1800F6380 @ 0x1800f6501
// > sub_1800F6380 @ 0x1800f6589
// > sub_1800F6380 @ 0x1800f659c
// > sub_180107A40 @ 0x180107a95
// > sub_180107A40 @ 0x180107aae
// > sub_180109650 @ 0x1801096ab
// > sub_180109650 @ 0x1801096c4
// > sub_180109650 @ 0x18010973a
// > sub_180109650 @ 0x180109751
// > sub_180109650 @ 0x1801097e4
// > sub_180109650 @ 0x1801097fb
// > sub_180109650 @ 0x180109872
// > sub_180109650 @ 0x180109889
// > sub_180109650 @ 0x18010990e
// > sub_180109650 @ 0x180109925
// > ??> @ 0x180202a20
//
// 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 10:54:56 +0000
//
char *__cdecl strncpy(char *Destination, const char *Source, size_t Count)
{
signed __int64 v4; // rcx
bool v5; // zf
unsigned __int64 v7; // rax
bool v8; // cc
unsigned __int64 v9; // rax
unsigned __int64 v10; // rax
unsigned int v11; // eax
const char *v12; // rcx
bool v13; // cf
size_t i; // r8
unsigned __int64 v15; // r8
if ( !Count )
return Destination;
v4 = Destination - Source;
if ( ((unsigned __int8)Source & 7) != 0 )
{
while ( 1 )
{
v5 = *Source == 0;
Source[v4] = *Source;
if ( v5 )
break;
++Source;
if ( !--Count )
return Destination;
if ( ((unsigned __int8)Source & 7) == 0 )
goto _qword_loop_entrance;
}
filler:
v12 = &Source[v4];
if ( Count >= 0x10 )
{
while ( ((unsigned __int8)v12 & 7) != 0 )
{
*++v12 = 0;
--Count;
}
v13 = Count < 0x20;
for ( i = Count - 32; !v13; i -= 32LL )
{
*(_QWORD *)v12 = 0;
*((_QWORD *)v12 + 1) = 0;
*((_QWORD *)v12 + 2) = 0;
*((_QWORD *)v12 + 3) = 0;
v12 += 32;
v13 = i < 0x20;
}
v15 = i + 32;
while ( 1 )
{
v13 = v15 < 8;
v15 -= 8LL;
if ( v13 )
break;
*(_QWORD *)v12 = 0;
v12 += 8;
}
Count = v15 + 8;
}
while ( 1 )
{
v13 = Count-- == 0;
if ( v13 )
break;
*v12++ = 0;
}
return Destination;
}
else
{
do
{
_qword_loop_entrance:
while ( 1 )
{
v7 = *(_QWORD *)Source;
v8 = Count <= 8;
Count -= 8LL;
if ( v8 || (((v7 + 0x7EFEFEFEFEFEFEFFLL) ^ ~v7) & 0x8101010101010100uLL) != 0 )
break;
*(_QWORD *)&Source[v4] = v7;
Source += 8;
}
Count += 8LL;
if ( !Count )
break;
Source[v4] = v7;
if ( !(_BYTE)v7 )
goto filler;
++Source;
if ( !--Count )
break;
Source[v4] = BYTE1(v7);
if ( !BYTE1(v7) )
goto filler;
++Source;
if ( !--Count )
break;
v9 = v7 >> 16;
Source[v4] = v9;
if ( !(_BYTE)v9 )
goto filler;
++Source;
if ( !--Count )
break;
Source[v4] = BYTE1(v9);
if ( !BYTE1(v9) )
goto filler;
++Source;
if ( !--Count )
break;
v10 = v9 >> 16;
Source[v4] = v10;
if ( !(_BYTE)v10 )
goto filler;
++Source;
if ( !--Count )
break;
Source[v4] = BYTE1(v10);
if ( !BYTE1(v10) )
goto filler;
++Source;
if ( !--Count )
break;
v11 = WORD1(v10);
Source[v4] = v11;
if ( !(_BYTE)v11 )
goto filler;
++Source;
if ( !--Count )
break;
Source[v4] = BYTE1(v11);
if ( !BYTE1(v11) )
goto filler;
++Source;
--Count;
}
while ( Count );
return Destination;
}
}