#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;
  if (value0[6] != 10)
    return 1;
  memmove(&value1[3], &value1[0], 7);
  if (value1[0] != 1)
    return 1;
  if (value1[3] != 1)
    return 1;
  if (value1[9] != 7)
    return 1;
  printf("\tpassed.\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    121c <test_memmove+0xfc>
movsbl -0x8(%rbp),%eax
cmp    $0xa,%eax
je     11a8 <test_memmove+0x88>
movl   $0x1,-0x4(%rbp)
jmp    121c <test_memmove+0xfc>
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     11d7 <test_memmove+0xb7>
movl   $0x1,-0x4(%rbp)
jmp    121c <test_memmove+0xfc>
movsbl -0x15(%rbp),%eax
cmp    $0x1,%eax
je     11f0 <test_memmove+0xd0>
movl   $0x1,-0x4(%rbp)
jmp    121c <test_memmove+0xfc>
movsbl -0xf(%rbp),%eax
cmp    $0x7,%eax
je     1209 <test_memmove+0xe9>
movl   $0x1,-0x4(%rbp)
jmp    121c <test_memmove+0xfc>
lea    0xe0d(%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    0xead(%rip),%rdi
call   1040 <printf@plt>
lea    0x13(%rsp),%rsi
lea    0x10(%rsp),%rdi
mov    $0x7,%edx
call   1050 <memmove@plt>
cmpb   $0x4,0x10(%rsp)
mov    $0x1,%ebx
jne    11bd <test_memmove+0x8d>
cmpb   $0xa,0x16(%rsp)
jne    11bd <test_memmove+0x8d>
lea    0x3(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x7,%edx
call   1050 <memmove@plt>
cmpb   $0x1,(%rsp)
jne    11bd <test_memmove+0x8d>
cmpb   $0x1,0x3(%rsp)
jne    11bd <test_memmove+0x8d>
cmpb   $0x7,0x9(%rsp)
jne    11bd <test_memmove+0x8d>
lea    0xe5d(%rip),%rdi
call   1030 <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 = [10 x i8] c"\09passed.\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 %44
15: ; preds = %0
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 1, i32* %1
br label %44
21: ; preds = %15
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%24 = call i32 @memmove(i8* %22, i8* %23, i32 7)
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 1, i32* %1
br label %44
30: ; preds = %21
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 1
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 1, i32* %1
br label %44
36: ; preds = %30
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 9
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 7
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 1, i32* %1
br label %44
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %44
44: ; preds = %42, %41, %35, %29, %20, %14
%45 = load i32, i32* %1
ret i32 %45
}

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"\09passed.\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
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 6
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
%13 = select i1 %9, i1 %12, i1 false
br i1 %13, label %14, label %28
14: ; preds = %0
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%16 = call i32 @memmove(i8* %15, i8* %4, i32 7)
%17 = load i8, i8* %4
%18 = icmp eq i8 %17, 1
%19 = load i8, i8* %15
%20 = icmp eq i8 %19, 1
%21 = select i1 %18, i1 %20, i1 false
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 7
%25 = select i1 %21, i1 %24, i1 false
br i1 %25, label %26, label %28
26: ; preds = %14
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %14, %0, %26
%29 = phi i32 [ 0, %26 ], [ 1, %0 ], [ 1, %14 ]
ret i32 %29
}