#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 *, void *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  argc = (int)argc;
  int value = 5;
  char buffer_one[8], buffer_two[8];
  strcpy(buffer_one, "one");
  strcpy(buffer_two, "two");
  printf("[BEFORE] buffer_two is at %p and contains \'%s\'\n",
         (void *)buffer_two, buffer_two);
  printf("[BEFORE] buffer_one is at %p and contains \'%s\'\n",
         (void *)buffer_one, buffer_one);
  printf("[BEFORE] value is at %p and is %d (0x%08x)\n", (void *)&value, value,
         value);
  printf("\n[STRCPY] copying %u bytes into buffer_two\n\n", strlen(argv[1]));
  strcpy(buffer_two, argv[1]);
  printf("[AFTER] buffer_two is at %p and contains \'%s\'\n",
         (void *)buffer_two, buffer_two);
  printf("[AFTER] buffer_one is at %p and contains \'%s\'\n",
         (void *)buffer_one, buffer_one);
  printf("[AFTER] value is at %p and is %d (0x%08x)\n", (void *)&value, value,
         value);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x24(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x24(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x14(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x24(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x14(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r15
movl   $0x5,0x4(%rsp)
lea    0xeb3(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xea3(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe93(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecb(%rip),%rdi
lea    0x4(%rsp),%r12
mov    %r12,%rsi
mov    $0x5,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r15),%rdi
call   1040 <strlen@plt>
movslq %eax,%rsi
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r15),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xede(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xef9(%rip),%rdi
mov    %r14,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%ecx
lea    0xf10(%rip),%rdi
mov    %r12,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"one\00"
@.str.1 = [4 x i8] c"two\00"
@.str.2 = [48 x i8] c"[BEFORE] buffer_two is at %p and contains '%s'\0A\00"
@.str.3 = [48 x i8] c"[BEFORE] buffer_one is at %p and contains '%s'\0A\00"
@.str.4 = [44 x i8] c"[BEFORE] value is at %p and is %d (0x%08x)\0A\00"
@.str.5 = [45 x i8] c"\0A[STRCPY] copying %u bytes into buffer_two\0A\0A\00"
@.str.6 = [47 x i8] c"[AFTER] buffer_two is at %p and contains '%s'\0A\00"
@.str.7 = [47 x i8] c"[AFTER] buffer_one is at %p and contains '%s'\0A\00"
@.str.8 = [43 x i8] c"[AFTER] value is at %p and is %d (0x%08x)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [8 x i8]
%7 = alloca [8 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
store i32 %8, i32* %3
store i32 5, i32* %5
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %14)
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%18 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
%19 = bitcast i32* %5 to i8*
%20 = load i32, i32* %5
%21 = load i32, i32* %5
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %19, i32 %20, i32 %21)
%23 = load i8**, i8*** %4
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strlen(i8* %25)
%27 = sext i32 %26 to i64
%28 = inttoptr i64 %27 to i8*
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i32 @strcpy(i8* %30, i8* %33)
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%36 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %35, i8* %36)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%39 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i8* %38, i8* %39)
%41 = bitcast i32* %5 to i8*
%42 = load i32, i32* %5
%43 = load i32, i32* %5
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %41, i32 %42, i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"one\00"
@.str.1 = [4 x i8] c"two\00"
@.str.2 = [48 x i8] c"[BEFORE] buffer_two is at %p and contains '%s'\0A\00"
@.str.3 = [48 x i8] c"[BEFORE] buffer_one is at %p and contains '%s'\0A\00"
@.str.4 = [44 x i8] c"[BEFORE] value is at %p and is %d (0x%08x)\0A\00"
@.str.5 = [45 x i8] c"\0A[STRCPY] copying %u bytes into buffer_two\0A\0A\00"
@.str.6 = [47 x i8] c"[AFTER] buffer_two is at %p and contains '%s'\0A\00"
@.str.7 = [47 x i8] c"[AFTER] buffer_one is at %p and contains '%s'\0A\00"
@.str.8 = [43 x i8] c"[AFTER] value is at %p and is %d (0x%08x)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [8 x i8]
%5 = alloca [8 x i8]
%6 = bitcast i32* %3 to i8*
store i32 5, i32* %3
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%9 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8)
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %7)
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 5, i32 5)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %14
%21 = call i32 @strcpy(i8* %8, i8* %20)
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %8, i8* %8)
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i8* %7, i8* %7)
%24 = load i32, i32* %3
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0), i8* %6, i32 %24, i32 %24)
ret i32 0
}