#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 */
char *memcpy(char *, char const *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ strcmp(char *, char const *);
int test_memcpy(void) {
  const char *src = "hello";
  char dest[10];
  memset(dest, 'x', sizeof dest);
  do {
    if (!(dest == memcpy(dest, src, 6))) {
      printf("expression '%s' untrue at %d\n", "dest == memcpy(dest, src, 6)",
             79);
      return 0;
    }
  } while (0);
  do {
    if (!(strcmp(dest, src) == 0)) {
      printf("expression '%s' untrue at %d\n", "strcmp(dest, src) == 0", 80);
      return 0;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<test_memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x78,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x1a(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1060 <memcpy@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11b4 <test_memcpy+0x74>
lea    0xe6f(%rip),%rdi
lea    0xe86(%rip),%rsi
mov    $0x4f,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <test_memcpy+0xc5>
jmp    11b9 <test_memcpy+0x79>
jmp    11be <test_memcpy+0x7e>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11f9 <test_memcpy+0xb9>
lea    0xe2a(%rip),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x50,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1205 <test_memcpy+0xc5>
jmp    11fe <test_memcpy+0xbe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memcpy>:
push   %rbx
sub    $0x10,%rsp
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x78,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1060 <memcpy@plt>
cmp    %rax,%rbx
je     118a <test_memcpy+0x4a>
lea    0xe8a(%rip),%rdi
lea    0xea1(%rip),%rsi
mov    $0x4f,%edx
jmp    11b3 <test_memcpy+0x73>
lea    0xe6f(%rip),%rsi
lea    0x6(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c0 <test_memcpy+0x80>
lea    0xe5f(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x50,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x1,%eax
jmp    11ba <test_memcpy+0x7a>

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [29 x i8] c"dest == memcpy(dest, src, 6)\00"
@.str.3 = [23 x i8] c"strcmp(dest, src) == 0\00"
define i32 @test_memcpy() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [10 x i8]
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i8 signext 120, i32 10)
br label %6
6: ; preds = %0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i8* @memcpy(i8* %8, i8* %9, i32 6)
%11 = icmp eq i8* %7, %10
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 79)
store i32 0, i32* %1
br label %25
14: ; preds = %6
br label %15
15: ; preds = %14
br label %16
16: ; preds = %15
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %2
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 80)
store i32 0, i32* %1
br label %25
23: ; preds = %16
br label %24
24: ; preds = %23
store i32 1, i32* %1
br label %25
25: ; preds = %24, %21, %12
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [30 x i8] c"expression '%s' untrue at %d\0A\00"
@.str.2 = [29 x i8] c"dest == memcpy(dest, src, 6)\00"
@.str.3 = [23 x i8] c"strcmp(dest, src) == 0\00"
define i32 @test_memcpy() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i8 signext 120, i32 10)
%4 = call i8* @memcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6)
%5 = icmp eq i8* %2, %4
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 79)
br label %13
8: ; preds = %0
%9 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 80)
br label %13
13: ; preds = %8, %11, %6
%14 = phi i32 [ 0, %11 ], [ 0, %6 ], [ 1, %8 ]
ret i32 %14
}