#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*/ EXIT_FAILURE;
unsigned int d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned int);
char *randwarlock2lvl(void) {
  unsigned roll;
  roll = d(12);
  switch (roll) {
  case 1:
    return ("Cloud of Daggers");
  case 2:
    return ("Crown of Madness");
  case 3:
    return ("Darkness");
  case 4:
    return ("Enthrall");
  case 5:
    return ("Hold Person");
  case 6:
    return ("Invisibility");
  case 7:
    return ("Mirror Image");
  case 8:
    return ("Misty Step");
  case 9:
    return ("Ray of Enfeeblement");
  case 10:
    return ("Shatter");
  case 11:
    return ("Spider Climb");
  case 12:
    return ("Suggestion");
  default:
    printf("Impossible random level 2 warlock spell %d\n", roll);
    exit(EXIT_FAILURE);
  }
  return "";
}


x86 assembly (clang, -O0):
<randwarlock2lvl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xc,%edi
call   1030 <d@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xb,%eax
ja     122e <randwarlock2lvl+0xfe>
mov    -0x18(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xebc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xeb6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xeaf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xeab(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xea8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xea5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xea0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    124b <randwarlock2lvl+0x11b>
mov    -0xc(%rbp),%esi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randwarlock2lvl>:
push   %rax
mov    $0xc,%edi
call   1030 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0xc,%ecx
jae    1156 <randwarlock2lvl+0x26>
movslq %ecx,%rax
lea    0xf7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xf3c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Cloud of Daggers\00"
@.str.1 = [17 x i8] c"Crown of Madness\00"
@.str.2 = [9 x i8] c"Darkness\00"
@.str.3 = [9 x i8] c"Enthrall\00"
@.str.4 = [12 x i8] c"Hold Person\00"
@.str.5 = [13 x i8] c"Invisibility\00"
@.str.6 = [13 x i8] c"Mirror Image\00"
@.str.7 = [11 x i8] c"Misty Step\00"
@.str.8 = [20 x i8] c"Ray of Enfeeblement\00"
@.str.9 = [8 x i8] c"Shatter\00"
@.str.10 = [13 x i8] c"Spider Climb\00"
@.str.11 = [11 x i8] c"Suggestion\00"
@.str.12 = [44 x i8] c"Impossible random level 2 warlock spell %d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @randwarlock2lvl() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @d(i32 12)
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %17 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
i32 9, label %13
i32 10, label %14
i32 11, label %15
i32 12, label %16
]
5: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %1
br label %22
6: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %22
7: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %22
8: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %22
9: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %22
10: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %22
11: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %1
br label %22
12: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8** %1
br label %22
13: ; preds = %0
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8** %1
br label %22
14: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), i8** %1
br label %22
15: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %22
16: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8** %1
br label %22
17: ; preds = %0
%18 = load i32, i32* %2
%19 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%23 = load i8*, i8** %1
ret i8* %23
}

LLVM IR (-O2):
@.str = [17 x i8] c"Cloud of Daggers\00"
@.str.1 = [17 x i8] c"Crown of Madness\00"
@.str.2 = [9 x i8] c"Darkness\00"
@.str.3 = [9 x i8] c"Enthrall\00"
@.str.4 = [12 x i8] c"Hold Person\00"
@.str.5 = [13 x i8] c"Invisibility\00"
@.str.6 = [13 x i8] c"Mirror Image\00"
@.str.7 = [11 x i8] c"Misty Step\00"
@.str.8 = [20 x i8] c"Ray of Enfeeblement\00"
@.str.9 = [8 x i8] c"Shatter\00"
@.str.10 = [13 x i8] c"Spider Climb\00"
@.str.11 = [11 x i8] c"Suggestion\00"
@.str.12 = [44 x i8] c"Impossible random level 2 warlock spell %d\0A\00"
@EXIT_FAILURE = global i32 0
@reltable.randwarlock2lvl = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.randwarlock2lvl to i64)) to i32)]
define i8* @randwarlock2lvl() {
%1 = tail call i32 @d(i32 12)
%2 = add i32 %1, -1
%3 = icmp ult i32 %2, 12
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.12, i64 0, i64 0), i32 %1)
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %0
%9 = sext i32 %2 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.randwarlock2lvl to i8*), i64 %10)
ret i8* %11
}