#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int plasma_element_size(int type) {
  switch (type) {
  case 0:
    return 1;
  case 1:
    return sizeof(int);
  case 2:
    return sizeof(float);
  case 3:
    return sizeof(double);
  case 4:
    return 2 * sizeof(float);
  case 5:
    return 2 * sizeof(double);
  default:
    fprintf(stderr, "plasma_element_size: invalide type parameter\n");
    return -1;
  }
}


x86 assembly (clang, -O0):
<plasma_element_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     1188 <plasma_element_size+0x78>
mov    -0x10(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
movl   $0x4,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
movl   $0x4,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
movl   $0x8,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
movl   $0x8,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
movl   $0x10,-0x4(%rbp)
jmp    11a4 <plasma_element_size+0x94>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plasma_element_size>:
push   %rax
cmp    $0x6,%edi
jae    1125 <plasma_element_size+0x15>
movslq %edi,%rax
lea    0xf10(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
lea    0xecb(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"plasma_element_size: invalide type parameter\0A\00"
define i32 @plasma_element_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %11 [
i32 0, label %5
i32 1, label %6
i32 2, label %7
i32 3, label %8
i32 4, label %9
i32 5, label %10
]
5: ; preds = %1
store i32 1, i32* %2
br label %14
6: ; preds = %1
store i32 4, i32* %2
br label %14
7: ; preds = %1
store i32 4, i32* %2
br label %14
8: ; preds = %1
store i32 8, i32* %2
br label %14
9: ; preds = %1
store i32 8, i32* %2
br label %14
10: ; preds = %1
store i32 16, i32* %2
br label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %14
14: ; preds = %11, %10, %9, %8, %7, %6, %5
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"plasma_element_size: invalide type parameter\0A\00"
@switch.table.plasma_element_size = [6 x i32] [i32 1, i32 4, i32 4, i32 8, i32 8, i32 16]
define i32 @plasma_element_size(i32 %0) {
%2 = icmp ult i32 %0, 6
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %1
%7 = sext i32 %0 to i64
%8 = getelementptr inbounds [6 x i32], [6 x i32]* @switch.table.plasma_element_size, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %6, %3
%11 = phi i32 [ -1, %3 ], [ %9, %6 ]
ret i32 %11
}