#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*/ DoLRScan();
int /*<<< orphan*/ DoQuit();
int /*<<< orphan*/ DoReport();
int /*<<< orphan*/ DoSRS();
int /*<<< orphan*/ DoWarp();
int /*<<< orphan*/ FirePhasers();
int /*<<< orphan*/ FirePhotonTorpedo();
int /*<<< orphan*/ ShowGalaxyMap();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strupper(char *);
void GetCommand() {
  char Command[5];
  do {
    printf("Command:");
    gets(Command);
    strcpy(Command, strupper(Command));
    switch (Command[0]) {
    case 'Q':
      DoQuit();
      return;
    case 'R':
      DoReport();
      continue;
    case 'S':
      DoSRS();
      continue;
    case 'L':
      DoLRScan();
      continue;
    case 'P':
      FirePhasers();
      return;
    case 'G':
      ShowGalaxyMap();
      continue;
    case 'T':
      FirePhotonTorpedo();
      return;
    case 'W':
      DoWarp();
      return;
    default: {
      printf("R=REPORT       S=SR SENSOR   L=LR SENSOR \n\r");
      printf("G=GALAXY MAP   P=PHASER       T=TORPEDO \n\r");
      printf("W=WARP ENGINE  **PLEASE USE ONE OF THESE COMMANDS***\n\r");
    }
    }
  } while (1);
  return;
}


