#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*/ gasspore(int);
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ shrieker(int);
int /*<<< orphan*/ violetfungi(int);
void fungi(unsigned d6) {
  int d4;
  switch (d6) {
  case 1:
  case 2:
    gasspore(d(4));
    d4 = d(4);
    if (d4 == 1) {
      niceprint(
          "The gas spore caries a memory fragment of a dead beholder.\n\n");
      d4 = d(4);
      switch (d4) {
      case 1:
        niceprint("It is a memory of a tense negotiation "
                  "with drow, ending with the beholder agreeing to allow the "
                  "drow safe passage thorugh \"the Vast Oblivium\" in exchange "
                  "for help ridding its lair of a deep gnome infestation.\n\n");
        break;
      case 2:
        niceprint("It is a memory of chasing svirfneblin thieves "
                  "through the tunnels of its domain to recover stolen "
                  "gemstones.\n\n");
        break;
      case 3:
        niceprint("It is a memory of a fierce battle against "
                  "a wizened drow archmage, ending with the beholder suffering "
                  "a grievous injury.\n\n");
        break;
      case 4:
        niceprint("It is a memory of spying on a drow ranger "
                  "with two gleaming scimitars and a black, quadrupedal animal "
                  "companion.\n\n");
        break;
      default:
        printf("Impossible beholder memory %d\n", d4);
        exit(EXIT_FAILURE);
      }
    }
    break;
  case 3:
  case 4:
    shrieker(d(4));
    break;
  case 5:
  case 6:
    violetfungi(d(4));
    break;
  default:
    printf("Impossible fungi encounter of %d\n", d6);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<fungi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     11ba <fungi+0x4a>
jmp    1192 <fungi+0x22>
mov    -0xc(%rbp),%eax
add    $0xfffffffd,%eax
sub    $0x2,%eax
jb     128f <fungi+0x11f>
jmp    11a6 <fungi+0x36>
mov    -0xc(%rbp),%eax
add    $0xfffffffb,%eax
sub    $0x2,%eax
jb     12a5 <fungi+0x135>
jmp    12bb <fungi+0x14b>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1060 <gasspore@plt>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    128a <fungi+0x11a>
lea    0xe27(%rip),%rdi
call   1070 <niceprint@plt>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1268 <fungi+0xf8>
mov    -0x18(%rbp),%rax
lea    0xde5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe22(%rip),%rdi
call   1070 <niceprint@plt>
jmp    1285 <fungi+0x115>
lea    0xee4(%rip),%rdi
call   1070 <niceprint@plt>
jmp    1285 <fungi+0x115>
lea    0xf42(%rip),%rdi
call   1070 <niceprint@plt>
jmp    1285 <fungi+0x115>
lea    0xfac(%rip),%rdi
call   1070 <niceprint@plt>
jmp    1285 <fungi+0x115>
mov    -0x8(%rbp),%esi
lea    0x100b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    128a <fungi+0x11a>
jmp    12d8 <fungi+0x168>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1080 <shrieker@plt>
jmp    12d8 <fungi+0x168>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1050 <violetfungi@plt>
jmp    12d8 <fungi+0x168>
mov    -0x4(%rbp),%esi
lea    0xfd7(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fungi>:
push   %rax
mov    %edi,%esi
cmp    $0x6,%edi
ja     1246 <fungi+0xd6>
mov    $0x6,%eax
bt     %esi,%eax
jb     11b0 <fungi+0x40>
mov    $0x18,%eax
bt     %esi,%eax
jb     120b <fungi+0x9b>
mov    $0x60,%eax
bt     %esi,%eax
jae    1246 <fungi+0xd6>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rax
jmp    1050 <violetfungi@plt>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1060 <gasspore@plt>
mov    $0x4,%edi
call   1030 <d@plt>
cmp    $0x1,%eax
jne    121d <fungi+0xad>
lea    0xe39(%rip),%rdi
call   1070 <niceprint@plt>
mov    $0x4,%edi
call   1030 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
ja     124f <fungi+0xdf>
lea    0xe0b(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe48(%rip),%rdi
pop    %rax
jmp    1070 <niceprint@plt>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rax
jmp    1080 <shrieker@plt>
pop    %rax
ret
lea    0xf69(%rip),%rdi
pop    %rax
jmp    1070 <niceprint@plt>
lea    0xeed(%rip),%rdi
pop    %rax
jmp    1070 <niceprint@plt>
lea    0xfca(%rip),%rdi
pop    %rax
jmp    1070 <niceprint@plt>
lea    0x104f(%rip),%rdi
jmp    1258 <fungi+0xe8>
lea    0x1027(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [61 x i8] c"The gas spore caries a memory fragment of a dead beholder.\0A\0A\00"
@.str.1 = [211 x i8] c"It is a memory of a tense negotiation with drow, ending with the beholder agreeing to allow the drow safe passage thorugh \22the Vast Oblivium\22 in exchange for help ridding its lair of a deep gnome infestation.\0A\0A\00"
@.str.2 = [111 x i8] c"It is a memory of chasing svirfneblin thieves through the tunnels of its domain to recover stolen gemstones.\0A\0A\00"
@.str.3 = [123 x i8] c"It is a memory of a fierce battle against a wizened drow archmage, ending with the beholder suffering a grievous injury.\0A\0A\00"
@.str.4 = [115 x i8] c"It is a memory of spying on a drow ranger with two gleaming scimitars and a black, quadrupedal animal companion.\0A\0A\00"
@.str.5 = [31 x i8] c"Impossible beholder memory %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [34 x i8] c"Impossible fungi encounter of %d\0A\00"
define void @fungi(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %36 [
i32 1, label %5
i32 2, label %5
i32 3, label %30
i32 4, label %30
i32 5, label %33
i32 6, label %33
]
5: ; preds = %1, %1
%6 = call i32 @d(i32 4)
%7 = call i32 @gasspore(i32 %6)
%8 = call i32 @d(i32 4)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %29
11: ; preds = %5
%12 = call i32 @niceprint(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @d(i32 4)
store i32 %13, i32* %3
%14 = load i32, i32* %3
switch i32 %14, label %23 [
i32 1, label %15
i32 2, label %17
i32 3, label %19
i32 4, label %21
]
15: ; preds = %11
%16 = call i32 @niceprint(i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str.1, i64 0, i64 0))
br label %28
17: ; preds = %11
%18 = call i32 @niceprint(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.2, i64 0, i64 0))
br label %28
19: ; preds = %11
%20 = call i32 @niceprint(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.3, i64 0, i64 0))
br label %28
21: ; preds = %11
%22 = call i32 @niceprint(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.4, i64 0, i64 0))
br label %28
23: ; preds = %11
%24 = load i32, i32* %3
%25 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %21, %19, %17, %15
br label %29
29: ; preds = %28, %5
br label %41
30: ; preds = %1, %1
%31 = call i32 @d(i32 4)
%32 = call i32 @shrieker(i32 %31)
br label %41
33: ; preds = %1, %1
%34 = call i32 @d(i32 4)
%35 = call i32 @violetfungi(i32 %34)
br label %41
36: ; preds = %1
%37 = load i32, i32* %2
%38 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %33, %30, %29
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"The gas spore caries a memory fragment of a dead beholder.\0A\0A\00"
@.str.1 = [211 x i8] c"It is a memory of a tense negotiation with drow, ending with the beholder agreeing to allow the drow safe passage thorugh \22the Vast Oblivium\22 in exchange for help ridding its lair of a deep gnome infestation.\0A\0A\00"
@.str.2 = [111 x i8] c"It is a memory of chasing svirfneblin thieves through the tunnels of its domain to recover stolen gemstones.\0A\0A\00"
@.str.3 = [123 x i8] c"It is a memory of a fierce battle against a wizened drow archmage, ending with the beholder suffering a grievous injury.\0A\0A\00"
@.str.4 = [115 x i8] c"It is a memory of spying on a drow ranger with two gleaming scimitars and a black, quadrupedal animal companion.\0A\0A\00"
@.str.5 = [31 x i8] c"Impossible beholder memory %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.6 = [34 x i8] c"Impossible fungi encounter of %d\0A\00"
define void @fungi(i32 %0) {
switch i32 %0, label %28 [
i32 1, label %2
i32 2, label %2
i32 3, label %22
i32 4, label %22
i32 5, label %25
i32 6, label %25
]
2: ; preds = %1, %1
%3 = tail call i32 @d(i32 4)
%4 = tail call i32 @gasspore(i32 %3)
%5 = tail call i32 @d(i32 4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %32
7: ; preds = %2
%8 = tail call i32 @niceprint(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @d(i32 4)
switch i32 %9, label %18 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
]
10: ; preds = %7
%11 = tail call i32 @niceprint(i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str.1, i64 0, i64 0))
br label %32
12: ; preds = %7
%13 = tail call i32 @niceprint(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.2, i64 0, i64 0))
br label %32
14: ; preds = %7
%15 = tail call i32 @niceprint(i8* getelementptr inbounds ([123 x i8], [123 x i8]* @.str.3, i64 0, i64 0))
br label %32
16: ; preds = %7
%17 = tail call i32 @niceprint(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.4, i64 0, i64 0))
br label %32
18: ; preds = %7
%19 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %9)
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %1, %1
%23 = tail call i32 @d(i32 4)
%24 = tail call i32 @shrieker(i32 %23)
br label %32
25: ; preds = %1, %1
%26 = tail call i32 @d(i32 4)
%27 = tail call i32 @violetfungi(i32 %26)
br label %32
28: ; preds = %1
%29 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %0)
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %2, %16, %14, %12, %10, %25, %22
ret void
}