#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*/ ambushlair(int /*<<< orphan*/);
int /*<<< orphan*/ chuul(int);
int /*<<< orphan*/ d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ giantspider(int /*<<< orphan*/);
int /*<<< orphan*/ grell(int);
int /*<<< orphan*/ grick(int /*<<< orphan*/);
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ orog(int /*<<< orphan*/);
int /*<<< orphan*/ piercer(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ umberhulk(int);
void ambush(unsigned d20) {
  niceprint("One or more creatures attempt to ambush the party.\n\n");
  switch (d20) {
  case 1:
  case 2:
    chuul(1);
    break;
  case 3:
    giantspider(d(6));
    break;
  case 4:
  case 5:
    grell(1);
    break;
  case 6:
  case 7:
  case 8:
  case 9:
    grick(d(4));
    break;
  case 10:
  case 11:
  case 12:
  case 13:
  case 14:
  case 15:
    orog(d(4));
    break;
  case 16:
  case 17:
    piercer(d(6));
    break;
  case 18:
  case 19:
  case 20:
    umberhulk(1);
    break;
  default:
    printf("Impossible ambush encounter of %d\n", d20);
    exit(EXIT_FAILURE);
  }
  ambushlair(d(20));
}


x86 assembly (clang, -O0):
<ambush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
call   10c0 <niceprint@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     1285 <ambush+0xc5>
mov    -0x10(%rbp),%rax
lea    0xe09(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
call   10b0 <chuul@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   10e0 <giantspider@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x1,%edi
call   1050 <grell@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1080 <grick@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1090 <orog@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   10a0 <piercer@plt>
jmp    12a2 <ambush+0xe2>
mov    $0x1,%edi
call   1070 <umberhulk@plt>
jmp    12a2 <ambush+0xe2>
mov    -0x4(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    $0x14,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1040 <ambushlair@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ambush>:
push   %rbx
mov    %edi,%ebx
lea    0xe86(%rip),%rdi
call   10c0 <niceprint@plt>
lea    -0x1(%rbx),%eax
cmp    $0x13,%eax
ja     126b <ambush+0xab>
lea    0xe1e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1090 <orog@plt>
jmp    1259 <ambush+0x99>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1080 <grick@plt>
jmp    1259 <ambush+0x99>
mov    $0x1,%edi
call   1070 <umberhulk@plt>
jmp    1259 <ambush+0x99>
mov    $0x1,%edi
call   10b0 <chuul@plt>
jmp    1259 <ambush+0x99>
mov    $0x1,%edi
call   1050 <grell@plt>
jmp    1259 <ambush+0x99>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   10a0 <piercer@plt>
jmp    1259 <ambush+0x99>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   10e0 <giantspider@plt>
mov    $0x14,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rbx
jmp    1040 <ambushlair@plt>
lea    0xe13(%rip),%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"One or more creatures attempt to ambush the party.\0A\0A\00"
@.str.1 = [35 x i8] c"Impossible ambush encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @ambush(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @niceprint(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %23 [
i32 1, label %5
i32 2, label %5
i32 3, label %7
i32 4, label %10
i32 5, label %10
i32 6, label %12
i32 7, label %12
i32 8, label %12
i32 9, label %12
i32 10, label %15
i32 11, label %15
i32 12, label %15
i32 13, label %15
i32 14, label %15
i32 15, label %15
i32 16, label %18
i32 17, label %18
i32 18, label %21
i32 19, label %21
i32 20, label %21
]
5: ; preds = %1, %1
%6 = call i32 @chuul(i32 1)
br label %28
7: ; preds = %1
%8 = call i32 @d(i32 6)
%9 = call i32 @giantspider(i32 %8)
br label %28
10: ; preds = %1, %1
%11 = call i32 @grell(i32 1)
br label %28
12: ; preds = %1, %1, %1, %1
%13 = call i32 @d(i32 4)
%14 = call i32 @grick(i32 %13)
br label %28
15: ; preds = %1, %1, %1, %1, %1, %1
%16 = call i32 @d(i32 4)
%17 = call i32 @orog(i32 %16)
br label %28
18: ; preds = %1, %1
%19 = call i32 @d(i32 6)
%20 = call i32 @piercer(i32 %19)
br label %28
21: ; preds = %1, %1, %1
%22 = call i32 @umberhulk(i32 1)
br label %28
23: ; preds = %1
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %21, %18, %15, %12, %10, %7, %5
%29 = call i32 @d(i32 20)
%30 = call i32 @ambushlair(i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"One or more creatures attempt to ambush the party.\0A\0A\00"
@.str.1 = [35 x i8] c"Impossible ambush encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @ambush(i32 %0) {
%2 = tail call i32 @niceprint(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %21 [
i32 1, label %3
i32 2, label %3
i32 3, label %5
i32 4, label %8
i32 5, label %8
i32 6, label %10
i32 7, label %10
i32 8, label %10
i32 9, label %10
i32 10, label %13
i32 11, label %13
i32 12, label %13
i32 13, label %13
i32 14, label %13
i32 15, label %13
i32 16, label %16
i32 17, label %16
i32 18, label %19
i32 19, label %19
i32 20, label %19
]
3: ; preds = %1, %1
%4 = tail call i32 @chuul(i32 1)
br label %25
5: ; preds = %1
%6 = tail call i32 @d(i32 6)
%7 = tail call i32 @giantspider(i32 %6)
br label %25
8: ; preds = %1, %1
%9 = tail call i32 @grell(i32 1)
br label %25
10: ; preds = %1, %1, %1, %1
%11 = tail call i32 @d(i32 4)
%12 = tail call i32 @grick(i32 %11)
br label %25
13: ; preds = %1, %1, %1, %1, %1, %1
%14 = tail call i32 @d(i32 4)
%15 = tail call i32 @orog(i32 %14)
br label %25
16: ; preds = %1, %1
%17 = tail call i32 @d(i32 6)
%18 = tail call i32 @piercer(i32 %17)
br label %25
19: ; preds = %1, %1, %1
%20 = tail call i32 @umberhulk(i32 1)
br label %25
21: ; preds = %1
%22 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %19, %16, %13, %10, %8, %5, %3
%26 = tail call i32 @d(i32 20)
%27 = tail call i32 @ambushlair(i32 %26)
ret void
}