#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*/ __generic_memcpy_fromfs(void *, void const *, unsigned long);
char get_user_byte(char const *);
int get_user_long(int const *);
short get_user_word(short const *);
void __constant_memcpy_fromfs(void *to, const void *from, unsigned long n) {
  if (n == 0) {
    return;
  } else if (n == 1) {
    *(char *)to = get_user_byte((const char *)from);
    return;
  } else if (n == 2) {
    *(short *)to = get_user_word((const short *)from);
    return;
  } else if (n == 3) {
    *(short *)to = get_user_word((const short *)from);
    *(2 + (char *)to) = get_user_byte(2 + (const char *)from);
    return;
  } else if (n == 4) {
    *(int *)to = get_user_long((const int *)from);
    return;
  }
  __generic_memcpy_fromfs(to, from, n);
}


x86 assembly (clang, -O0):
<__constant_memcpy_fromfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1164 <__constant_memcpy_fromfs+0x24>
jmp    1227 <__constant_memcpy_fromfs+0xe7>
cmpq   $0x1,-0x18(%rbp)
jne    1185 <__constant_memcpy_fromfs+0x45>
mov    -0x10(%rbp),%rdi
call   1060 <get_user_byte@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    1227 <__constant_memcpy_fromfs+0xe7>
cmpq   $0x2,-0x18(%rbp)
jne    11a8 <__constant_memcpy_fromfs+0x68>
mov    -0x10(%rbp),%rdi
call   1030 <get_user_word@plt>
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
jmp    1227 <__constant_memcpy_fromfs+0xe7>
cmpq   $0x3,-0x18(%rbp)
jne    11e1 <__constant_memcpy_fromfs+0xa1>
mov    -0x10(%rbp),%rdi
call   1030 <get_user_word@plt>
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1060 <get_user_byte@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
jmp    1227 <__constant_memcpy_fromfs+0xe7>
cmpq   $0x4,-0x18(%rbp)
jne    1202 <__constant_memcpy_fromfs+0xc2>
mov    -0x10(%rbp),%rdi
call   1050 <get_user_long@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    1227 <__constant_memcpy_fromfs+0xe7>
jmp    1207 <__constant_memcpy_fromfs+0xc7>
jmp    120c <__constant_memcpy_fromfs+0xcc>
jmp    1211 <__constant_memcpy_fromfs+0xd1>
jmp    1216 <__constant_memcpy_fromfs+0xd6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <__generic_memcpy_fromfs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__constant_memcpy_fromfs>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0x4,%rdx
ja     116d <__constant_memcpy_fromfs+0x2d>
lea    0xea9(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %rbx,%rdi
call   1060 <get_user_byte@plt>
mov    %al,(%r14)
jmp    11b6 <__constant_memcpy_fromfs+0x76>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <__generic_memcpy_fromfs@plt>
mov    %rbx,%rdi
call   1030 <get_user_word@plt>
mov    %ax,(%r14)
jmp    11b6 <__constant_memcpy_fromfs+0x76>
mov    %rbx,%rdi
call   1030 <get_user_word@plt>
mov    %ax,(%r14)
add    $0x2,%rbx
mov    %rbx,%rdi
call   1060 <get_user_byte@plt>
mov    %al,0x2(%r14)
jmp    11b6 <__constant_memcpy_fromfs+0x76>
mov    %rbx,%rdi
call   1050 <get_user_long@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @__constant_memcpy_fromfs(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %3
br label %58
10: ; preds = %3
%11 = load i64, i64* %6
%12 = icmp eq i64 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = call signext i8 @get_user_byte(i8* %14)
%16 = load i8*, i8** %4
store i8 %15, i8* %16
br label %58
17: ; preds = %10
%18 = load i64, i64* %6
%19 = icmp eq i64 %18, 2
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i8*, i8** %5
%22 = bitcast i8* %21 to i16*
%23 = call signext i16 @get_user_word(i16* %22)
%24 = load i8*, i8** %4
%25 = bitcast i8* %24 to i16*
store i16 %23, i16* %25
br label %58
26: ; preds = %17
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 3
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i8*, i8** %5
%31 = bitcast i8* %30 to i16*
%32 = call signext i16 @get_user_word(i16* %31)
%33 = load i8*, i8** %4
%34 = bitcast i8* %33 to i16*
store i16 %32, i16* %34
%35 = load i8*, i8** %5
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = call signext i8 @get_user_byte(i8* %36)
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 2
store i8 %37, i8* %39
br label %58
40: ; preds = %26
%41 = load i64, i64* %6
%42 = icmp eq i64 %41, 4
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i8*, i8** %5
%45 = bitcast i8* %44 to i32*
%46 = call i32 @get_user_long(i32* %45)
%47 = load i8*, i8** %4
%48 = bitcast i8* %47 to i32*
store i32 %46, i32* %48
br label %58
49: ; preds = %40
br label %50
50: ; preds = %49
br label %51
51: ; preds = %50
br label %52
52: ; preds = %51
br label %53
53: ; preds = %52
%54 = load i8*, i8** %4
%55 = load i8*, i8** %5
%56 = load i64, i64* %6
%57 = call i32 @__generic_memcpy_fromfs(i8* %54, i8* %55, i64 %56)
br label %58
58: ; preds = %53, %43, %29, %20, %13, %9
ret void
}

LLVM IR (-O2):
define void @__constant_memcpy_fromfs(i8* %0, i8* %1, i64 %2) {
switch i64 %2, label %21 [
i64 0, label %23
i64 1, label %4
i64 2, label %6
i64 3, label %10
i64 4, label %17
]
4: ; preds = %3
%5 = tail call signext i8 @get_user_byte(i8* %1)
store i8 %5, i8* %0
br label %23
6: ; preds = %3
%7 = bitcast i8* %1 to i16*
%8 = tail call signext i16 @get_user_word(i16* %7)
%9 = bitcast i8* %0 to i16*
store i16 %8, i16* %9
br label %23
10: ; preds = %3
%11 = bitcast i8* %1 to i16*
%12 = tail call signext i16 @get_user_word(i16* %11)
%13 = bitcast i8* %0 to i16*
store i16 %12, i16* %13
%14 = getelementptr inbounds i8, i8* %1, i64 2
%15 = tail call signext i8 @get_user_byte(i8* %14)
%16 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %15, i8* %16
br label %23
17: ; preds = %3
%18 = bitcast i8* %1 to i32*
%19 = tail call i32 @get_user_long(i32* %18)
%20 = bitcast i8* %0 to i32*
store i32 %19, i32* %20
br label %23
21: ; preds = %3
%22 = tail call i32 @__generic_memcpy_fromfs(i8* %0, i8* %1, i64 %2)
br label %23
23: ; preds = %3, %21, %17, %10, %6, %4
ret void
}