#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 *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int test_strcpy(void) {
  const char *str = "string";
  char buffer[11] = "aaaaaaaaaa";
  printf("\tstrcpy");
  strcpy(buffer, str);
  if (strcmp(buffer, str))
    return 1;
  printf("\tpassed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_strcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x1b(%rbp)
mov    0xeba(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xeb2(%rip),%al
mov    %al,-0x11(%rbp)
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1b(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     119e <test_strcpy+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    11b1 <test_strcpy+0x81>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strcpy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6161616161616161,%rax
61 61 61
mov    %rax,0x8(%rsp)
movl   $0x616161,0xf(%rsp)
lea    0xead(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8f(%rip),%r14
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11a7 <test_strcpy+0x67>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"string\00"
@__const.test_strcpy.buffer = [11 x i8] c"aaaaaaaaaa\00"
@.str.1 = [8 x i8] c"\09strcpy\00"
@.str.2 = [10 x i8] c"\09passed.\0A\00"
define i32 @test_strcpy() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [11 x i8]
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = bitcast [11 x i8]* %3 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i64 @strcmp(i8* %9, i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 1, i32* %1
br label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %16
16: ; preds = %14, %13
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str = [7 x i8] c"string\00"
@__const.test_strcpy.buffer = [11 x i8] c"aaaaaaaaaa\00"
@.str.1 = [8 x i8] c"\09strcpy\00"
@str = [9 x i8] c"\09passed.\00"
define i32 @test_strcpy() {
%1 = alloca [11 x i8]
%2 = getelementptr inbounds [11 x i8], [11 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %0, %7
%10 = phi i32 [ 0, %7 ], [ 1, %0 ]
ret i32 %10
}