#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*/ Term_clear();
int /*<<< orphan*/ bell(char *);
char inkey();
int /*<<< orphan*/ message_flush();
int /*<<< orphan*/ prt(char *, int, int);
int /*<<< orphan*/ screen_load();
int /*<<< orphan*/ screen_save();
int /*<<< orphan*/ spoil_artifact(char *);
int /*<<< orphan*/ spoil_features(char *);
int /*<<< orphan*/ spoil_mon_desc(char *);
int /*<<< orphan*/ spoil_mon_info(char *);
int /*<<< orphan*/ spoil_obj_desc(char *);
void do_cmd_spoilers(void) {
  char ch;
  screen_save();
  while (1) {
    Term_clear();
    prt("Create a spoiler file.", 2, 0);
    prt("(1) Brief Object Info (obj-desc.spo)", 5, 5);
    prt("(2) Brief Artifact Info (artifact.spo)", 6, 5);
    prt("(3) Brief Monster Info (mon-desc.spo)", 7, 5);
    prt("(4) Full Monster Info (mon-info.spo)", 8, 5);
    prt("(5) Full Feature Info (feature.spo)", 9, 5);
    prt("Command: ", 12, 0);
    ch = inkey();
    if (ch == '\033') {
      break;
    } else if (ch == '1') {
      spoil_obj_desc("obj-desc.spo");
    } else if (ch == '2') {
      spoil_artifact("artifact.spo");
    } else if (ch == '3') {
      spoil_mon_desc("mon-desc.spo");
    } else if (ch == '4') {
      spoil_mon_info("mon-info.spo");
    } else if (ch == '5') {
      spoil_features("feature.spo");
    } else {
      bell("Illegal command for spoilers!");
    }
    message_flush();
  }
  screen_load();
}


