#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*/ __memcpy_aligned_up(unsigned long, unsigned long, size_t);
int /*<<< orphan*/ __memcpy_unaligned_up(unsigned long, unsigned long, size_t);
void *memcpy(void *dest, const void *src, size_t n) {
  if (!(((unsigned long)dest ^ (unsigned long)src) & 7)) {
    __memcpy_aligned_up((unsigned long)dest, (unsigned long)src, n);
    return dest;
  }
  __memcpy_unaligned_up((unsigned long)dest, (unsigned long)src, n);
  return dest;
}


x86 assembly (clang, -O0):
<memcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
xor    %rcx,%rax
and    $0x7,%rax
cmp    $0x0,%rax
jne    116b <memcpy+0x4b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <__memcpy_aligned_up@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <memcpy+0x64>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <__memcpy_unaligned_up@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpy>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%eax
xor    %ebx,%eax
test   $0x7,%al
je     1133 <memcpy+0x13>
call   1030 <__memcpy_unaligned_up@plt>
jmp    1138 <memcpy+0x18>
call   1040 <__memcpy_aligned_up@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @memcpy(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load i8*, i8** %5
%9 = ptrtoint i8* %8 to i64
%10 = load i8*, i8** %6
%11 = ptrtoint i8* %10 to i64
%12 = xor i64 %9, %11
%13 = and i64 %12, 7
%14 = icmp ne i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = ptrtoint i8* %16 to i64
%18 = load i8*, i8** %6
%19 = ptrtoint i8* %18 to i64
%20 = load i64, i64* %7
%21 = call i32 @__memcpy_aligned_up(i64 %17, i64 %19, i64 %20)
%22 = load i8*, i8** %5
store i8* %22, i8** %4
br label %31
23: ; preds = %3
%24 = load i8*, i8** %5
%25 = ptrtoint i8* %24 to i64
%26 = load i8*, i8** %6
%27 = ptrtoint i8* %26 to i64
%28 = load i64, i64* %7
%29 = call i32 @__memcpy_unaligned_up(i64 %25, i64 %27, i64 %28)
%30 = load i8*, i8** %5
store i8* %30, i8** %4
br label %31
31: ; preds = %23, %15
%32 = load i8*, i8** %4
ret i8* %32
}

LLVM IR (-O2):
define i8* @memcpy(i8* returned %0, i8* %1, i64 %2) {
%4 = ptrtoint i8* %0 to i64
%5 = ptrtoint i8* %1 to i64
%6 = xor i64 %5, %4
%7 = and i64 %6, 7
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @__memcpy_aligned_up(i64 %4, i64 %5, i64 %2)
br label %13
11: ; preds = %3
%12 = tail call i32 @__memcpy_unaligned_up(i64 %4, i64 %5, i64 %2)
br label %13
13: ; preds = %11, %9
ret i8* %0
}