#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*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ ft_memcpy(void *, char *, size_t);
scalar_t__ malloc(size_t);
void *ft_memmove(void *dst, const void *src, size_t len) {
  char *temp;
  if (!(temp = (char *)malloc(len * sizeof(char))))
    exit(1);
  ft_memcpy(temp, src, len);
  ft_memcpy(dst, temp, len);
  free(temp);
  return (dst);
}


x86 assembly (clang, -O0):
<ft_memmove>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1179 <ft_memmove+0x39>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <ft_memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <ft_memcpy@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_memmove>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     1194 <ft_memmove+0x54>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <ft_memcpy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <ft_memcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i8* @ft_memmove(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = mul i64 %8, 1
%10 = call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %7
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %3
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = load i8*, i8** %5
%18 = load i64, i64* %6
%19 = call i32 @ft_memcpy(i8* %16, i8* %17, i64 %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %7
%22 = load i64, i64* %6
%23 = call i32 @ft_memcpy(i8* %20, i8* %21, i64 %22)
%24 = load i8*, i8** %7
%25 = call i32 @free(i8* %24)
%26 = load i8*, i8** %4
ret i8* %26
}

LLVM IR (-O2):
define i8* @ft_memmove(i8* returned %0, i8* %1, i64 %2) {
%4 = tail call i64 @malloc(i64 %2)
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %3
%10 = tail call i32 @ft_memcpy(i8* %5, i8* %1, i64 %2)
%11 = tail call i32 @ft_memcpy(i8* %0, i8* %5, i64 %2)
%12 = tail call i32 @free(i8* %5)
ret i8* %0
}