#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 */
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ strlcpy(char *, char const *, int);
int main(int argc, char *argv[]) {
  char buf[64] = "abcdefghijklmnopqrstuvwxyz";
  const char *src = "helloworld";
  ssize_t len;
  len = strlcpy(buf, src, 0);
  printf("cp %d ret %zu buf %s\n", 0, len, buf);
  len = strlcpy(buf, src, 5);
  printf("cp %d ret %zu buf %s\n", 5, len, buf);
  len = strlcpy(buf, src, 10);
  printf("cp %d ret %zu buf %s\n", 10, len, buf);
  len = strlcpy(buf, src, 11);
  printf("cp %d ret %zu buf %s\n", 11, len, buf);
  len = strlcpy(buf, src, 12);
  printf("cp %d ret %zu buf %s\n", 12, len, buf);
  len = strlcpy(buf, src, 20);
  printf("cp %d ret %zu buf %s\n", 20, len, buf);
  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    0xeaf(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
lea    0xede(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
xor    %edx,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xec5(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0x5,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xe9b(%rip),%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xe6e(%rip),%rdi
mov    $0xa,%esi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xb,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xe41(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0xc,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xe14(%rip),%rdi
mov    $0xc,%esi
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    $0x14,%edx
call   1050 <strlcpy@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%edx
lea    -0x50(%rbp),%rcx
lea    0xde7(%rip),%rdi
mov    $0x14,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xf00(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee1(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strlcpy@plt>
lea    0xed5(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    $0x5,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    $0xa,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    $0xb,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xc,%edx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    $0xc,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x14,%edx
call   1040 <strlcpy@plt>
mov    %r15,%rdi
mov    $0x14,%esi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
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"
@.str.1 = [22 x i8] c"cp %d ret %zu buf %s\0A\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*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [64 x i8]* %6 to i8*
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%11 = load i8*, i8** %7
%12 = call i32 @strlcpy(i8* %10, i8* %11, i32 0)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %13, i8* %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %7
%18 = call i32 @strlcpy(i8* %16, i8* %17, i32 5)
store i32 %18, i32* %8
%19 = load i32, i32* %8
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %19, i8* %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%23 = load i8*, i8** %7
%24 = call i32 @strlcpy(i8* %22, i8* %23, i32 10)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 %25, i8* %26)
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%29 = load i8*, i8** %7
%30 = call i32 @strlcpy(i8* %28, i8* %29, i32 11)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 11, i32 %31, i8* %32)
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%35 = load i8*, i8** %7
%36 = call i32 @strlcpy(i8* %34, i8* %35, i32 12)
store i32 %36, i32* %8
%37 = load i32, i32* %8
%38 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 12, i32 %37, i8* %38)
%40 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%41 = load i8*, i8** %7
%42 = call i32 @strlcpy(i8* %40, i8* %41, i32 20)
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %43, i8* %44)
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"
@.str.1 = [22 x i8] c"cp %d ret %zu buf %s\0A\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 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0)
%6 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %5, i8* %4)
%7 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %7, i8* %4)
%9 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 10, i32 %9, i8* %4)
%11 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 11)
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 11, i32 %11, i8* %4)
%13 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 12)
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 12, i32 %13, i8* %4)
%15 = call i32 @strlcpy(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 20)
%16 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 %15, i8* %4)
ret i32 0
}