#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 */
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *);
int test_memcpy(void) {
  char value0[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  char value1[10] = {11, 11, 11, 11, 11, 11, 11, 11, 11, 11};
  printf("\tmemcpy");
  memcpy(value1, value0, 5);
  if (value0[5] == value1[5])
    return 1;
  else
    printf(".");
  memcpy(value1, value0, 10);
  if (memcmp(value1, value0, 10))
    return 1;
  else
    printf(".");
  printf(" passed.\n");
  return 0;
}


x86 assembly (clang, -O0):
<test_memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb2(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x5,%edx
call   1050 <memcpy@plt>
movsbl -0x9(%rbp),%eax
movsbl -0x13(%rbp),%ecx
cmp    %ecx,%eax
jne    119e <test_memcpy+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1203 <test_memcpy+0xd3>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0xa,%edx
call   1050 <memcpy@plt>
lea    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11e4 <test_memcpy+0xb4>
movl   $0x1,-0x4(%rbp)
jmp    1203 <test_memcpy+0xd3>
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memcpy>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x807060504030201,%rax
06 07 08
mov    %rax,0x10(%rsp)
movw   $0xa09,0x18(%rsp)
movabs $0xb0b0b0b0b0b0b0b,%rax
0b 0b 0b
mov    %rax,(%rsp)
movw   $0xb0b,0x8(%rsp)
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rdi
lea    0x10(%rsp),%rsi
mov    $0x5,%edx
call   1070 <memcpy@plt>
mov    0x15(%rsp),%al
mov    $0x1,%ebx
cmp    0x5(%rsp),%al
je     1200 <test_memcpy+0xb0>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %rsp,%r14
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1070 <memcpy@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
jne    1200 <test_memcpy+0xb0>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_memcpy.value0 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0A"
@__const.test_memcpy.value1 = [10 x i8] c"\0B\0B\0B\0B\0B\0B\0B\0B\0B\0B"
@.str = [8 x i8] c"\09memcpy\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [10 x i8] c" passed.\0A\00"
define i32 @test_memcpy() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = bitcast [10 x i8]* %2 to i8*
%5 = bitcast [10 x i8]* %3 to i8*
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i32 @memcpy(i8* %7, i8* %8, i32 5)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 5
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %12, %15
br i1 %16, label %17, label %18
17: ; preds = %0
store i32 1, i32* %1
br label %33
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%23 = call i32 @memcpy(i8* %21, i8* %22, i32 10)
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%26 = call i64 @memcmp(i8* %24, i8* %25, i32 10)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 1, i32* %1
br label %33
29: ; preds = %20
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = 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 %33
33: ; preds = %31, %28, %17
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@__const.test_memcpy.value0 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0A"
@.str = [8 x i8] c"\09memcpy\00"
@str = [9 x i8] c" passed.\00"
define i32 @test_memcpy() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @memcpy(i8* %4, i8* %3, i32 5)
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 5
%8 = load i8, i8* %7
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 5
%10 = load i8, i8* %9
%11 = icmp eq i8 %8, %10
br i1 %11, label %20, label %12
12: ; preds = %0
%13 = call i32 @putchar(i32 46)
%14 = call i32 @memcpy(i8* %4, i8* %3, i32 10)
%15 = call i64 @memcmp(i8* %4, i8* %3, i32 10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = call i32 @putchar(i32 46)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %12, %0, %17
%21 = phi i32 [ 0, %17 ], [ 1, %0 ], [ 1, %12 ]
ret i32 %21
}