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


x86 assembly (clang, -O0):
<test_memmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec2(%rip),%ax
mov    %ax,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rdi
lea    -0xe(%rbp),%rsi
add    $0x3,%rsi
mov    $0x7,%edx
call   1040 <memmove@plt>
movsbl -0xe(%rbp),%eax
cmp    $0x4,%eax
je     118f <test_memmove+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    1258 <test_memmove+0x138>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x8(%rbp),%eax
cmp    $0xa,%eax
je     11b4 <test_memmove+0x94>
movl   $0x1,-0x4(%rbp)
jmp    1258 <test_memmove+0x138>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
add    $0x3,%rdi
lea    -0x18(%rbp),%rsi
mov    $0x7,%edx
call   1040 <memmove@plt>
movsbl -0x18(%rbp),%eax
cmp    $0x1,%eax
je     11ef <test_memmove+0xcf>
movl   $0x1,-0x4(%rbp)
jmp    1258 <test_memmove+0x138>
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x15(%rbp),%eax
cmp    $0x1,%eax
je     1214 <test_memmove+0xf4>
movl   $0x1,-0x4(%rbp)
jmp    1258 <test_memmove+0x138>
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
movsbl -0xf(%rbp),%eax
cmp    $0x7,%eax
je     1239 <test_memmove+0x119>
movl   $0x1,-0x4(%rbp)
jmp    1258 <test_memmove+0x138>
lea    0xddd(%rip),%rdi
call   1030 <printf@plt>
lea    0xdd3(%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_memmove>:
push   %rbx
sub    $0x20,%rsp
movabs $0x807060504030201,%rax
06 07 08
mov    %rax,0x10(%rsp)
movw   $0xa09,0x18(%rsp)
mov    %rax,(%rsp)
movw   $0xa09,0x8(%rsp)
lea    0xe9d(%rip),%rdi
call   1050 <printf@plt>
lea    0x13(%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x7,%edx
call   1060 <memmove@plt>
mov    $0x1,%ebx
cmpb   $0x4,0x10(%rsp)
jne    11ff <test_memmove+0xbf>
mov    $0x2e,%edi
call   1030 <putchar@plt>
cmpb   $0xa,0x16(%rsp)
jne    11ff <test_memmove+0xbf>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0x3(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x7,%edx
call   1060 <memmove@plt>
cmpb   $0x1,(%rsp)
jne    11ff <test_memmove+0xbf>
mov    $0x2e,%edi
call   1030 <putchar@plt>
cmpb   $0x1,0x3(%rsp)
jne    11ff <test_memmove+0xbf>
mov    $0x2e,%edi
call   1030 <putchar@plt>
cmpb   $0x7,0x9(%rsp)
jne    11ff <test_memmove+0xbf>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xe1b(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_memmove.value0 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0A"
@__const.test_memmove.value1 = [10 x i8] c"\01\02\03\04\05\06\07\08\09\0A"
@.str = [9 x i8] c"\09memmove\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [10 x i8] c" passed.\0A\00"
define i32 @test_memmove() {
%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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%9 = call i32 @memmove(i8* %7, i8* %8, i32 7)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %15
14: ; preds = %0
store i32 1, i32* %1
br label %54
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 1, i32* %1
br label %54
23: ; preds = %17
%24 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%28 = call i32 @memmove(i8* %26, i8* %27, i32 7)
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 1
br i1 %32, label %33, label %34
33: ; preds = %25
store i32 1, i32* %1
br label %54
34: ; preds = %25
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 1, i32* %1
br label %54
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 9
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 7
br i1 %48, label %49, label %50
49: ; preds = %44
store i32 1, i32* %1
br label %54
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %52
52: ; preds = %50
%53 = 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 %54
54: ; preds = %52, %49, %41, %33, %22, %14
%55 = load i32, i32* %1
ret i32 %55
}

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