#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*/ printMenu();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sendCommand(char);
int main() {
  int opc;
  while (1 == 1) {
    printMenu();
    scanf("%d", &opc);
    switch (opc) {
    case 1:
      sendCommand('R');
      break;
    case 2:
      sendCommand('Y');
      break;
    case 3:
      sendCommand('G');
      break;
    case 4:
      sendCommand('L');
      break;
    case 5:
      sendCommand('S');
      break;
    default:
      printf("\nInvalid command");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
call   1050 <printMenu@plt>
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     11da <main+0x9a>
mov    -0x10(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x52,%edi
call   1030 <sendCommand@plt>
jmp    11e6 <main+0xa6>
mov    $0x59,%edi
call   1030 <sendCommand@plt>
jmp    11e6 <main+0xa6>
mov    $0x47,%edi
call   1030 <sendCommand@plt>
jmp    11e6 <main+0xa6>
mov    $0x4c,%edi
call   1030 <sendCommand@plt>
jmp    11e6 <main+0xa6>
mov    $0x53,%edi
call   1030 <sendCommand@plt>
jmp    11e6 <main+0xa6>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
jmp    114f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
lea    0x4(%rsp),%r12
lea    0xebc(%rip),%r15
lea    0xe9e(%rip),%rbx
jmp    1170 <main+0x30>
mov    $0x53,%edi
call   1030 <sendCommand@plt>
xchg   %ax,%ax
xor    %eax,%eax
call   1050 <printMenu@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11a3 <main+0x63>
movslq (%rbx,%rax,4),%rax
add    %rbx,%rax
jmp    *%rax
mov    $0x52,%edi
call   1030 <sendCommand@plt>
jmp    1170 <main+0x30>
mov    %r15,%rdi
call   1040 <printf@plt>
jmp    1170 <main+0x30>
mov    $0x59,%edi
call   1030 <sendCommand@plt>
jmp    1170 <main+0x30>
mov    $0x47,%edi
call   1030 <sendCommand@plt>
jmp    1170 <main+0x30>
mov    $0x4c,%edi
call   1030 <sendCommand@plt>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"\0AInvalid command\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %19
%4 = call i32 (...) @printMenu()
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
7: ; preds = %3
%8 = call i32 @sendCommand(i8 signext 82)
br label %19
9: ; preds = %3
%10 = call i32 @sendCommand(i8 signext 89)
br label %19
11: ; preds = %3
%12 = call i32 @sendCommand(i8 signext 71)
br label %19
13: ; preds = %3
%14 = call i32 @sendCommand(i8 signext 76)
br label %19
15: ; preds = %3
%16 = call i32 @sendCommand(i8 signext 83)
br label %19
17: ; preds = %3
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %15, %13, %11, %9, %7
br label %3
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [17 x i8] c"\0AInvalid command\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %19, %0
%4 = call i32 (...) @printMenu()
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
7: ; preds = %3
%8 = call i32 @sendCommand(i8 signext 82)
br label %19
9: ; preds = %3
%10 = call i32 @sendCommand(i8 signext 89)
br label %19
11: ; preds = %3
%12 = call i32 @sendCommand(i8 signext 71)
br label %19
13: ; preds = %3
%14 = call i32 @sendCommand(i8 signext 76)
br label %19
15: ; preds = %3
%16 = call i32 @sendCommand(i8 signext 83)
br label %19
17: ; preds = %3
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %15, %13, %11, %9, %7
br label %3
}