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


x86 assembly (clang, -O0):
<test_mempcpy>:
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
add    $0x6,%rax
mov    %rax,-0x28(%rbp)
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1060 <mempcpy@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
je     11b8 <test_mempcpy+0x78>
lea    0xe6b(%rip),%rdi
lea    0xe82(%rip),%rsi
mov    $0x5b,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1209 <test_mempcpy+0xc9>
jmp    11bd <test_mempcpy+0x7d>
jmp    11c2 <test_mempcpy+0x82>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11fd <test_mempcpy+0xbd>
lea    0xe26(%rip),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x5c,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1209 <test_mempcpy+0xc9>
jmp    1202 <test_mempcpy+0xc2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mempcpy>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x78,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0x14(%rsp),%r14
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1060 <mempcpy@plt>
cmp    %rax,%r14
je     1191 <test_mempcpy+0x51>
lea    0xe83(%rip),%rdi
lea    0xe9a(%rip),%rsi
mov    $0x5b,%edx
jmp    11ba <test_mempcpy+0x7a>
lea    0xe68(%rip),%rsi
lea    0xe(%rsp),%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c9 <test_mempcpy+0x89>
lea    0xe58(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    $0x5c,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%eax
jmp    11c1 <test_mempcpy+0x81>

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 = [34 x i8] c"&dest[6] == mempcpy(dest, src, 6)\00"
@.str.3 = [23 x i8] c"strcmp(dest, src) == 0\00"
define i32 @test_mempcpy() {
%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 6
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = load i8*, i8** %2
%10 = call i8* @mempcpy(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 ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 91)
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 92)
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 = [34 x i8] c"&dest[6] == mempcpy(dest, src, 6)\00"
@.str.3 = [23 x i8] c"strcmp(dest, src) == 0\00"
define i32 @test_mempcpy() {
%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 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
%5 = call i8* @mempcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6)
%6 = icmp eq i8* %4, %5
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 91)
br label %14
9: ; preds = %0
%10 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = 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 92)
br label %14
14: ; preds = %9, %12, %7
%15 = phi i32 [ 0, %12 ], [ 0, %7 ], [ 1, %9 ]
ret i32 %15
}