#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*/ printf(char *, char *, ...);
int show_selection(char option) {
  switch (option) {
  case 'Q':
    printf("%s\n", "Goodbye!");
    break;
  case 'A':
    printf("%s%c\n", "Changing to menu item --> ", 'A');
    break;
  case 'B':
    printf("%s%c\n", "Changing to menu item --> ", 'B');
    break;
  case 'C':
    printf("%s%c\n", "Changing to menu item --> ", 'C');
    break;
  default:
    printf("%s\n", "Sorry, invalid option");
    break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<show_selection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x10,%eax
ja     11bf <show_selection+0xaf>
mov    -0x10(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef5(%rip),%rdi
lea    0xef2(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <show_selection+0xc4>
lea    0xee8(%rip),%rdi
lea    0xee7(%rip),%rsi
mov    $0x41,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <show_selection+0xc4>
lea    0xec9(%rip),%rdi
lea    0xec8(%rip),%rsi
mov    $0x42,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <show_selection+0xc4>
lea    0xeaa(%rip),%rdi
lea    0xea9(%rip),%rsi
mov    $0x43,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <show_selection+0xc4>
lea    0xe7e(%rip),%rdi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_selection>:
push   %rax
add    $0xffffffbf,%edi
cmp    $0x10,%edi
ja     116f <show_selection+0x5f>
lea    0xee0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xf21(%rip),%rdi
lea    0xf20(%rip),%rsi
mov    $0x41,%edx
jmp    1166 <show_selection+0x56>
lea    0xf0c(%rip),%rdi
lea    0xf0b(%rip),%rsi
mov    $0x42,%edx
jmp    1166 <show_selection+0x56>
lea    0xef7(%rip),%rdi
lea    0xef6(%rip),%rsi
mov    $0x43,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1194 <show_selection+0x84>
lea    0xece(%rip),%rdi
lea    0xef5(%rip),%rsi
jmp    118d <show_selection+0x7d>
lea    0xebe(%rip),%rdi
lea    0xebb(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [9 x i8] c"Goodbye!\00"
@.str.2 = [6 x i8] c"%s%c\0A\00"
@.str.3 = [27 x i8] c"Changing to menu item --> \00"
@.str.4 = [22 x i8] c"Sorry, invalid option\00"
define i32 @show_selection(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
switch i32 %4, label %13 [
i32 81, label %5
i32 65, label %7
i32 66, label %9
i32 67, label %11
]
5: ; preds = %1
%6 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %15
7: ; preds = %1
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 65)
br label %15
9: ; preds = %1
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 66)
br label %15
11: ; preds = %1
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 67)
br label %15
13: ; preds = %1
%14 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %13, %11, %9, %7, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [9 x i8] c"Goodbye!\00"
@.str.2 = [6 x i8] c"%s%c\0A\00"
@.str.3 = [27 x i8] c"Changing to menu item --> \00"
@.str.4 = [22 x i8] c"Sorry, invalid option\00"
define i32 @show_selection(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %11 [
i32 81, label %3
i32 65, label %5
i32 66, label %7
i32 67, label %9
]
3: ; preds = %1
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %13
5: ; preds = %1
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 65)
br label %13
7: ; preds = %1
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 66)
br label %13
9: ; preds = %1
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 67)
br label %13
11: ; preds = %1
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5, %3
ret i32 0
}