#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(void *, void const *, int);
void memcpyfast(void *dst, const void *src, int size) {
  switch (size) {
  case 1:
    *((char *)dst) = *((char *)src);
    break;
  case 2:
    *((short *)dst) = *((short *)src);
    break;
  case 3:
    memcpy(dst, src, size);
    break;
  case 4:
    *((int *)dst) = *((int *)src);
    break;
  default:
    memcpy(dst, src, size);
    break;
  }
}


x86 assembly (clang, -O0):
<memcpyfast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1196 <memcpyfast+0x86>
mov    -0x20(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    11a6 <memcpyfast+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    11a6 <memcpyfast+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
jmp    11a6 <memcpyfast+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11a6 <memcpyfast+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memcpyfast>:
lea    -0x1(%rdx),%eax
cmp    $0x3,%eax
ja     112d <memcpyfast+0x1d>
lea    0xee1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    (%rsi),%al
mov    %al,(%rdi)
ret
jmp    1030 <memcpy@plt>
movzwl (%rsi),%eax
mov    %ax,(%rdi)
ret
mov    $0x3,%edx
jmp    1030 <memcpy@plt>
mov    (%rsi),%eax
mov    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @memcpyfast(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
switch i32 %7, label %29 [
i32 1, label %8
i32 2, label %12
i32 3, label %18
i32 4, label %23
]
8: ; preds = %3
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = load i8*, i8** %4
store i8 %10, i8* %11
br label %34
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = bitcast i8* %13 to i16*
%15 = load i16, i16* %14
%16 = load i8*, i8** %4
%17 = bitcast i8* %16 to i16*
store i16 %15, i16* %17
br label %34
18: ; preds = %3
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i32 @memcpy(i8* %19, i8* %20, i32 %21)
br label %34
23: ; preds = %3
%24 = load i8*, i8** %5
%25 = bitcast i8* %24 to i32*
%26 = load i32, i32* %25
%27 = load i8*, i8** %4
%28 = bitcast i8* %27 to i32*
store i32 %26, i32* %28
br label %34
29: ; preds = %3
%30 = load i8*, i8** %4
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
br label %34
34: ; preds = %29, %23, %18, %12, %8
ret void
}

LLVM IR (-O2):
define void @memcpyfast(i8* %0, i8* %1, i32 %2) {
switch i32 %2, label %16 [
i32 1, label %4
i32 2, label %6
i32 3, label %10
i32 4, label %12
]
4: ; preds = %3
%5 = load i8, i8* %1
store i8 %5, i8* %0
br label %18
6: ; preds = %3
%7 = bitcast i8* %1 to i16*
%8 = load i16, i16* %7
%9 = bitcast i8* %0 to i16*
store i16 %8, i16* %9
br label %18
10: ; preds = %3
%11 = tail call i32 @memcpy(i8* %0, i8* %1, i32 3)
br label %18
12: ; preds = %3
%13 = bitcast i8* %1 to i32*
%14 = load i32, i32* %13
%15 = bitcast i8* %0 to i32*
store i32 %14, i32* %15
br label %18
16: ; preds = %3
%17 = tail call i32 @memcpy(i8* %0, i8* %1, i32 %2)
br label %18
18: ; preds = %16, %12, %10, %6, %4
ret void
}