#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*/ destination;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int main() {
  int i = 0;
  char destination[] = "********************";
  printf("strlen(destination) -> %d\n", strlen(destination));
  const char *source = "-----";
  strncpy(destination, source, 5);
  printf("%s\n", destination);
  strncpy(destination, source, 6);
  printf("%s\n", destination);
  strncpy(destination, source, 10);
  printf("-> %s\n", destination);
  printf("sizeof(destination)%d\n", sizeof(destination));
  printf("--> %c\n", destination[sizeof(destination) - 2]);
  printf("--> %c\n", destination[strlen(destination) - 1]);
  for (; i < sizeof(destination); ++i) {
    printf("%d%c\t", i, destination[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xea9(%rip),%al
mov    %al,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea2(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe38(%rip),%rdi
mov    $0x15,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0xd(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x8(%rbp),%rax
cmp    $0x15,%rax
jae    127a <main+0x14a>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edx
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1244 <main+0x114>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x2a2a2a2a2a2a2a,%rax
mov    %rax,0xd(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xea2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xead(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1030 <strncpy@plt>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x15,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x13(%rsp),%esi
lea    0xe61(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl (%rsp),%edx
lea    0xe3b(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x1(%rsp),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x2(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x3(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x4(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x5(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x6(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x7(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x8(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x9(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xa(%rsp),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xb(%rsp),%edx
mov    %rbx,%rdi
mov    $0xb,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xc(%rsp),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xd(%rsp),%edx
mov    %rbx,%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xe(%rsp),%edx
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0xf(%rsp),%edx
mov    %rbx,%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x10(%rsp),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x11(%rsp),%edx
mov    %rbx,%rdi
mov    $0x11,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x12(%rsp),%edx
mov    %rbx,%rdi
mov    $0x12,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x13(%rsp),%edx
mov    %rbx,%rdi
mov    $0x13,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsbl 0x14(%rsp),%edx
mov    %rbx,%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.destination = [21 x i8] c"********************\00"
@.str = [27 x i8] c"strlen(destination) -> %d\0A\00"
@.str.1 = [6 x i8] c"-----\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [7 x i8] c"-> %s\0A\00"
@.str.4 = [23 x i8] c"sizeof(destination)%d\0A\00"
@.str.5 = [8 x i8] c"--> %c\0A\00"
@.str.6 = [6 x i8] c"%d%c\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [21 x i8]
%4 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
%5 = bitcast [21 x i8]* %3 to i8*
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%7 = call i32 @strlen(i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %7)
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strncpy(i8* %9, i8* %10, i32 5)
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = call i32 @strncpy(i8* %14, i8* %15, i32 6)
%17 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%20 = load i8*, i8** %4
%21 = call i32 @strncpy(i8* %19, i8* %20, i32 10)
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 21)
%25 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 19
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %49, %0
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = icmp ult i64 %39, 21
br i1 %40, label %41, label %52
41: ; preds = %37
%42 = load i32, i32* %2
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %42, i32 %47)
br label %49
49: ; preds = %41
%50 = load i32, i32* %2
%51 = add nsw i32 %50, 1
store i32 %51, i32* %2
br label %37
52: ; preds = %37
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@__const.main.destination = [21 x i8] c"********************\00"
@.str = [27 x i8] c"strlen(destination) -> %d\0A\00"
@.str.1 = [6 x i8] c"-----\00"
@.str.3 = [7 x i8] c"-> %s\0A\00"
@.str.4 = [23 x i8] c"sizeof(destination)%d\0A\00"
@.str.5 = [8 x i8] c"--> %c\0A\00"
@.str.6 = [6 x i8] c"%d%c\09\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%6 = call i32 @puts(i8* %2)
%7 = call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 6)
%8 = call i32 @puts(i8* %2)
%9 = call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 10)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 21)
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 19
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = call i32 @strlen(i8* %2)
%17 = add nsw i32 %16, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %21)
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 %24)
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 1
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 %28)
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 %32)
%34 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 3
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 %36)
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 4
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 %40)
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5, i32 %44)
%46 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 6
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 6, i32 %48)
%50 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 7
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 7, i32 %52)
%54 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 8
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 8, i32 %56)
%58 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 9
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 9, i32 %60)
%62 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 10
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 10, i32 %64)
%66 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 11
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 11, i32 %68)
%70 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 12
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 12, i32 %72)
%74 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 13
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 13, i32 %76)
%78 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 14
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 14, i32 %80)
%82 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 15
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 15, i32 %84)
%86 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 16
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 16, i32 %88)
%90 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 17
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 17, i32 %92)
%94 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 18
%95 = load i8, i8* %94
%96 = sext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 18, i32 %96)
%98 = load i8, i8* %12
%99 = sext i8 %98 to i32
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 19, i32 %99)
%101 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 20
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 20, i32 %103)
ret i32 0
}