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


x86 assembly (clang, -O0):
<test_memmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeeb(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x78,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
lea    -0x1a(%rbp),%rdi
lea    0xeb7(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11b6 <test_memmove+0x76>
lea    0xe67(%rip),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x68,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1274 <test_memmove+0x134>
jmp    11bb <test_memmove+0x7b>
lea    -0x1a(%rbp),%rdi
add    $0x1,%rdi
lea    -0x1a(%rbp),%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
lea    -0x1a(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     120f <test_memmove+0xcf>
lea    0xe0e(%rip),%rdi
lea    0xe47(%rip),%rsi
mov    $0x6a,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1274 <test_memmove+0x134>
jmp    1214 <test_memmove+0xd4>
lea    -0x1a(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
add    $0x1,%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
lea    -0x1a(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1268 <test_memmove+0x128>
lea    0xdb5(%rip),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x6c,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1274 <test_memmove+0x134>
jmp    126d <test_memmove+0x12d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memmove>:
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    0xed5(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119a <test_memmove+0x5a>
lea    0xe74(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x68,%edx
jmp    1219 <test_memmove+0xd9>
lea    0xf(%rsp),%r14
lea    0xe(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11dd <test_memmove+0x9d>
lea    0xe31(%rip),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x6a,%edx
jmp    1219 <test_memmove+0xd9>
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1060 <memmove@plt>
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1228 <test_memmove+0xe8>
lea    0xdf3(%rip),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x6c,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%eax
jmp    1220 <test_memmove+0xe0>

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 = [27 x i8] c"strcmp(dest, \22hello\22) == 0\00"
@.str.3 = [7 x i8] c"hhello\00"
@.str.4 = [28 x i8] c"strcmp(dest, \22hhello\22) == 0\00"
define i32 @test_memmove() {
%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)
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @memmove(i8* %6, i8* %7, i32 6)
br label %9
9: ; preds = %0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 104)
store i32 0, i32* %1
br label %41
15: ; preds = %9
br label %16
16: ; preds = %15
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%20 = call i32 @memmove(i8* %18, i8* %19, i32 6)
br label %21
21: ; preds = %16
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 106)
store i32 0, i32* %1
br label %41
27: ; preds = %21
br label %28
28: ; preds = %27
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = call i32 @memmove(i8* %29, i8* %31, i32 6)
br label %33
33: ; preds = %28
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 108)
store i32 0, i32* %1
br label %41
39: ; preds = %33
br label %40
40: ; preds = %39
store i32 1, i32* %1
br label %41
41: ; preds = %40, %37, %25, %13
%42 = load i32, i32* %1
ret i32 %42
}

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 = [27 x i8] c"strcmp(dest, \22hello\22) == 0\00"
@.str.3 = [7 x i8] c"hhello\00"
@.str.4 = [28 x i8] c"strcmp(dest, \22hhello\22) == 0\00"
define i32 @test_memmove() {
%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 i32 @memmove(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 6)
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
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 ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 104)
br label %22
9: ; preds = %0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
%11 = call i32 @memmove(i8* %10, i8* %2, i32 6)
%12 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 106)
br label %22
16: ; preds = %9
%17 = call i32 @memmove(i8* %2, i8* %10, i32 6)
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 108)
br label %22
22: ; preds = %16, %20, %14, %7
%23 = phi i32 [ 0, %20 ], [ 0, %14 ], [ 0, %7 ], [ 1, %16 ]
ret i32 %23
}