#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 */
typedef scalar_t__ XPointer;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
void _XlcCopyFromArg(char *src, char *dst, int size) {
  if (size == sizeof(long))
    *((long *)dst) = (long)src;
  else if (size == sizeof(short))
    *((short *)dst) = (short)(long)src;
  else if (size == sizeof(char))
    *((char *)dst) = (char)(long)src;
  else if (size == sizeof(XPointer))
    *((XPointer *)dst) = (XPointer)src;
  else if (size > sizeof(XPointer))
    memcpy(dst, (char *)src, size);
  else
    memcpy(dst, (char *)&src, size);
}


x86 assembly (clang, -O0):
<_XlcCopyFromArg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jne    1141 <_XlcCopyFromArg+0x31>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11e6 <_XlcCopyFromArg+0xd6>
movslq -0x14(%rbp),%rax
cmp    $0x2,%rax
jne    1162 <_XlcCopyFromArg+0x52>
mov    -0x8(%rbp),%rax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
jmp    11e1 <_XlcCopyFromArg+0xd1>
movslq -0x14(%rbp),%rax
cmp    $0x1,%rax
jne    1181 <_XlcCopyFromArg+0x71>
mov    -0x8(%rbp),%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    11dc <_XlcCopyFromArg+0xcc>
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jne    119f <_XlcCopyFromArg+0x8f>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11d7 <_XlcCopyFromArg+0xc7>
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jbe    11c2 <_XlcCopyFromArg+0xb2>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
jmp    11d2 <_XlcCopyFromArg+0xc2>
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
jmp    11d7 <_XlcCopyFromArg+0xc7>
jmp    11dc <_XlcCopyFromArg+0xcc>
jmp    11e1 <_XlcCopyFromArg+0xd1>
jmp    11e6 <_XlcCopyFromArg+0xd6>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_XlcCopyFromArg>:
push   %rax
mov    %rdi,%rax
mov    %rdi,(%rsp)
cmp    $0x1,%edx
je     112c <_XlcCopyFromArg+0x1c>
cmp    $0x2,%edx
je     1130 <_XlcCopyFromArg+0x20>
cmp    $0x8,%edx
jne    1135 <_XlcCopyFromArg+0x25>
mov    %rax,(%rsi)
pop    %rax
ret
mov    %al,(%rsi)
pop    %rax
ret
mov    %ax,(%rsi)
pop    %rax
ret
jbe    1143 <_XlcCopyFromArg+0x33>
mov    %rsi,%rdi
mov    %rax,%rsi
pop    %rax
jmp    1030 <memcpy@plt>
mov    %rsp,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <memcpy@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @_XlcCopyFromArg(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
%8 = sext i32 %7 to i64
%9 = icmp eq i64 %8, 8
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = ptrtoint i8* %11 to i64
%13 = load i8*, i8** %5
%14 = bitcast i8* %13 to i64*
store i64 %12, i64* %14
br label %61
15: ; preds = %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = icmp eq i64 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i8*, i8** %4
%21 = ptrtoint i8* %20 to i64
%22 = trunc i64 %21 to i16
%23 = load i8*, i8** %5
%24 = bitcast i8* %23 to i16*
store i16 %22, i16* %24
br label %60
25: ; preds = %15
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = icmp eq i64 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i8
%33 = load i8*, i8** %5
store i8 %32, i8* %33
br label %59
34: ; preds = %25
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = icmp eq i64 %36, 8
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i8*, i8** %4
%40 = ptrtoint i8* %39 to i64
%41 = load i8*, i8** %5
%42 = bitcast i8* %41 to i64*
store i64 %40, i64* %42
br label %58
43: ; preds = %34
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = icmp ugt i64 %45, 8
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i8*, i8** %5
%49 = load i8*, i8** %4
%50 = load i32, i32* %6
%51 = call i32 @memcpy(i8* %48, i8* %49, i32 %50)
br label %57
52: ; preds = %43
%53 = load i8*, i8** %5
%54 = bitcast i8** %4 to i8*
%55 = load i32, i32* %6
%56 = call i32 @memcpy(i8* %53, i8* %54, i32 %55)
br label %57
57: ; preds = %52, %47
br label %58
58: ; preds = %57, %38
br label %59
59: ; preds = %58, %29
br label %60
60: ; preds = %59, %19
br label %61
61: ; preds = %60, %10
ret void
}

LLVM IR (-O2):
define void @_XlcCopyFromArg(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
store i8* %0, i8** %4
switch i32 %2, label %15 [
i32 8, label %5
i32 2, label %8
i32 1, label %12
]
5: ; preds = %3
%6 = ptrtoint i8* %0 to i64
%7 = bitcast i8* %1 to i64*
store i64 %6, i64* %7
br label %22
8: ; preds = %3
%9 = ptrtoint i8* %0 to i64
%10 = trunc i64 %9 to i16
%11 = bitcast i8* %1 to i16*
store i16 %10, i16* %11
br label %22
12: ; preds = %3
%13 = ptrtoint i8* %0 to i64
%14 = trunc i64 %13 to i8
store i8 %14, i8* %1
br label %22
15: ; preds = %3
%16 = icmp ugt i32 %2, 8
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %2)
br label %22
19: ; preds = %15
%20 = bitcast i8** %4 to i8*
%21 = call i32 @memcpy(i8* %1, i8* %20, i32 %2)
br label %22
22: ; preds = %8, %19, %17, %12, %5
ret void
}