x86 assembly (clang, -O0):
<do_cmd_spoilers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   10b0 <screen_save@plt>
mov    $0x0,%al
call   1090 <Term_clear@plt>
lea    0xe23(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <prt@plt>
lea    0xe27(%rip),%rdi
mov    $0x5,%edx
mov    %edx,%esi
call   1070 <prt@plt>
lea    0xe39(%rip),%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
lea    0xe4a(%rip),%rdi
mov    $0x7,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
lea    0xe5a(%rip),%rdi
mov    $0x8,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
lea    0xe69(%rip),%rdi
mov    $0x9,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
lea    0xe77(%rip),%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1070 <prt@plt>
mov    $0x0,%al
call   10d0 <inkey@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x1b,%eax
jne    1283 <do_cmd_spoilers+0xc3>
jmp    134a <do_cmd_spoilers+0x18a>
movsbl -0x1(%rbp),%eax
cmp    $0x31,%eax
jne    12a1 <do_cmd_spoilers+0xe1>
lea    0xe45(%rip),%rdi
call   10a0 <spoil_obj_desc@plt>
jmp    1339 <do_cmd_spoilers+0x179>
movsbl -0x1(%rbp),%eax
cmp    $0x32,%eax
jne    12bf <do_cmd_spoilers+0xff>
lea    0xe34(%rip),%rdi
call   1080 <spoil_artifact@plt>
jmp    1334 <do_cmd_spoilers+0x174>
movsbl -0x1(%rbp),%eax
cmp    $0x33,%eax
jne    12dd <do_cmd_spoilers+0x11d>
lea    0xe23(%rip),%rdi
call   10c0 <spoil_mon_desc@plt>
jmp    132f <do_cmd_spoilers+0x16f>
movsbl -0x1(%rbp),%eax
cmp    $0x34,%eax
jne    12fb <do_cmd_spoilers+0x13b>
lea    0xe12(%rip),%rdi
call   1040 <spoil_mon_info@plt>
jmp    132a <do_cmd_spoilers+0x16a>
movsbl -0x1(%rbp),%eax
cmp    $0x35,%eax
jne    1319 <do_cmd_spoilers+0x159>
lea    0xe01(%rip),%rdi
call   10e0 <spoil_features@plt>
jmp    1325 <do_cmd_spoilers+0x165>
lea    0xdfc(%rip),%rdi
call   1030 <bell@plt>
jmp    132a <do_cmd_spoilers+0x16a>
jmp    132f <do_cmd_spoilers+0x16f>
jmp    1334 <do_cmd_spoilers+0x174>
jmp    1339 <do_cmd_spoilers+0x179>
jmp    133e <do_cmd_spoilers+0x17e>
mov    $0x0,%al
call   1060 <message_flush@plt>
jmp    11cf <do_cmd_spoilers+0xf>
mov    $0x0,%al
call   1050 <screen_load@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_cmd_spoilers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10b0 <screen_save@plt>
lea    0xecf(%rip),%r12
lea    0xeef(%rip),%r13
lea    0xf0e(%rip),%rbx
lea    0xf2c(%rip),%rbp
lea    0xf49(%rip),%r14
lea    0xe04(%rip),%r15
jmp    1217 <do_cmd_spoilers+0x57>
lea    0xf83(%rip),%rdi
call   1030 <bell@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <message_flush@plt>
xor    %eax,%eax
call   1090 <Term_clear@plt>
lea    0xe47(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <prt@plt>
lea    0xe4b(%rip),%rdi
mov    $0x5,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
mov    %r12,%rdi
mov    $0x6,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
mov    %r13,%rdi
mov    $0x7,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
mov    %rbp,%rdi
mov    $0x9,%esi
mov    $0x5,%edx
call   1070 <prt@plt>
mov    %r14,%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1070 <prt@plt>
xor    %eax,%eax
call   10d0 <inkey@plt>
add    $0xe5,%al
cmp    $0x1a,%al
ja     11fe <do_cmd_spoilers+0x3e>
movzbl %al,%eax
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xe86(%rip),%rdi
call   10a0 <spoil_obj_desc@plt>
jmp    1210 <do_cmd_spoilers+0x50>
lea    0xe82(%rip),%rdi
call   1080 <spoil_artifact@plt>
jmp    1210 <do_cmd_spoilers+0x50>
lea    0xe7e(%rip),%rdi
call   10c0 <spoil_mon_desc@plt>
jmp    1210 <do_cmd_spoilers+0x50>
lea    0xe7a(%rip),%rdi
call   1040 <spoil_mon_info@plt>
jmp    1210 <do_cmd_spoilers+0x50>
lea    0xe76(%rip),%rdi
call   10e0 <spoil_features@plt>
jmp    1210 <do_cmd_spoilers+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <screen_load@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Create a spoiler file.\00"
@.str.1 = [37 x i8] c"(1) Brief Object Info (obj-desc.spo)\00"
@.str.2 = [39 x i8] c"(2) Brief Artifact Info (artifact.spo)\00"
@.str.3 = [38 x i8] c"(3) Brief Monster Info (mon-desc.spo)\00"
@.str.4 = [37 x i8] c"(4) Full Monster Info (mon-info.spo)\00"
@.str.5 = [36 x i8] c"(5) Full Feature Info (feature.spo)\00"
@.str.6 = [10 x i8] c"Command: \00"
@.str.7 = [13 x i8] c"obj-desc.spo\00"
@.str.8 = [13 x i8] c"artifact.spo\00"
@.str.9 = [13 x i8] c"mon-desc.spo\00"
@.str.10 = [13 x i8] c"mon-info.spo\00"
@.str.11 = [12 x i8] c"feature.spo\00"
@.str.12 = [30 x i8] c"Illegal command for spoilers!\00"
define void @do_cmd_spoilers() {
%1 = alloca i8
%2 = call i32 (...) @screen_save()
br label %3
3: ; preds = %0, %54
%4 = call i32 (...) @Term_clear()
%5 = call i32 @prt(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
%6 = call i32 @prt(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 5)
%7 = call i32 @prt(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 5)
%8 = call i32 @prt(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 5)
%9 = call i32 @prt(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 5)
%10 = call i32 @prt(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 9, i32 5)
%11 = call i32 @prt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 12, i32 0)
%12 = call signext i8 (...) @inkey()
store i8 %12, i8* %1
%13 = load i8, i8* %1
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 27
br i1 %15, label %16, label %17
16: ; preds = %3
br label %56
17: ; preds = %3
%18 = load i8, i8* %1
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 49
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @spoil_obj_desc(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %53
23: ; preds = %17
%24 = load i8, i8* %1
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 50
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @spoil_artifact(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %52
29: ; preds = %23
%30 = load i8, i8* %1
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 51
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @spoil_mon_desc(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %51
35: ; preds = %29
%36 = load i8, i8* %1
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 52
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @spoil_mon_info(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %50
41: ; preds = %35
%42 = load i8, i8* %1
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 53
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @spoil_features(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %49
47: ; preds = %41
%48 = call i32 @bell(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
br label %50
50: ; preds = %49, %39
br label %51
51: ; preds = %50, %33
br label %52
52: ; preds = %51, %27
br label %53
53: ; preds = %52, %21
br label %54
54: ; preds = %53
%55 = call i32 (...) @message_flush()
br label %3
56: ; preds = %16
%57 = call i32 (...) @screen_load()
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Create a spoiler file.\00"
@.str.1 = [37 x i8] c"(1) Brief Object Info (obj-desc.spo)\00"
@.str.2 = [39 x i8] c"(2) Brief Artifact Info (artifact.spo)\00"
@.str.3 = [38 x i8] c"(3) Brief Monster Info (mon-desc.spo)\00"
@.str.4 = [37 x i8] c"(4) Full Monster Info (mon-info.spo)\00"
@.str.5 = [36 x i8] c"(5) Full Feature Info (feature.spo)\00"
@.str.6 = [10 x i8] c"Command: \00"
@.str.7 = [13 x i8] c"obj-desc.spo\00"
@.str.8 = [13 x i8] c"artifact.spo\00"
@.str.9 = [13 x i8] c"mon-desc.spo\00"
@.str.10 = [13 x i8] c"mon-info.spo\00"
@.str.11 = [12 x i8] c"feature.spo\00"
@.str.12 = [30 x i8] c"Illegal command for spoilers!\00"
define void @do_cmd_spoilers() {
%1 = tail call i32 (...) @screen_save()
br label %2
2: ; preds = %24, %0
%3 = tail call i32 (...) @Term_clear()
%4 = tail call i32 @prt(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
%5 = tail call i32 @prt(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 5)
%6 = tail call i32 @prt(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 5)
%7 = tail call i32 @prt(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 5)
%8 = tail call i32 @prt(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 5)
%9 = tail call i32 @prt(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 9, i32 5)
%10 = tail call i32 @prt(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 12, i32 0)
%11 = tail call signext i8 (...) @inkey()
switch i8 %11, label %22 [
i8 27, label %26
i8 49, label %12
i8 50, label %14
i8 51, label %16
i8 52, label %18
i8 53, label %20
]
12: ; preds = %2
%13 = tail call i32 @spoil_obj_desc(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %24
14: ; preds = %2
%15 = tail call i32 @spoil_artifact(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %24
16: ; preds = %2
%17 = tail call i32 @spoil_mon_desc(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %24
18: ; preds = %2
%19 = tail call i32 @spoil_mon_info(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %24
20: ; preds = %2
%21 = tail call i32 @spoil_features(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %24
22: ; preds = %2
%23 = tail call i32 @bell(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
br label %24
24: ; preds = %12, %16, %20, %22, %18, %14
%25 = tail call i32 (...) @message_flush()
br label %2
26: ; preds = %2
%27 = tail call i32 (...) @screen_load()
ret void
}