#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*/ dirdist_calc();
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ galactic_record();
int /*<<< orphan*/ galaxy_map();
scalar_t__ inoperable(int);
int input_int();
int /*<<< orphan*/ nav_data();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ status_report();
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ torpedo_data();
void library_computer(void) {
  if (inoperable(8))
    return;
  fputs("Computer active and awating command: ", stdout);
  switch (input_int()) {
  case -1:
    break;
  case 0:
    galactic_record();
    break;
  case 1:
    status_report();
    break;
  case 2:
    torpedo_data();
    break;
  case 3:
    nav_data();
    break;
  case 4:
    dirdist_calc();
    break;
  case 5:
    galaxy_map();
    break;
  default:
    puts("Functions available from Library-Computer:\n\n"
         "   0 = Cumulative Galactic Record\n"
         "   1 = Status Report\n"
         "   2 = Photon Torpedo Data\n"
         "   3 = Starbase Nav Data\n"
         "   4 = Direction/Distance Calculator\n"
         "   5 = Galaxy 'Region Name' Map\n");
  }
}


x86 assembly (clang, -O0):
<library_computer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x8,%edi
call   1090 <inoperable@plt>
cmp    $0x0,%rax
je     11c1 <library_computer+0x21>
jmp    125c <library_computer+0xbc>
mov    0x2e18(%rip),%rax
mov    (%rax),%esi
lea    0xe4b(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10c0 <input_int@plt>
add    $0x1,%eax
mov    %eax,%ecx
mov    %rcx,-0x8(%rbp)
sub    $0x6,%eax
ja     1250 <library_computer+0xb0>
mov    -0x8(%rbp),%rax
lea    0xe06(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   1030 <galactic_record@plt>
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   1060 <status_report@plt>
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   1070 <torpedo_data@plt>
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   1040 <nav_data@plt>
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   10a0 <dirdist_calc@plt>
jmp    125c <library_computer+0xbc>
mov    $0x0,%al
call   10b0 <galaxy_map@plt>
jmp    125c <library_computer+0xbc>
lea    0xdeb(%rip),%rdi
call   1050 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<library_computer>:
push   %rax
mov    $0x8,%edi
call   1090 <inoperable@plt>
test   %rax,%rax
je     11b2 <library_computer+0x12>
pop    %rax
ret
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    0xe5a(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10c0 <input_int@plt>
add    $0x1,%eax
cmp    $0x6,%eax
ja     11ee <library_computer+0x4e>
lea    0xe23(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rcx
jmp    1030 <galactic_record@plt>
lea    0xe4d(%rip),%rdi
pop    %rax
jmp    1050 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <status_report@plt>
xor    %eax,%eax
pop    %rcx
jmp    1070 <torpedo_data@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <nav_data@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <dirdist_calc@plt>
xor    %eax,%eax
pop    %rcx
jmp    10b0 <galaxy_map@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Computer active and awating command: \00"
@stdout = global i32 0
@.str.1 = [221 x i8] c"Functions available from Library-Computer:\0A\0A 0 = Cumulative Galactic Record\0A 1 = Status Report\0A 2 = Photon Torpedo Data\0A 3 = Starbase Nav Data\0A 4 = Direction/Distance Calculator\0A 5 = Galaxy 'Region Name' Map\0A\00"
define void @library_computer() {
%1 = call i64 @inoperable(i32 8)
%2 = icmp ne i64 %1, 0
br i1 %2, label %3, label %4
3: ; preds = %0
br label %23
4: ; preds = %0
%5 = load i32, i32* @stdout
%6 = call i32 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (...) @input_int()
switch i32 %7, label %21 [
i32 -1, label %8
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
i32 5, label %19
]
8: ; preds = %4
br label %23
9: ; preds = %4
%10 = call i32 (...) @galactic_record()
br label %23
11: ; preds = %4
%12 = call i32 (...) @status_report()
br label %23
13: ; preds = %4
%14 = call i32 (...) @torpedo_data()
br label %23
15: ; preds = %4
%16 = call i32 (...) @nav_data()
br label %23
17: ; preds = %4
%18 = call i32 (...) @dirdist_calc()
br label %23
19: ; preds = %4
%20 = call i32 (...) @galaxy_map()
br label %23
21: ; preds = %4
%22 = call i32 @puts(i8* getelementptr inbounds ([221 x i8], [221 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %3, %21, %19, %17, %15, %13, %11, %9, %8
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Computer active and awating command: \00"
@stdout = global i32 0
@.str.1 = [221 x i8] c"Functions available from Library-Computer:\0A\0A 0 = Cumulative Galactic Record\0A 1 = Status Report\0A 2 = Photon Torpedo Data\0A 3 = Starbase Nav Data\0A 4 = Direction/Distance Calculator\0A 5 = Galaxy 'Region Name' Map\0A\00"
define void @library_computer() {
%1 = tail call i64 @inoperable(i32 8)
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %21
3: ; preds = %0
%4 = load i32, i32* @stdout
%5 = tail call i32 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 (...) @input_int()
switch i32 %6, label %19 [
i32 -1, label %21
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
]
7: ; preds = %3
%8 = tail call i32 (...) @galactic_record()
br label %21
9: ; preds = %3
%10 = tail call i32 (...) @status_report()
br label %21
11: ; preds = %3
%12 = tail call i32 (...) @torpedo_data()
br label %21
13: ; preds = %3
%14 = tail call i32 (...) @nav_data()
br label %21
15: ; preds = %3
%16 = tail call i32 (...) @dirdist_calc()
br label %21
17: ; preds = %3
%18 = tail call i32 (...) @galaxy_map()
br label %21
19: ; preds = %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([221 x i8], [221 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %0, %19, %17, %15, %13, %11, %9, %7, %3
ret void
}