#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 */
void *mymemmove(void *dest, const void *src, size_t n) {
  char temp[n];
  int i;
  char *d = dest;
  const char *s = src;
  for (i = 0; i < n; i++)
    temp[i] = s[i];
  for (i = 0; i < n; i++)
    d[i] = temp[i];
  return dest;
}


x86 assembly (clang, -O0):
<mymemmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1184 <mymemmove+0x84>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,1),%dl
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1152 <mymemmove+0x52>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11bd <mymemmove+0xbd>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118b <mymemmove+0x8b>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mymemmove>:
push   %rbx
mov    %rdi,%rbx
test   %rdx,%rdx
je     1121 <mymemmove+0x11>
mov    %rbx,%rdi
call   1030 <memmove@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @mymemmove(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%12 = load i64, i64* %6
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
%15 = load i8*, i8** %4
store i8* %15, i8** %10
%16 = load i8*, i8** %5
store i8* %16, i8** %11
store i32 0, i32* %9
br label %17
17: ; preds = %31, %3
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = load i64, i64* %6
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %17
%23 = load i8*, i8** %11
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %14, i64 %29
store i8 %27, i8* %30
br label %31
31: ; preds = %22
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %17
34: ; preds = %17
store i32 0, i32* %9
br label %35
35: ; preds = %49, %34
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = load i64, i64* %6
%39 = icmp ult i64 %37, %38
br i1 %39, label %40, label %52
40: ; preds = %35
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %14, i64 %42
%44 = load i8, i8* %43
%45 = load i8*, i8** %10
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
store i8 %44, i8* %48
br label %49
49: ; preds = %40
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %35
52: ; preds = %35
%53 = load i8*, i8** %4
%54 = load i8*, i8** %7
ret i8* %53
}

LLVM IR (-O2):
define i8* @mymemmove(i8* returned writeonly %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %6, label %5
5: ; preds = %3
br label %6
6: ; preds = %3, %5
ret i8* %0
}