#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 *randbard2lvl(void) {
  unsigned roll;
  roll = d(23);
  switch (roll) {
  case 1:
    return ("Animal Messenger");
  case 2:
    return ("Blindness");
  case 3:
    return ("Deafness");
  case 4:
    return ("Calm Emotions");
  case 5:
    return ("Cloud of Daggers");
  case 6:
    return ("Crown of Madness");
  case 7:
    return ("Detect Thoughts");
  case 8:
    return ("Enhance Ability");
  case 9:
    return ("Enthrall");
  case 10:
    return ("Heat Metal");
  case 11:
    return ("Hold Person");
  case 12:
    return ("Invisibility");
  case 13:
    return ("Knock");
  case 14:
    return ("Lesser Restoration");
  case 15:
    return ("Locate Animals or Plants");
  case 16:
    return ("Locate Object");
  case 17:
    return ("Magic Mouth");
  case 18:
    return ("Phantasmal Force");
  case 19:
    return ("See Invisibility");
  case 20:
    return ("Shatter");
  case 21:
    return ("Silence");
  case 22:
    return ("Suggestoin");
  case 23:
    return ("Zone of Truth");
  default:
    printf("Impossible random level 2 bard spell %d\n", roll);
    exit(EXIT_FAILURE);
  }
  return "";
}


x86 assembly (clang, -O0):
<randbard2lvl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x17,%edi
call   1030 <d@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x16,%eax
ja     12de <randbard2lvl+0x1ae>
mov    -0x18(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xee8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xee2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xf2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xebd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xebb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xea9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <randbard2lvl+0x1cb>
mov    -0xc(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randbard2lvl>:
push   %rax
mov    $0x17,%edi
call   1030 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x17,%ecx
jae    1156 <randbard2lvl+0x26>
movslq %ecx,%rax
lea    0x1007(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xfce(%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"Animal Messenger\00"
@.str.1 = [10 x i8] c"Blindness\00"
@.str.2 = [9 x i8] c"Deafness\00"
@.str.3 = [14 x i8] c"Calm Emotions\00"
@.str.4 = [17 x i8] c"Cloud of Daggers\00"
@.str.5 = [17 x i8] c"Crown of Madness\00"
@.str.6 = [16 x i8] c"Detect Thoughts\00"
@.str.7 = [16 x i8] c"Enhance Ability\00"
@.str.8 = [9 x i8] c"Enthrall\00"
@.str.9 = [11 x i8] c"Heat Metal\00"
@.str.10 = [12 x i8] c"Hold Person\00"
@.str.11 = [13 x i8] c"Invisibility\00"
@.str.12 = [6 x i8] c"Knock\00"
@.str.13 = [19 x i8] c"Lesser Restoration\00"
@.str.14 = [25 x i8] c"Locate Animals or Plants\00"
@.str.15 = [14 x i8] c"Locate Object\00"
@.str.16 = [12 x i8] c"Magic Mouth\00"
@.str.17 = [17 x i8] c"Phantasmal Force\00"
@.str.18 = [17 x i8] c"See Invisibility\00"
@.str.19 = [8 x i8] c"Shatter\00"
@.str.20 = [8 x i8] c"Silence\00"
@.str.21 = [11 x i8] c"Suggestoin\00"
@.str.22 = [14 x i8] c"Zone of Truth\00"
@.str.23 = [41 x i8] c"Impossible random level 2 bard spell %d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @randbard2lvl() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @d(i32 23)
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %28 [
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
i32 17, label %21
i32 18, label %22
i32 19, label %23
i32 20, label %24
i32 21, label %25
i32 22, label %26
i32 23, label %27
]
5: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %1
br label %33
6: ; preds = %0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %33
7: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %33
8: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %33
9: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %33
10: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %33
11: ; preds = %0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8** %1
br label %33
12: ; preds = %0
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8** %1
br label %33
13: ; preds = %0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i8** %1
br label %33
14: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8** %1
br label %33
15: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8** %1
br label %33
16: ; preds = %0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i8** %1
br label %33
17: ; preds = %0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8** %1
br label %33
18: ; preds = %0
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i8** %1
br label %33
19: ; preds = %0
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0), i8** %1
br label %33
20: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.15, i64 0, i64 0), i8** %1
br label %33
21: ; preds = %0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i8** %1
br label %33
22: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.17, i64 0, i64 0), i8** %1
br label %33
23: ; preds = %0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.18, i64 0, i64 0), i8** %1
br label %33
24: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.19, i64 0, i64 0), i8** %1
br label %33
25: ; preds = %0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.20, i64 0, i64 0), i8** %1
br label %33
26: ; preds = %0
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.21, i64 0, i64 0), i8** %1
br label %33
27: ; preds = %0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.22, i64 0, i64 0), i8** %1
br label %33
28: ; preds = %0
%29 = load i32, i32* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.23, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %27, %26, %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%34 = load i8*, i8** %1
ret i8* %34
}

LLVM IR (-O2):
@.str = [17 x i8] c"Animal Messenger\00"
@.str.1 = [10 x i8] c"Blindness\00"
@.str.2 = [9 x i8] c"Deafness\00"
@.str.3 = [14 x i8] c"Calm Emotions\00"
@.str.4 = [17 x i8] c"Cloud of Daggers\00"
@.str.5 = [17 x i8] c"Crown of Madness\00"
@.str.6 = [16 x i8] c"Detect Thoughts\00"
@.str.7 = [16 x i8] c"Enhance Ability\00"
@.str.8 = [9 x i8] c"Enthrall\00"
@.str.9 = [11 x i8] c"Heat Metal\00"
@.str.10 = [12 x i8] c"Hold Person\00"
@.str.11 = [13 x i8] c"Invisibility\00"
@.str.12 = [6 x i8] c"Knock\00"
@.str.13 = [19 x i8] c"Lesser Restoration\00"
@.str.14 = [25 x i8] c"Locate Animals or Plants\00"
@.str.15 = [14 x i8] c"Locate Object\00"
@.str.16 = [12 x i8] c"Magic Mouth\00"
@.str.17 = [17 x i8] c"Phantasmal Force\00"
@.str.18 = [17 x i8] c"See Invisibility\00"
@.str.19 = [8 x i8] c"Shatter\00"
@.str.20 = [8 x i8] c"Silence\00"
@.str.21 = [11 x i8] c"Suggestoin\00"
@.str.22 = [14 x i8] c"Zone of Truth\00"
@.str.23 = [41 x i8] c"Impossible random level 2 bard spell %d\0A\00"
@EXIT_FAILURE = global i32 0
@reltable.randbard2lvl = [23 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.4 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.5 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.6 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.7 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.8 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.9 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.10 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.11 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.12 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.13 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.14 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.15 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.16 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.17 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.18 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.19 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.20 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.21 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.22 to i64), i64 ptrtoint ([23 x i32]* @reltable.randbard2lvl to i64)) to i32)]
define i8* @randbard2lvl() {
%1 = tail call i32 @d(i32 23)
%2 = add i32 %1, -1
%3 = icmp ult i32 %2, 23
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.23, 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 ([23 x i32]* @reltable.randbard2lvl to i8*), i64 %10)
ret i8* %11
}