#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 d(int);
int /*<<< orphan*/ printf(char *, ...);
char *rand0lvl();
char *rand1lvl();
char *rand2lvl();
void magictablea(void) {
  int d100;
  d100 = d(100);
  if (d100 < 51)
    printf("Potion of healing (2d4 + 2) [DM 188]\n");
  else if (d100 < 61)
    printf("'%s' Spell scroll (cantrip) (Save DC 13, +5 Attack) [DM 200]\n",
           rand0lvl());
  else if (d100 < 71)
    printf("Potion of climbing [DM 187]\n");
  else if (d100 < 91)
    printf("'%s' Spell scroll (1st level) (Save DC 13, +5 Attack) [DM 200]\n",
           rand1lvl());
  else if (d100 < 95)
    printf("'%s' Spell scroll (2nd level) (Save DC 13, +5 Attack) [DM 200]\n",
           rand2lvl());
  else if (d100 < 99)
    printf("Potion of greater healing (4d4 +4 [DM 188]\n");
  else if (d100 < 100)
    printf("Bag of holding [DM 153]\n");
  else
    printf("Driftglobe (light source) [DM 166]\n");
}


x86 assembly (clang, -O0):
<magictablea>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x64,%edi
call   1030 <d@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x33,-0x4(%rbp)
jge    1182 <magictablea+0x32>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127a <magictablea+0x12a>
cmpl   $0x3d,-0x4(%rbp)
jge    11a9 <magictablea+0x59>
mov    $0x0,%al
call   1070 <rand0lvl@plt>
mov    %rax,%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1275 <magictablea+0x125>
cmpl   $0x47,-0x4(%rbp)
jge    11c6 <magictablea+0x76>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1270 <magictablea+0x120>
cmpl   $0x5b,-0x4(%rbp)
jge    11ed <magictablea+0x9d>
mov    $0x0,%al
call   1050 <rand1lvl@plt>
mov    %rax,%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    126b <magictablea+0x11b>
cmpl   $0x5f,-0x4(%rbp)
jge    1214 <magictablea+0xc4>
mov    $0x0,%al
call   1060 <rand2lvl@plt>
mov    %rax,%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1266 <magictablea+0x116>
cmpl   $0x63,-0x4(%rbp)
jge    1231 <magictablea+0xe1>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1261 <magictablea+0x111>
cmpl   $0x64,-0x4(%rbp)
jge    124e <magictablea+0xfe>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <magictablea+0x10c>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1261 <magictablea+0x111>
jmp    1266 <magictablea+0x116>
jmp    126b <magictablea+0x11b>
jmp    1270 <magictablea+0x120>
jmp    1275 <magictablea+0x125>
jmp    127a <magictablea+0x12a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<magictablea>:
push   %rax
mov    $0x64,%edi
call   1040 <d@plt>
cmp    $0x32,%eax
jg     117d <magictablea+0x1d>
lea    0xfc9(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
cmp    $0x3c,%eax
ja     1192 <magictablea+0x32>
xor    %eax,%eax
call   1080 <rand0lvl@plt>
lea    0xe70(%rip),%rdi
jmp    11cc <magictablea+0x6c>
cmp    $0x46,%eax
ja     11a4 <magictablea+0x44>
lea    0xf86(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
cmp    $0x5a,%eax
ja     11b9 <magictablea+0x59>
xor    %eax,%eax
call   1060 <rand1lvl@plt>
lea    0xe87(%rip),%rdi
jmp    11cc <magictablea+0x6c>
cmp    $0x5e,%eax
ja     11d7 <magictablea+0x77>
xor    %eax,%eax
call   1070 <rand2lvl@plt>
lea    0xeb2(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
pop    %rcx
jmp    1050 <printf@plt>
cmp    $0x62,%eax
ja     11e9 <magictablea+0x89>
lea    0xf16(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
cmp    $0x63,%eax
jne    11fb <magictablea+0x9b>
lea    0xeec(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>
lea    0xebc(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Potion of healing (2d4 + 2) [DM 188]\0A\00"
@.str.1 = [62 x i8] c"'%s' Spell scroll (cantrip) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@.str.2 = [29 x i8] c"Potion of climbing [DM 187]\0A\00"
@.str.3 = [64 x i8] c"'%s' Spell scroll (1st level) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@.str.4 = [64 x i8] c"'%s' Spell scroll (2nd level) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@.str.5 = [44 x i8] c"Potion of greater healing (4d4 +4 [DM 188]\0A\00"
@.str.6 = [25 x i8] c"Bag of holding [DM 153]\0A\00"
@.str.7 = [36 x i8] c"Driftglobe (light source) [DM 166]\0A\00"
define void @magictablea() {
%1 = alloca i32
%2 = call i32 @d(i32 100)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 51
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %48
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 61
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i8* (...) @rand0lvl()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %47
13: ; preds = %7
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 71
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %46
18: ; preds = %13
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 91
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = call i8* (...) @rand1lvl()
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %45
24: ; preds = %18
%25 = load i32, i32* %1
%26 = icmp slt i32 %25, 95
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i8* (...) @rand2lvl()
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %44
30: ; preds = %24
%31 = load i32, i32* %1
%32 = icmp slt i32 %31, 99
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
br label %43
35: ; preds = %30
%36 = load i32, i32* %1
%37 = icmp slt i32 %36, 100
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %42
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %33
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44, %21
br label %46
46: ; preds = %45, %16
br label %47
47: ; preds = %46, %10
br label %48
48: ; preds = %47, %5
ret void
}

LLVM IR (-O2):
@.str.1 = [62 x i8] c"'%s' Spell scroll (cantrip) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@.str.3 = [64 x i8] c"'%s' Spell scroll (1st level) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@.str.4 = [64 x i8] c"'%s' Spell scroll (2nd level) (Save DC 13, +5 Attack) [DM 200]\0A\00"
@str = [35 x i8] c"Driftglobe (light source) [DM 166]\00"
@str.8 = [24 x i8] c"Bag of holding [DM 153]\00"
@str.9 = [43 x i8] c"Potion of greater healing (4d4 +4 [DM 188]\00"
@str.10 = [28 x i8] c"Potion of climbing [DM 187]\00"
@str.11 = [37 x i8] c"Potion of healing (2d4 + 2) [DM 188]\00"
define void @magictablea() {
%1 = tail call i32 @d(i32 100)
%2 = icmp slt i32 %1, 51
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
br label %34
5: ; preds = %0
%6 = icmp ult i32 %1, 61
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = tail call i8* (...) @rand0lvl()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %34
10: ; preds = %5
%11 = icmp ult i32 %1, 71
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0))
br label %34
14: ; preds = %10
%15 = icmp ult i32 %1, 91
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = tail call i8* (...) @rand1lvl()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %34
19: ; preds = %14
%20 = icmp ult i32 %1, 95
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = tail call i8* (...) @rand2lvl()
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0), i8* %22)
br label %34
24: ; preds = %19
%25 = icmp ult i32 %1, 99
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
br label %34
28: ; preds = %24
%29 = icmp eq i32 %1, 99
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.8, i64 0, i64 0))
br label %34
32: ; preds = %28
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %7, %16, %26, %32, %30, %21, %12, %3
ret void
}