#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*/ boneyard();
int /*<<< orphan*/ bridge();
int /*<<< orphan*/ cliff();
int /*<<< orphan*/ crystal();
unsigned int d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fungus();
int /*<<< orphan*/ gas();
int /*<<< orphan*/ gorge();
int /*<<< orphan*/ lava();
int /*<<< orphan*/ ledge();
int /*<<< orphan*/ muck();
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ rockfall();
int /*<<< orphan*/ ruins();
int /*<<< orphan*/ shelter();
int /*<<< orphan*/ sinkhole();
int /*<<< orphan*/ slime();
int /*<<< orphan*/ sounds();
int /*<<< orphan*/ stream();
int /*<<< orphan*/ vent();
int /*<<< orphan*/ warning();
int /*<<< orphan*/ webs();
void terrain_encounter(void) {
  unsigned d20;
  d20 = d(20);
  switch (d20) {
  case 1:
    boneyard();
    break;
  case 2:
    cliff();
    break;
  case 3:
    crystal();
    break;
  case 4:
    fungus();
    break;
  case 5:
    gas();
    break;
  case 6:
    gorge();
    break;
  case 7:
    ledge();
    break;
  case 8:
    sounds();
    break;
  case 9:
    lava();
    break;
  case 10:
    muck();
    break;
  case 11:
    rockfall();
    break;
  case 12:
    bridge();
    break;
  case 13:
    ruins();
    break;
  case 14:
    shelter();
    break;
  case 15:
    sinkhole();
    break;
  case 16:
    slime();
    break;
  case 17:
    vent();
    break;
  case 18:
    stream();
    break;
  case 19:
    warning();
    break;
  case 20:
    webs();
    break;
  default:
    printf("Impossible terrain encounter of %d\n", d20);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<terrain_encounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
call   1040 <d@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     139e <terrain_encounter+0x12e>
mov    -0x10(%rbp),%rax
lea    0xd5b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1050 <boneyard@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10d0 <cliff@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1060 <crystal@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1180 <fungus@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10f0 <gas@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10c0 <gorge@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10a0 <ledge@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1120 <sounds@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10e0 <lava@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1100 <muck@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1150 <rockfall@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1110 <bridge@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1090 <ruins@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1190 <shelter@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1140 <sinkhole@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1170 <slime@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1130 <vent@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   10b0 <stream@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1030 <warning@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    $0x0,%al
call   1080 <webs@plt>
jmp    13bb <terrain_encounter+0x14b>
mov    -0x4(%rbp),%esi
lea    0xca8(%rip),%rdi
call   1070 <printf@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<terrain_encounter>:
push   %rax
mov    $0x14,%edi
call   1040 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x13,%ecx
ja     1337 <terrain_encounter+0xc7>
lea    0xd72(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
pop    %rcx
jmp    1050 <boneyard@plt>
xor    %eax,%eax
pop    %rcx
jmp    10d0 <cliff@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <crystal@plt>
xor    %eax,%eax
pop    %rcx
jmp    1180 <fungus@plt>
xor    %eax,%eax
pop    %rcx
jmp    10f0 <gas@plt>
xor    %eax,%eax
pop    %rcx
jmp    10c0 <gorge@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <ledge@plt>
xor    %eax,%eax
pop    %rcx
jmp    1120 <sounds@plt>
xor    %eax,%eax
pop    %rcx
jmp    10e0 <lava@plt>
xor    %eax,%eax
pop    %rcx
jmp    1100 <muck@plt>
xor    %eax,%eax
pop    %rcx
jmp    1150 <rockfall@plt>
xor    %eax,%eax
pop    %rcx
jmp    1110 <bridge@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <ruins@plt>
xor    %eax,%eax
pop    %rcx
jmp    1190 <shelter@plt>
xor    %eax,%eax
pop    %rcx
jmp    1140 <sinkhole@plt>
xor    %eax,%eax
pop    %rcx
jmp    1170 <slime@plt>
xor    %eax,%eax
pop    %rcx
jmp    1130 <vent@plt>
xor    %eax,%eax
pop    %rcx
jmp    10b0 <stream@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <warning@plt>
xor    %eax,%eax
pop    %rcx
jmp    1080 <webs@plt>
lea    0xd12(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
call   1160 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Impossible terrain encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @terrain_encounter() {
%1 = alloca i32
%2 = call i32 @d(i32 20)
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %44 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
i32 5, label %12
i32 6, label %14
i32 7, label %16
i32 8, label %18
i32 9, label %20
i32 10, label %22
i32 11, label %24
i32 12, label %26
i32 13, label %28
i32 14, label %30
i32 15, label %32
i32 16, label %34
i32 17, label %36
i32 18, label %38
i32 19, label %40
i32 20, label %42
]
4: ; preds = %0
%5 = call i32 (...) @boneyard()
br label %49
6: ; preds = %0
%7 = call i32 (...) @cliff()
br label %49
8: ; preds = %0
%9 = call i32 (...) @crystal()
br label %49
10: ; preds = %0
%11 = call i32 (...) @fungus()
br label %49
12: ; preds = %0
%13 = call i32 (...) @gas()
br label %49
14: ; preds = %0
%15 = call i32 (...) @gorge()
br label %49
16: ; preds = %0
%17 = call i32 (...) @ledge()
br label %49
18: ; preds = %0
%19 = call i32 (...) @sounds()
br label %49
20: ; preds = %0
%21 = call i32 (...) @lava()
br label %49
22: ; preds = %0
%23 = call i32 (...) @muck()
br label %49
24: ; preds = %0
%25 = call i32 (...) @rockfall()
br label %49
26: ; preds = %0
%27 = call i32 (...) @bridge()
br label %49
28: ; preds = %0
%29 = call i32 (...) @ruins()
br label %49
30: ; preds = %0
%31 = call i32 (...) @shelter()
br label %49
32: ; preds = %0
%33 = call i32 (...) @sinkhole()
br label %49
34: ; preds = %0
%35 = call i32 (...) @slime()
br label %49
36: ; preds = %0
%37 = call i32 (...) @vent()
br label %49
38: ; preds = %0
%39 = call i32 (...) @stream()
br label %49
40: ; preds = %0
%41 = call i32 (...) @warning()
br label %49
42: ; preds = %0
%43 = call i32 (...) @webs()
br label %49
44: ; preds = %0
%45 = load i32, i32* %1
%46 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = call i32 @exit(i32 %47)
unreachable
49: ; preds = %42, %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Impossible terrain encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @terrain_encounter() {
%1 = tail call i32 @d(i32 20)
switch i32 %1, label %42 [
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
i32 9, label %18
i32 10, label %20
i32 11, label %22
i32 12, label %24
i32 13, label %26
i32 14, label %28
i32 15, label %30
i32 16, label %32
i32 17, label %34
i32 18, label %36
i32 19, label %38
i32 20, label %40
]
2: ; preds = %0
%3 = tail call i32 (...) @boneyard()
br label %46
4: ; preds = %0
%5 = tail call i32 (...) @cliff()
br label %46
6: ; preds = %0
%7 = tail call i32 (...) @crystal()
br label %46
8: ; preds = %0
%9 = tail call i32 (...) @fungus()
br label %46
10: ; preds = %0
%11 = tail call i32 (...) @gas()
br label %46
12: ; preds = %0
%13 = tail call i32 (...) @gorge()
br label %46
14: ; preds = %0
%15 = tail call i32 (...) @ledge()
br label %46
16: ; preds = %0
%17 = tail call i32 (...) @sounds()
br label %46
18: ; preds = %0
%19 = tail call i32 (...) @lava()
br label %46
20: ; preds = %0
%21 = tail call i32 (...) @muck()
br label %46
22: ; preds = %0
%23 = tail call i32 (...) @rockfall()
br label %46
24: ; preds = %0
%25 = tail call i32 (...) @bridge()
br label %46
26: ; preds = %0
%27 = tail call i32 (...) @ruins()
br label %46
28: ; preds = %0
%29 = tail call i32 (...) @shelter()
br label %46
30: ; preds = %0
%31 = tail call i32 (...) @sinkhole()
br label %46
32: ; preds = %0
%33 = tail call i32 (...) @slime()
br label %46
34: ; preds = %0
%35 = tail call i32 (...) @vent()
br label %46
36: ; preds = %0
%37 = tail call i32 (...) @stream()
br label %46
38: ; preds = %0
%39 = tail call i32 (...) @warning()
br label %46
40: ; preds = %0
%41 = tail call i32 (...) @webs()
br label %46
42: ; preds = %0
%43 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %1)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %40, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %4, %2
ret void
}