#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 */
typedef int /*<<< orphan*/ dst1;

/* Variables and functions */
char *ft_memmove(char *, char *, int);
scalar_t__ memcmp(char *, char *, int);
char *memmove(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void test_memmove() {
  printf("-----------------------ft_memmove\n");
  char *src = "thi\xffs i\xfas \0a g\xde\xadood \0nyan\0cat\0 !\r\n";
  int size = 33;
  char dst1[0xF0];
  char dst2[0xF0];
  char *ret1;
  char *ret2;
  ret1 = memmove(dst1, src, sizeof(dst1));
  ret2 = ft_memmove(dst2, src, size);
  if (memcmp(ret1, ret2, 33) != 0) {
    printf(">>>>>>>FAIL<<<<<<<\n");
    printf("   memmove = %s\n", ret1);
    printf("ft_memmove = %s\n", ret2);
  } else
    printf(">>>>>SUCCESS<<<<<\n");
}


x86 assembly (clang, -O0):
<test_memmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x21,-0xc(%rbp)
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0xf0,%edx
call   1060 <memmove@plt>
mov    %rax,-0x1f8(%rbp)
lea    -0x1f0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <ft_memmove@plt>
mov    %rax,-0x200(%rbp)
mov    -0x1f8(%rbp),%rdi
mov    -0x200(%rbp),%rsi
mov    $0x21,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1200 <test_memmove+0xc0>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1f8(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x200(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120e <test_memmove+0xce>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memmove>:
push   %r14
push   %rbx
sub    $0x1e8,%rsp
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rbx
lea    0xf0(%rsp),%rdi
mov    %rbx,%rsi
mov    $0xf0,%edx
call   1070 <memmove@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x21,%edx
call   1060 <ft_memmove@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x21,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11dd <test_memmove+0x8d>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe63(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e9 <test_memmove+0x99>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
add    $0x1e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [35 x i8] c"-----------------------ft_memmove\0A\00"
@.str.1 = [35 x i8] c"thi\FFs i\FAs \00a g\DE\ADood \00nyan\00cat\00 !\0D\0A\00"
@.str.2 = [20 x i8] c">>>>>>>FAIL<<<<<<<\0A\00"
@.str.3 = [17 x i8] c" memmove = %s\0A\00"
@.str.4 = [17 x i8] c"ft_memmove = %s\0A\00"
@.str.5 = [19 x i8] c">>>>>SUCCESS<<<<<\0A\00"
define void @test_memmove() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca [240 x i8]
%4 = alloca [240 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8** %1
store i32 33, i32* %2
%8 = getelementptr inbounds [240 x i8], [240 x i8]* %3, i64 0, i64 0
%9 = load i8*, i8** %1
%10 = call i8* @memmove(i8* %8, i8* %9, i32 240)
store i8* %10, i8** %5
%11 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 0
%12 = load i8*, i8** %1
%13 = load i32, i32* %2
%14 = call i8* @ft_memmove(i8* %11, i8* %12, i32 %13)
store i8* %14, i8** %6
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = call i64 @memcmp(i8* %15, i8* %16, i32 33)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%21 = load i8*, i8** %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %19
ret void
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"thi\FFs i\FAs \00a g\DE\ADood \00nyan\00cat\00 !\0D\0A\00"
@.str.3 = [17 x i8] c" memmove = %s\0A\00"
@.str.4 = [17 x i8] c"ft_memmove = %s\0A\00"
@str = [34 x i8] c"-----------------------ft_memmove\00"
@str.6 = [18 x i8] c">>>>>SUCCESS<<<<<\00"
@str.7 = [19 x i8] c">>>>>>>FAIL<<<<<<<\00"
define void @test_memmove() {
%1 = alloca [240 x i8]
%2 = alloca [240 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [240 x i8], [240 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [240 x i8], [240 x i8]* %2, i64 0, i64 0
%6 = call i8* @memmove(i8* %4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 240)
%7 = call i8* @ft_memmove(i8* %5, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 33)
%8 = call i64 @memcmp(i8* %6, i8* %7, i32 33)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %7)
br label %16
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
ret void
}