#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*/ strncpy(char *, char const *, int);
int main(int argc, char *argv[]) {
  char buf[64] = "abcdefghijklmnopqrstuvwxyz";
  const char *src = "helloworld";
  strncpy(buf, src, 0);
  strncpy(buf, src, 5);
  strncpy(buf, src, 10);
  strncpy(buf, src, 11);
  strncpy(buf, src, 12);
  strncpy(buf, src, 20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    0xeee(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
xor    %edx,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xb,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xc,%edx
call   1030 <strncpy@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xef6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xef3(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.buf = [64 x i8] c"abcdefghijklmnopqrstuvwxyz\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 = [11 x i8] c"helloworld\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [64 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [64 x i8]* %6 to i8*
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %7
%11 = call i32 @strncpy(i8* %9, i8* %10, i32 0)
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%13 = load i8*, i8** %7
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 5)
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%16 = load i8*, i8** %7
%17 = call i32 @strncpy(i8* %15, i8* %16, i32 10)
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%19 = load i8*, i8** %7
%20 = call i32 @strncpy(i8* %18, i8* %19, i32 11)
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%22 = load i8*, i8** %7
%23 = call i32 @strncpy(i8* %21, i8* %22, i32 12)
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%25 = load i8*, i8** %7
%26 = call i32 @strncpy(i8* %24, i8* %25, i32 20)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [64 x i8] c"abcdefghijklmnopqrstuvwxyz\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 = [11 x i8] c"helloworld\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%8 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11)
%9 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 12)
%10 = call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 20)
ret i32 0
}