#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 /*<<< orphan*/ bandit(int);
int /*<<< orphan*/ banditcaptain(int);
int d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ eyeofgruumsh(int);
int /*<<< orphan*/ goblin(int);
int /*<<< orphan*/ goblinboss(int);
int /*<<< orphan*/ magictableb();
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ orc(int);
int /*<<< orphan*/ printf(char *, ...);
void raiders(unsigned d6) {
  int d20;
  niceprint(
      "A group of raiders from the surface ventured into the Underdark looking "
      "for riches and got lost. They are initially hostile toward the party, "
      "though clever characters might try bribing them for safe passage or "
      "information.\n\n");
  switch (d6) {
  case 1:
  case 2:
    bandit(d(6));
    banditcaptain(1);
    break;
  case 3:
  case 4:
    goblin(d(4) + d(4));
    goblinboss(1);
    break;
  case 5:
  case 6:
    orc(d(6));
    eyeofgruumsh(1);
    break;
  default:
    printf("Impossible raider encounter of %d\n", d6);
    exit(EXIT_FAILURE);
  }
  d20 = d(20);
  if (d20 < 6)
    return;
  printf("The leader of the group has something of interest:\n\n");
  if (d20 < 11)
    printf("%d 10gp gemstones in a pouch\n", (d(6) + d(6)));
  else if (d20 < 15)
    printf("%d 50gp gemstones in a pouch\n", (d(6) + d(6)));
  else if (d20 < 18)
    printf("%d tourchstalks\n", d(4));
  else if (d20 < 20)
    printf("%d waterorbs\n", d(4));
  else
    magictableb();
}


