#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, char *);
char *strncpy(char *, char *, int);
int main(void) {
  char dst[100] = "abcdefghijk";
  char src[100] = "123456";
  char *r = strncpy(dst + 1, src, 3);
  printf("%s, %s.\n", r, dst);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    -0x70(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x64,%edx
call   1060 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movb   $0x31,-0xe0(%rbp)
movb   $0x32,-0xdf(%rbp)
movb   $0x33,-0xde(%rbp)
movb   $0x34,-0xdd(%rbp)
movb   $0x35,-0xdc(%rbp)
movb   $0x36,-0xdb(%rbp)
lea    -0x70(%rbp),%rdi
add    $0x1,%rdi
lea    -0xe0(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xd8,%rsp
movaps 0xf22(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xf03(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe87(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x60(%rsp)
movl   $0x34333231,(%rsp)
movw   $0x3635,0x4(%rsp)
lea    0x71(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
lea    0xe8c(%rip),%rdi
lea    0x70(%rsp),%rdx
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
ret

LLVM IR (-O0):
@__const.main.dst = [100 x i8] c"abcdefghijk\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [9 x i8] c"%s, %s.\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = bitcast [100 x i8]* %1 to i8*
%5 = bitcast [100 x i8]* %2 to i8*
%6 = bitcast i8* %5 to [100 x i8]*
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 0
store i8 49, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 1
store i8 50, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 2
store i8 51, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 3
store i8 52, i8* %10
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 4
store i8 53, i8* %11
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i32 0, i32 5
store i8 54, i8* %12
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%16 = call i8* @strncpy(i8* %14, i8* %15, i32 3)
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.dst = [100 x i8] c"abcdefghijk\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [9 x i8] c"%s, %s.\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8 49, i8* %4
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
store i8 50, i8* %5
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 2
store i8 51, i8* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 3
store i8 52, i8* %7
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 4
store i8 53, i8* %8
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 5
store i8 54, i8* %9
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 1
%11 = call i8* @strncpy(i8* %10, i8* %4, i32 3)
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %3)
ret i32 0
}