#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*/ creature_encounter();
unsigned int d(int);
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ terrain_encounter();
void random_encounter(void) {
  unsigned d20;
  d20 = d(20);
  if (d20 < 14) {
    printf("No encounter\n");
    return;
  }
  niceprint("If the party is not moving, either anchored or ashore, then "
            "re-roll until a creature "
            "encounter occurs and ignore terrain encounters\n\n");
  if (d20 < 16 || d20 > 17) {
    terrain_encounter();
  }
  if (d20 > 15) {
    creature_encounter();
  }
}


x86 assembly (clang, -O0):
<random_encounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
call   1030 <d@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xe,-0x4(%rbp)
jae    1180 <random_encounter+0x30>
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
jmp    11b8 <random_encounter+0x68>
lea    0xe87(%rip),%rdi
call   1060 <niceprint@plt>
cmpl   $0x10,-0x4(%rbp)
jb     11a0 <random_encounter+0x50>
cmpl   $0x11,-0x4(%rbp)
jbe    11a7 <random_encounter+0x57>
mov    $0x0,%al
call   1040 <terrain_encounter@plt>
cmpl   $0xf,-0x4(%rbp)
jbe    11b8 <random_encounter+0x68>
mov    $0x0,%al
call   1070 <creature_encounter@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_encounter>:
push   %rbx
mov    $0x14,%edi
call   1040 <d@plt>
cmp    $0xd,%eax
ja     116d <random_encounter+0x1d>
lea    0xf1f(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
mov    %eax,%ebx
lea    0xe8a(%rip),%rdi
call   1060 <niceprint@plt>
lea    -0x12(%rbx),%eax
cmp    $0xfffffffd,%eax
ja     118f <random_encounter+0x3f>
xor    %eax,%eax
call   1050 <terrain_encounter@plt>
cmp    $0x10,%ebx
jb     1197 <random_encounter+0x47>
xor    %eax,%eax
pop    %rbx
jmp    1070 <creature_encounter@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"No encounter\0A\00"
@.str.1 = [134 x i8] c"If the party is not moving, either anchored or ashore, then re-roll until a creature encounter occurs and ignore terrain encounters\0A\0A\00"
define void @random_encounter() {
%1 = alloca i32
%2 = call i32 @d(i32 20)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp ult i32 %3, 14
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
7: ; preds = %0
%8 = call i32 @niceprint(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = icmp ult i32 %9, 16
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load i32, i32* %1
%13 = icmp ugt i32 %12, 17
br i1 %13, label %14, label %16
14: ; preds = %11, %7
%15 = call i32 (...) @terrain_encounter()
br label %16
16: ; preds = %14, %11
%17 = load i32, i32* %1
%18 = icmp ugt i32 %17, 15
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (...) @creature_encounter()
br label %21
21: ; preds = %5, %19, %16
ret void
}

LLVM IR (-O2):
@.str.1 = [134 x i8] c"If the party is not moving, either anchored or ashore, then re-roll until a creature encounter occurs and ignore terrain encounters\0A\0A\00"
@str = [13 x i8] c"No encounter\00"
define void @random_encounter() {
%1 = tail call i32 @d(i32 20)
%2 = icmp ult i32 %1, 14
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %14
5: ; preds = %0
%6 = tail call i32 @niceprint(i8* getelementptr inbounds ([134 x i8], [134 x i8]* @.str.1, i64 0, i64 0))
%7 = add i32 %1, -18
%8 = icmp ult i32 %7, -2
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i32 (...) @terrain_encounter()
%11 = icmp ugt i32 %1, 15
br i1 %11, label %12, label %14
12: ; preds = %5, %9
%13 = tail call i32 (...) @creature_encounter()
br label %14
14: ; preds = %9, %12, %3
ret void
}