#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*/ aground();
int /*<<< orphan*/ collision();
int /*<<< orphan*/ current();
unsigned int d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ falls();
int /*<<< orphan*/ island();
int /*<<< orphan*/ lowceiling();
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ rockfall();
int /*<<< orphan*/ stoneteeth();
int /*<<< orphan*/ tightpassage();
int /*<<< orphan*/ whirlpool();
void terrain_encounter(void) {
  unsigned d10;
  d10 = d(10);
  switch (d10) {
  case 1:
    collision();
    break;
  case 2:
    falls();
    break;
  case 3:
    island();
    break;
  case 4:
    lowceiling();
    break;
  case 5:
    rockfall();
    break;
  case 6:
    current();
    break;
  case 7:
    aground();
    break;
  case 8:
    stoneteeth();
    break;
  case 9:
    tightpassage();
    break;
  case 10:
    whirlpool();
    break;
  default:
    printf("Impossible terrain encounter of %d\n", d10);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<terrain_encounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xa,%edi
call   1060 <d@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x9,%eax
ja     1286 <terrain_encounter+0xb6>
mov    -0x10(%rbp),%rax
lea    0xdfb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <collision@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   1040 <falls@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   1050 <island@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   1030 <lowceiling@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   10e0 <rockfall@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   10d0 <current@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   1070 <aground@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   10c0 <stoneteeth@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   10b0 <tightpassage@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    $0x0,%al
call   10a0 <whirlpool@plt>
jmp    12a3 <terrain_encounter+0xd3>
mov    -0x4(%rbp),%esi
lea    0xd98(%rip),%rdi
call   1090 <printf@plt>
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<terrain_encounter>:
push   %rax
mov    $0xa,%edi
call   1060 <d@plt>
lea    -0x1(%rax),%ecx
cmp    $0x9,%ecx
ja     1243 <terrain_encounter+0x73>
lea    0xe16(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
pop    %rcx
jmp    1080 <collision@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <falls@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <island@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <lowceiling@plt>
xor    %eax,%eax
pop    %rcx
jmp    10e0 <rockfall@plt>
xor    %eax,%eax
pop    %rcx
jmp    10d0 <current@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <aground@plt>
xor    %eax,%eax
pop    %rcx
jmp    10c0 <stoneteeth@plt>
xor    %eax,%eax
pop    %rcx
jmp    10b0 <tightpassage@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <whirlpool@plt>
lea    0xdde(%rip),%rdi
mov    %eax,%esi
call   1090 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   10f0 <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 10)
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %24 [
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
]
4: ; preds = %0
%5 = call i32 (...) @collision()
br label %29
6: ; preds = %0
%7 = call i32 (...) @falls()
br label %29
8: ; preds = %0
%9 = call i32 (...) @island()
br label %29
10: ; preds = %0
%11 = call i32 (...) @lowceiling()
br label %29
12: ; preds = %0
%13 = call i32 (...) @rockfall()
br label %29
14: ; preds = %0
%15 = call i32 (...) @current()
br label %29
16: ; preds = %0
%17 = call i32 (...) @aground()
br label %29
18: ; preds = %0
%19 = call i32 (...) @stoneteeth()
br label %29
20: ; preds = %0
%21 = call i32 (...) @tightpassage()
br label %29
22: ; preds = %0
%23 = call i32 (...) @whirlpool()
br label %29
24: ; preds = %0
%25 = load i32, i32* %1
%26 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 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 = [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 10)
switch i32 %1, label %22 [
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
]
2: ; preds = %0
%3 = tail call i32 (...) @collision()
br label %26
4: ; preds = %0
%5 = tail call i32 (...) @falls()
br label %26
6: ; preds = %0
%7 = tail call i32 (...) @island()
br label %26
8: ; preds = %0
%9 = tail call i32 (...) @lowceiling()
br label %26
10: ; preds = %0
%11 = tail call i32 (...) @rockfall()
br label %26
12: ; preds = %0
%13 = tail call i32 (...) @current()
br label %26
14: ; preds = %0
%15 = tail call i32 (...) @aground()
br label %26
16: ; preds = %0
%17 = tail call i32 (...) @stoneteeth()
br label %26
18: ; preds = %0
%19 = tail call i32 (...) @tightpassage()
br label %26
20: ; preds = %0
%21 = tail call i32 (...) @whirlpool()
br label %26
22: ; preds = %0
%23 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 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
}