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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x24(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x24(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xec9(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%esi
lea    0xed3(%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    0xed9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1c(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xf0d(%rip),%rdi
lea    -0x14(%rbp),%rsi
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>
lea    0xecd(%rip),%rdi
mov    %eax,%esi
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 = [43 x i8] c"[BEFORE] value is at %p and is %d(0x%08x)\0A\00"
@.str.5 = [45 x i8] c"\0A[STRCPY] copying %d 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 = [42 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
store i32 5, i32* %5
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i32, i32* %5
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32 %18, i32 %19)
%21 = load i8**, i8*** %4
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @strlen(i8* %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%27 = load i8**, i8*** %4
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @strcpy(i8* %26, i8* %29)
%31 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %7, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %31, i8* %32)
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i8* %34, i8* %35)
%37 = load i32, i32* %5
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32* %5, i32 %37, i32 %38)
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 = [43 x i8] c"[BEFORE] value is at %p and is %d(0x%08x)\0A\00"
@.str.5 = [45 x i8] c"\0A[STRCPY] copying %d 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 = [42 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*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %8, i8* %8)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %7, i8* %7)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32 5, i32 5)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = load i8*, i8** %14
%19 = call i32 @strcpy(i8* %8, i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i8* %8, i8* %8)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i8* %7, i8* %7)
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32* %3, i32 %22, i32 %22)
ret i32 0
}