x86 assembly (clang, -O0):
<raiders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe3e(%rip),%rdi
call   10a0 <niceprint@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     1206 <raiders+0x56>
jmp    11de <raiders+0x2e>
mov    -0xc(%rbp),%eax
add    $0xfffffffd,%eax
sub    $0x2,%eax
jb     1226 <raiders+0x76>
jmp    11f2 <raiders+0x42>
mov    -0xc(%rbp),%eax
add    $0xfffffffb,%eax
sub    $0x2,%eax
jb     1256 <raiders+0xa6>
jmp    1276 <raiders+0xc6>
mov    $0x6,%edi
call   1040 <d@plt>
mov    %eax,%edi
call   1030 <bandit@plt>
mov    $0x1,%edi
call   10d0 <banditcaptain@plt>
jmp    1295 <raiders+0xe5>
mov    $0x4,%edi
call   1040 <d@plt>
mov    %eax,-0x10(%rbp)
mov    $0x4,%edi
call   1040 <d@plt>
mov    -0x10(%rbp),%edi
add    %eax,%edi
call   1080 <goblin@plt>
mov    $0x1,%edi
call   1070 <goblinboss@plt>
jmp    1295 <raiders+0xe5>
mov    $0x6,%edi
call   1040 <d@plt>
mov    %eax,%edi
call   1050 <orc@plt>
mov    $0x1,%edi
call   1090 <eyeofgruumsh@plt>
jmp    1295 <raiders+0xe5>
mov    -0x4(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x14,%edi
call   1040 <d@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6,-0x8(%rbp)
jge    12b1 <raiders+0x101>
jmp    1399 <raiders+0x1e9>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0xb,-0x8(%rbp)
jge    12f8 <raiders+0x148>
mov    $0x6,%edi
call   1040 <d@plt>
mov    %eax,-0x14(%rbp)
mov    $0x6,%edi
call   1040 <d@plt>
mov    -0x14(%rbp),%esi
add    %eax,%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1399 <raiders+0x1e9>
cmpl   $0xf,-0x8(%rbp)
jge    1331 <raiders+0x181>
mov    $0x6,%edi
call   1040 <d@plt>
mov    %eax,-0x18(%rbp)
mov    $0x6,%edi
call   1040 <d@plt>
mov    -0x18(%rbp),%esi
add    %eax,%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1394 <raiders+0x1e4>
cmpl   $0x12,-0x8(%rbp)
jge    135a <raiders+0x1aa>
mov    $0x4,%edi
call   1040 <d@plt>
mov    %eax,%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138f <raiders+0x1df>
cmpl   $0x14,-0x8(%rbp)
jge    1383 <raiders+0x1d3>
mov    $0x4,%edi
call   1040 <d@plt>
mov    %eax,%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    138a <raiders+0x1da>
mov    $0x0,%al
call   10c0 <magictableb@plt>
jmp    138f <raiders+0x1df>
jmp    1394 <raiders+0x1e4>
jmp    1399 <raiders+0x1e9>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raiders>:
push   %rbx
mov    %edi,%ebx
lea    0xe36(%rip),%rdi
call   10b0 <niceprint@plt>
cmp    $0x6,%ebx
ja     130c <raiders+0x14c>
mov    $0x6,%eax
bt     %ebx,%eax
jb     1217 <raiders+0x57>
mov    $0x18,%eax
bt     %ebx,%eax
jb     1234 <raiders+0x74>
mov    $0x60,%eax
bt     %ebx,%eax
jae    130c <raiders+0x14c>
mov    $0x6,%edi
call   1050 <d@plt>
mov    %eax,%edi
call   1060 <orc@plt>
mov    $0x1,%edi
call   10a0 <eyeofgruumsh@plt>
jmp    125d <raiders+0x9d>
mov    $0x6,%edi
call   1050 <d@plt>
mov    %eax,%edi
call   1030 <bandit@plt>
mov    $0x1,%edi
call   10e0 <banditcaptain@plt>
jmp    125d <raiders+0x9d>
mov    $0x4,%edi
call   1050 <d@plt>
mov    %eax,%ebx
mov    $0x4,%edi
call   1050 <d@plt>
add    %eax,%ebx
mov    %ebx,%edi
call   1090 <goblin@plt>
mov    $0x1,%edi
call   1080 <goblinboss@plt>
mov    $0x14,%edi
call   1050 <d@plt>
cmp    $0x6,%eax
jge    126e <raiders+0xae>
pop    %rbx
ret
mov    %eax,%ebx
lea    0xee8(%rip),%rdi
call   1040 <puts@plt>
cmp    $0xa,%ebx
ja     12a2 <raiders+0xe2>
mov    $0x6,%edi
call   1050 <d@plt>
mov    %eax,%ebx
mov    $0x6,%edi
call   1050 <d@plt>
add    %eax,%ebx
lea    0xe64(%rip),%rdi
jmp    12c6 <raiders+0x106>
cmp    $0xe,%ebx
ja     12d0 <raiders+0x110>
mov    $0x6,%edi
call   1050 <d@plt>
mov    %eax,%ebx
mov    $0x6,%edi
call   1050 <d@plt>
add    %eax,%ebx
lea    0xe5c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1070 <printf@plt>
cmp    $0x11,%ebx
ja     12ea <raiders+0x12a>
mov    $0x4,%edi
call   1050 <d@plt>
lea    0xe5a(%rip),%rdi
mov    %eax,%esi
jmp    12c8 <raiders+0x108>
cmp    $0x13,%ebx
ja     1304 <raiders+0x144>
mov    $0x4,%edi
call   1050 <d@plt>
lea    0xe51(%rip),%rdi
mov    %eax,%esi
jmp    12c8 <raiders+0x108>
xor    %eax,%eax
pop    %rbx
jmp    10d0 <magictableb@plt>
lea    0xdce(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [225 x i8] c"A group of raiders from the surface ventured into the Underdark looking for riches and got lost. They are initially hostile toward the party, though clever characters might try bribing them for safe passage or information.\0A\0A\00"
@.str.1 = [35 x i8] c"Impossible raider encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [53 x i8] c"The leader of the group has something of interest:\0A\0A\00"
@.str.3 = [30 x i8] c"%d 10gp gemstones in a pouch\0A\00"
@.str.4 = [30 x i8] c"%d 50gp gemstones in a pouch\0A\00"
@.str.5 = [17 x i8] c"%d tourchstalks\0A\00"
@.str.6 = [14 x i8] c"%d waterorbs\0A\00"
define void @raiders(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @niceprint(i8* getelementptr inbounds ([225 x i8], [225 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* %2
switch i32 %5, label %20 [
i32 1, label %6
i32 2, label %6
i32 3, label %10
i32 4, label %10
i32 5, label %16
i32 6, label %16
]
6: ; preds = %1, %1
%7 = call i32 @d(i32 6)
%8 = call i32 @bandit(i32 %7)
%9 = call i32 @banditcaptain(i32 1)
br label %25
10: ; preds = %1, %1
%11 = call i32 @d(i32 4)
%12 = call i32 @d(i32 4)
%13 = add nsw i32 %11, %12
%14 = call i32 @goblin(i32 %13)
%15 = call i32 @goblinboss(i32 1)
br label %25
16: ; preds = %1, %1
%17 = call i32 @d(i32 6)
%18 = call i32 @orc(i32 %17)
%19 = call i32 @eyeofgruumsh(i32 1)
br label %25
20: ; preds = %1
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16, %10, %6
%26 = call i32 @d(i32 20)
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp slt i32 %27, 6
br i1 %28, label %29, label %30
29: ; preds = %25
br label %64
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 11
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = call i32 @d(i32 6)
%36 = call i32 @d(i32 6)
%37 = add nsw i32 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %64
39: ; preds = %30
%40 = load i32, i32* %3
%41 = icmp slt i32 %40, 15
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = call i32 @d(i32 6)
%44 = call i32 @d(i32 6)
%45 = add nsw i32 %43, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %45)
br label %63
47: ; preds = %39
%48 = load i32, i32* %3
%49 = icmp slt i32 %48, 18
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = call i32 @d(i32 4)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %51)
br label %62
53: ; preds = %47
%54 = load i32, i32* %3
%55 = icmp slt i32 %54, 20
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = call i32 @d(i32 4)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %57)
br label %61
59: ; preds = %53
%60 = call i32 (...) @magictableb()
br label %61
61: ; preds = %59, %56
br label %62
62: ; preds = %61, %50
br label %63
63: ; preds = %62, %42
br label %64
64: ; preds = %29, %63, %34
ret void
}

LLVM IR (-O2):
@.str = [225 x i8] c"A group of raiders from the surface ventured into the Underdark looking for riches and got lost. They are initially hostile toward the party, though clever characters might try bribing them for safe passage or information.\0A\0A\00"
@.str.1 = [35 x i8] c"Impossible raider encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [30 x i8] c"%d 10gp gemstones in a pouch\0A\00"
@.str.4 = [30 x i8] c"%d 50gp gemstones in a pouch\0A\00"
@.str.5 = [17 x i8] c"%d tourchstalks\0A\00"
@.str.6 = [14 x i8] c"%d waterorbs\0A\00"
@str = [52 x i8] c"The leader of the group has something of interest:\0A\00"
define void @raiders(i32 %0) {
%2 = tail call i32 @niceprint(i8* getelementptr inbounds ([225 x i8], [225 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %17 [
i32 1, label %3
i32 2, label %3
i32 3, label %7
i32 4, label %7
i32 5, label %13
i32 6, label %13
]
3: ; preds = %1, %1
%4 = tail call i32 @d(i32 6)
%5 = tail call i32 @bandit(i32 %4)
%6 = tail call i32 @banditcaptain(i32 1)
br label %21
7: ; preds = %1, %1
%8 = tail call i32 @d(i32 4)
%9 = tail call i32 @d(i32 4)
%10 = add nsw i32 %9, %8
%11 = tail call i32 @goblin(i32 %10)
%12 = tail call i32 @goblinboss(i32 1)
br label %21
13: ; preds = %1, %1
%14 = tail call i32 @d(i32 6)
%15 = tail call i32 @orc(i32 %14)
%16 = tail call i32 @eyeofgruumsh(i32 1)
br label %21
17: ; preds = %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %13, %7, %3
%22 = tail call i32 @d(i32 20)
%23 = icmp slt i32 %22, 6
br i1 %23, label %51, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%26 = icmp ult i32 %22, 11
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = tail call i32 @d(i32 6)
%29 = tail call i32 @d(i32 6)
%30 = add nsw i32 %29, %28
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %51
32: ; preds = %24
%33 = icmp ult i32 %22, 15
br i1 %33, label %34, label %39
34: ; preds = %32
%35 = tail call i32 @d(i32 6)
%36 = tail call i32 @d(i32 6)
%37 = add nsw i32 %36, %35
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %51
39: ; preds = %32
%40 = icmp ult i32 %22, 18
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = tail call i32 @d(i32 4)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %51
44: ; preds = %39
%45 = icmp ult i32 %22, 20
br i1 %45, label %46, label %49
46: ; preds = %44
%47 = tail call i32 @d(i32 4)
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %44
%50 = tail call i32 (...) @magictableb()
br label %51
51: ; preds = %27, %41, %49, %46, %34, %21
ret void
}