#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*/ caravan();
unsigned int d(int);
int /*<<< orphan*/ emissary();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gnome();
int /*<<< orphan*/ guards();
int /*<<< orphan*/ handlers();
int /*<<< orphan*/ madduergar();
int /*<<< orphan*/ merchants();
int /*<<< orphan*/ patrol(int);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ rioters();
int /*<<< orphan*/ themberchaud();
void creature_encounter(void) {
  unsigned int d20 = d(20);
  switch (d20) {
  case 1:
  case 2:
    guards();
    break;
  case 3:
  case 4:
    gnome();
    break;
  case 5:
  case 6:
  case 7:
    rioters();
    break;
  case 8:
  case 9:
    emissary();
    break;
  case 10:
  case 11:
  case 12:
    patrol(1);
    break;
  case 13:
  case 14:
    madduergar();
    break;
  case 15:
  case 16:
    merchants();
    break;
  case 17:
  case 18:
    caravan();
    break;
  case 19:
    handlers();
    break;
  case 20:
    themberchaud();
    break;
  default:
    printf("Impossible encounter of %d\n", d20);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<creature_encounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
call   1070 <d@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     1289 <creature_encounter+0xb9>
mov    -0x10(%rbp),%rax
lea    0xdfb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <guards@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   1050 <gnome@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   10d0 <rioters@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   10a0 <emissary@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x1,%edi
call   1030 <patrol@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   10c0 <madduergar@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   10f0 <merchants@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   1040 <caravan@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   10b0 <handlers@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    $0x0,%al
call   1060 <themberchaud@plt>
jmp    12a6 <creature_encounter+0xd6>
mov    -0x4(%rbp),%esi
lea    0xdbd(%rip),%rdi
call   1080 <printf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<creature_encounter>:
push   %rax
mov    $0x14,%edi
call   1070 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x13,%ecx
ja     1246 <creature_encounter+0x76>
lea    0xe16(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
pop    %rcx
jmp    10d0 <rioters@plt>
mov    $0x1,%edi
pop    %rax
jmp    1030 <patrol@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <guards@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <gnome@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <emissary@plt>
xor    %eax,%eax
pop    %rcx
jmp    10c0 <madduergar@plt>
xor    %eax,%eax
pop    %rcx
jmp    10f0 <merchants@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <caravan@plt>
xor    %eax,%eax
pop    %rcx
jmp    10b0 <handlers@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <themberchaud@plt>
lea    0xe03(%rip),%rdi
mov    %eax,%esi
call   1080 <printf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Impossible encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @creature_encounter() {
%1 = alloca i32
%2 = call i32 @d(i32 20)
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %24 [
i32 1, label %4
i32 2, label %4
i32 3, label %6
i32 4, label %6
i32 5, label %8
i32 6, label %8
i32 7, label %8
i32 8, label %10
i32 9, label %10
i32 10, label %12
i32 11, label %12
i32 12, label %12
i32 13, label %14
i32 14, label %14
i32 15, label %16
i32 16, label %16
i32 17, label %18
i32 18, label %18
i32 19, label %20
i32 20, label %22
]
4: ; preds = %0, %0
%5 = call i32 (...) @guards()
br label %29
6: ; preds = %0, %0
%7 = call i32 (...) @gnome()
br label %29
8: ; preds = %0, %0, %0
%9 = call i32 (...) @rioters()
br label %29
10: ; preds = %0, %0
%11 = call i32 (...) @emissary()
br label %29
12: ; preds = %0, %0, %0
%13 = call i32 @patrol(i32 1)
br label %29
14: ; preds = %0, %0
%15 = call i32 (...) @madduergar()
br label %29
16: ; preds = %0, %0
%17 = call i32 (...) @merchants()
br label %29
18: ; preds = %0, %0
%19 = call i32 (...) @caravan()
br label %29
20: ; preds = %0
%21 = call i32 (...) @handlers()
br label %29
22: ; preds = %0
%23 = call i32 (...) @themberchaud()
br label %29
24: ; preds = %0
%25 = load i32, i32* %1
%26 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Impossible encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @creature_encounter() {
%1 = tail call i32 @d(i32 20)
switch i32 %1, label %22 [
i32 1, label %2
i32 2, label %2
i32 3, label %4
i32 4, label %4
i32 5, label %6
i32 6, label %6
i32 7, label %6
i32 8, label %8
i32 9, label %8
i32 10, label %10
i32 11, label %10
i32 12, label %10
i32 13, label %12
i32 14, label %12
i32 15, label %14
i32 16, label %14
i32 17, label %16
i32 18, label %16
i32 19, label %18
i32 20, label %20
]
2: ; preds = %0, %0
%3 = tail call i32 (...) @guards()
br label %26
4: ; preds = %0, %0
%5 = tail call i32 (...) @gnome()
br label %26
6: ; preds = %0, %0, %0
%7 = tail call i32 (...) @rioters()
br label %26
8: ; preds = %0, %0
%9 = tail call i32 (...) @emissary()
br label %26
10: ; preds = %0, %0, %0
%11 = tail call i32 @patrol(i32 1)
br label %26
12: ; preds = %0, %0
%13 = tail call i32 (...) @madduergar()
br label %26
14: ; preds = %0, %0
%15 = tail call i32 (...) @merchants()
br label %26
16: ; preds = %0, %0
%17 = tail call i32 (...) @caravan()
br label %26
18: ; preds = %0
%19 = tail call i32 (...) @handlers()
br label %26
20: ; preds = %0
%21 = tail call i32 (...) @themberchaud()
br label %26
22: ; preds = %0
%23 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %1)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %20, %18, %16, %14, %12, %10, %8, %6, %4, %2
ret void
}