x86 assembly (clang, -O0):
<GetCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe75(%rip),%rdi
call   1070 <printf@plt>
lea    -0x5(%rbp),%rdi
mov    %rdi,-0x18(%rbp)
call   10a0 <gets@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <strupper@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffb9,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x10,%eax
ja     127f <GetCommand+0xbf>
mov    -0x10(%rbp),%rax
lea    0xdea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1090 <DoQuit@plt>
jmp    12bc <GetCommand+0xfc>
mov    $0x0,%al
call   10d0 <DoReport@plt>
jmp    12a8 <GetCommand+0xe8>
mov    $0x0,%al
call   10c0 <DoSRS@plt>
jmp    12a8 <GetCommand+0xe8>
mov    $0x0,%al
call   1030 <DoLRScan@plt>
jmp    12a8 <GetCommand+0xe8>
mov    $0x0,%al
call   1080 <FirePhasers@plt>
jmp    12bc <GetCommand+0xfc>
mov    $0x0,%al
call   1050 <ShowGalaxyMap@plt>
jmp    12a8 <GetCommand+0xe8>
mov    $0x0,%al
call   10e0 <FirePhotonTorpedo@plt>
jmp    12bc <GetCommand+0xfc>
mov    $0x0,%al
call   1060 <DoWarp@plt>
jmp    12bc <GetCommand+0xfc>
lea    0xdc7(%rip),%rdi
call   1070 <printf@plt>
lea    0xde7(%rip),%rdi
call   1070 <printf@plt>
lea    0xe06(%rip),%rdi
call   1070 <printf@plt>
jmp    12a8 <GetCommand+0xe8>
mov    $0x1,%al
test   $0x1,%al
jne    11c8 <GetCommand+0x8>
jmp    12b7 <GetCommand+0xf7>
jmp    12bc <GetCommand+0xfc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetCommand>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe72(%rip),%r14
lea    0x3(%rsp),%rbx
lea    0xe6f(%rip),%r15
lea    0xe94(%rip),%r12
lea    0xeb8(%rip),%r13
lea    0xe0d(%rip),%rbp
jmp    1200 <GetCommand+0x40>
xor    %eax,%eax
call   1050 <ShowGalaxyMap@plt>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   10a0 <gets@plt>
mov    %rbx,%rdi
call   10b0 <strupper@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
movsbl 0x3(%rsp),%eax
add    $0xffffffb9,%eax
cmp    $0x10,%eax
ja     1242 <GetCommand+0x82>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
xor    %eax,%eax
call   1030 <DoLRScan@plt>
jmp    1200 <GetCommand+0x40>
mov    %r15,%rdi
call   1070 <printf@plt>
mov    %r12,%rdi
call   1070 <printf@plt>
mov    %r13,%rdi
call   1070 <printf@plt>
jmp    1200 <GetCommand+0x40>
xor    %eax,%eax
call   10d0 <DoReport@plt>
jmp    1200 <GetCommand+0x40>
xor    %eax,%eax
call   10c0 <DoSRS@plt>
jmp    1200 <GetCommand+0x40>
xor    %eax,%eax
call   1080 <FirePhasers@plt>
jmp    1290 <GetCommand+0xd0>
xor    %eax,%eax
call   1090 <DoQuit@plt>
jmp    1290 <GetCommand+0xd0>
xor    %eax,%eax
call   10e0 <FirePhotonTorpedo@plt>
jmp    1290 <GetCommand+0xd0>
xor    %eax,%eax
call   1060 <DoWarp@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Command:\00"
@.str.1 = [44 x i8] c"R=REPORT S=SR SENSOR L=LR SENSOR \0A\0D\00"
@.str.2 = [43 x i8] c"G=GALAXY MAP P=PHASER T=TORPEDO \0A\0D\00"
@.str.3 = [55 x i8] c"W=WARP ENGINE **PLEASE USE ONE OF THESE COMMANDS***\0A\0D\00"
define void @GetCommand() {
%1 = alloca [5 x i8]
br label %2
2: ; preds = %34, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = call i32 @gets(i8* %4)
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%8 = call i32 @strupper(i8* %7)
%9 = call i32 @strcpy(i8* %6, i32 %8)
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %29 [
i32 81, label %13
i32 82, label %15
i32 83, label %17
i32 76, label %19
i32 80, label %21
i32 71, label %23
i32 84, label %25
i32 87, label %27
]
13: ; preds = %2
%14 = call i32 (...) @DoQuit()
br label %36
15: ; preds = %2
%16 = call i32 (...) @DoReport()
br label %34
17: ; preds = %2
%18 = call i32 (...) @DoSRS()
br label %34
19: ; preds = %2
%20 = call i32 (...) @DoLRScan()
br label %34
21: ; preds = %2
%22 = call i32 (...) @FirePhasers()
br label %36
23: ; preds = %2
%24 = call i32 (...) @ShowGalaxyMap()
br label %34
25: ; preds = %2
%26 = call i32 (...) @FirePhotonTorpedo()
br label %36
27: ; preds = %2
%28 = call i32 (...) @DoWarp()
br label %36
29: ; preds = %2
%30 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %29
br label %34
34: ; preds = %33, %23, %19, %17, %15
br i1 true, label %2, label %35
35: ; preds = %34
br label %36
36: ; preds = %35, %27, %25, %21, %13
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Command:\00"
@.str.1 = [44 x i8] c"R=REPORT S=SR SENSOR L=LR SENSOR \0A\0D\00"
@.str.2 = [43 x i8] c"G=GALAXY MAP P=PHASER T=TORPEDO \0A\0D\00"
@.str.3 = [55 x i8] c"W=WARP ENGINE **PLEASE USE ONE OF THESE COMMANDS***\0A\0D\00"
define void @GetCommand() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %30, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @gets(i8* %2)
%6 = call i32 @strupper(i8* %2)
%7 = call i32 @strcpy(i8* %2, i32 %6)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
switch i32 %9, label %26 [
i32 81, label %10
i32 82, label %12
i32 83, label %14
i32 76, label %16
i32 80, label %18
i32 71, label %20
i32 84, label %22
i32 87, label %24
]
10: ; preds = %3
%11 = call i32 (...) @DoQuit()
br label %31
12: ; preds = %3
%13 = call i32 (...) @DoReport()
br label %30
14: ; preds = %3
%15 = call i32 (...) @DoSRS()
br label %30
16: ; preds = %3
%17 = call i32 (...) @DoLRScan()
br label %30
18: ; preds = %3
%19 = call i32 (...) @FirePhasers()
br label %31
20: ; preds = %3
%21 = call i32 (...) @ShowGalaxyMap()
br label %30
22: ; preds = %3
%23 = call i32 (...) @FirePhotonTorpedo()
br label %31
24: ; preds = %3
%25 = call i32 (...) @DoWarp()
br label %31
26: ; preds = %3
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %26, %20, %16, %14, %12
br label %3
31: ; preds = %24, %22, %18, %10
ret void
}