#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;
int d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
char *randbard1lvl();
char *randcleric1lvl();
char *randdruid1lvl();
char *randpaladin1lvl();
char *randranger1lvl();
char *randsorcerer1lvl();
char *randwarlock1lvl();
char *randwizard1lvl();
char *rand1lvl(void) {
  int d8;
  d8 = d(8);
  switch (d8) {
  case 1:
    return randbard1lvl();
  case 2:
    return randcleric1lvl();
  case 3:
    return randdruid1lvl();
  case 4:
    return randpaladin1lvl();
  case 5:
    return randranger1lvl();
  case 6:
    return randsorcerer1lvl();
  case 7:
    return randwarlock1lvl();
  case 8:
    return randwizard1lvl();
  default:
    printf("Impossible random level 1 spell %d\n", d8);
    exit(EXIT_FAILURE);
  }
  return "";
}


x86 assembly (clang, -O0):
<rand1lvl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x8,%edi
call   1030 <d@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     126e <rand1lvl+0xbe>
mov    -0x18(%rbp),%rax
lea    0xe1b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <randbard1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   1040 <randcleric1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   10d0 <randdruid1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   1080 <randpaladin1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   1090 <randranger1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   1070 <randsorcerer1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   10a0 <randwarlock1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    $0x0,%al
call   10c0 <randwizard1lvl@plt>
mov    %rax,-0x8(%rbp)
jmp    128b <rand1lvl+0xdb>
mov    -0xc(%rbp),%esi
lea    0xda8(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand1lvl>:
push   %rax
mov    $0x8,%edi
call   1030 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x7,%ecx
ja     1213 <rand1lvl+0x63>
lea    0xe36(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
pop    %rcx
jmp    1060 <randbard1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    10d0 <randdruid1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    1080 <randpaladin1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <randranger1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <randcleric1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <randsorcerer1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <randwarlock1lvl@plt>
xor    %eax,%eax
pop    %rcx
jmp    10c0 <randwizard1lvl@plt>
lea    0xe06(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Impossible random level 1 spell %d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @rand1lvl() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @d(i32 8)
store i32 %3, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %21 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
i32 4, label %11
i32 5, label %13
i32 6, label %15
i32 7, label %17
i32 8, label %19
]
5: ; preds = %0
%6 = call i8* (...) @randbard1lvl()
store i8* %6, i8** %1
br label %26
7: ; preds = %0
%8 = call i8* (...) @randcleric1lvl()
store i8* %8, i8** %1
br label %26
9: ; preds = %0
%10 = call i8* (...) @randdruid1lvl()
store i8* %10, i8** %1
br label %26
11: ; preds = %0
%12 = call i8* (...) @randpaladin1lvl()
store i8* %12, i8** %1
br label %26
13: ; preds = %0
%14 = call i8* (...) @randranger1lvl()
store i8* %14, i8** %1
br label %26
15: ; preds = %0
%16 = call i8* (...) @randsorcerer1lvl()
store i8* %16, i8** %1
br label %26
17: ; preds = %0
%18 = call i8* (...) @randwarlock1lvl()
store i8* %18, i8** %1
br label %26
19: ; preds = %0
%20 = call i8* (...) @randwizard1lvl()
store i8* %20, i8** %1
br label %26
21: ; preds = %0
%22 = load i32, i32* %2
%23 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %19, %17, %15, %13, %11, %9, %7, %5
%27 = load i8*, i8** %1
ret i8* %27
}

LLVM IR (-O2):
@.str = [36 x i8] c"Impossible random level 1 spell %d\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @rand1lvl() {
%1 = tail call i32 @d(i32 8)
switch i32 %1, label %18 [
i32 1, label %2
i32 2, label %4
i32 3, label %6
i32 4, label %8
i32 5, label %10
i32 6, label %12
i32 7, label %14
i32 8, label %16
]
2: ; preds = %0
%3 = tail call i8* (...) @randbard1lvl()
br label %22
4: ; preds = %0
%5 = tail call i8* (...) @randcleric1lvl()
br label %22
6: ; preds = %0
%7 = tail call i8* (...) @randdruid1lvl()
br label %22
8: ; preds = %0
%9 = tail call i8* (...) @randpaladin1lvl()
br label %22
10: ; preds = %0
%11 = tail call i8* (...) @randranger1lvl()
br label %22
12: ; preds = %0
%13 = tail call i8* (...) @randsorcerer1lvl()
br label %22
14: ; preds = %0
%15 = tail call i8* (...) @randwarlock1lvl()
br label %22
16: ; preds = %0
%17 = tail call i8* (...) @randwizard1lvl()
br label %22
18: ; preds = %0
%19 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %1)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %16, %14, %12, %10, %8, %6, %4, %2
%23 = phi i8* [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ %3, %2 ]
ret i8* %23
}