#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 *randdruid1lvl(void) {
  unsigned roll;
  roll = d(16);
  switch (roll) {
  case 1:
    return ("Animal Friendship");
  case 2:
    return ("Charm Person");
  case 3:
    return ("Create or Destory Water");
  case 4:
    return ("Cure Wounds");
  case 5:
    return ("Detect Magic");
  case 6:
    return ("Detect Poison and Disease");
  case 7:
    return ("Entangle");
  case 8:
    return ("Faerie Fire");
  case 9:
    return ("Fog Cloud");
  case 10:
    return ("Goodberry");
  case 11:
    return ("Healing Word");
  case 12:
    return ("Jump");
  case 13:
    return ("Longstrider");
  case 14:
    return ("Purify Food and Drink");
  case 15:
    return ("Speak with Animals");
  case 16:
    return ("Thunderwave");
  default:
    printf("Impossible random level 1 druid spell %d\n", roll);
    exit(EXIT_FAILURE);
  }
  return "";
}


x86 assembly (clang, -O0):
<randdruid1lvl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x10,%edi
call   1030 <d@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xf,%eax
ja     126e <randdruid1lvl+0x13e>
mov    -0x18(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xecd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xed2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xed5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeca(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xebe(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeb0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
lea    0xeb5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128b <randdruid1lvl+0x15b>
mov    -0xc(%rbp),%esi
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [18 x i8] c"Animal Friendship\00"
@.str.1 = [13 x i8] c"Charm Person\00"
@.str.2 = [24 x i8] c"Create or Destory Water\00"
@.str.3 = [12 x i8] c"Cure Wounds\00"
@.str.4 = [13 x i8] c"Detect Magic\00"
@.str.5 = [26 x i8] c"Detect Poison and Disease\00"
@.str.6 = [9 x i8] c"Entangle\00"
@.str.7 = [12 x i8] c"Faerie Fire\00"
@.str.8 = [10 x i8] c"Fog Cloud\00"
@.str.9 = [10 x i8] c"Goodberry\00"
@.str.10 = [13 x i8] c"Healing Word\00"
@.str.11 = [5 x i8] c"Jump\00"
@.str.12 = [12 x i8] c"Longstrider\00"
@.str.13 = [22 x i8] c"Purify Food and Drink\00"
@.str.14 = [19 x i8] c"Speak with Animals\00"
@.str.15 = [12 x i8] c"Thunderwave\00"
@.str.16 = [42 x i8] c"Impossible random level 1 druid spell %d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @randdruid1lvl() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @d(i32 16)
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %21 [
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
i32 13, label %17
i32 14, label %18
i32 15, label %19
i32 16, label %20
]
5: ; preds = %0
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8** %1
br label %26
6: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %26
7: ; preds = %0
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %26
8: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %26
9: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %26
10: ; preds = %0
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %26
11: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %1
br label %26
12: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8** %1
br label %26
13: ; preds = %0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8** %1
br label %26
14: ; preds = %0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8** %1
br label %26
15: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %26
16: ; preds = %0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %1
br label %26
17: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i8** %1
br label %26
18: ; preds = %0
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8** %1
br label %26
19: ; preds = %0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8** %1
br label %26
20: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i8** %1
br label %26
21: ; preds = %0
%22 = load i32, i32* %2
%23 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%27 = load i8*, i8** %1
ret i8* %27
}

LLVM IR (-O2):
@.str = [18 x i8] c"Animal Friendship\00"
@.str.1 = [13 x i8] c"Charm Person\00"
@.str.2 = [24 x i8] c"Create or Destory Water\00"
@.str.3 = [12 x i8] c"Cure Wounds\00"
@.str.4 = [13 x i8] c"Detect Magic\00"
@.str.5 = [26 x i8] c"Detect Poison and Disease\00"
@.str.6 = [9 x i8] c"Entangle\00"
@.str.7 = [12 x i8] c"Faerie Fire\00"
@.str.8 = [10 x i8] c"Fog Cloud\00"
@.str.9 = [10 x i8] c"Goodberry\00"
@.str.10 = [13 x i8] c"Healing Word\00"
@.str.11 = [5 x i8] c"Jump\00"
@.str.12 = [12 x i8] c"Longstrider\00"
@.str.13 = [22 x i8] c"Purify Food and Drink\00"
@.str.14 = [19 x i8] c"Speak with Animals\00"
@.str.15 = [12 x i8] c"Thunderwave\00"
@.str.16 = [42 x i8] c"Impossible random level 1 druid spell %d\0A\00"
@EXIT_FAILURE = global i32 0
@reltable.randdruid1lvl = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.2 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.3 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.4 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.5 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.7 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.8 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.10 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.11 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.12 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.13 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.14 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.15 to i64), i64 ptrtoint ([16 x i32]* @reltable.randdruid1lvl to i64)) to i32)]
define i8* @randdruid1lvl() {
%1 = tail call i32 @d(i32 16)
%2 = add i32 %1, -1
%3 = icmp ult i32 %2, 16
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, 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 ([16 x i32]* @reltable.randdruid1lvl to i8*), i64 %10)
ret i8* %11
}