#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 EXIT_SUCCESS;
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char choice;
  puts("\t Main Menu:");
  puts(" a: Formula 1");
  puts(" b: Formula 2");
  puts(" e: Exit");
  while (1) {
    scanf("%c", &choice);
    if (choice == 'a' || choice == 'A') {
      puts("You chose Formula 1");
    } else if (choice == 'b' || choice == 'B') {
      puts("You chose Formula 2");
    } else if (choice == 'e' || choice == 'E') {
      puts("Exiting now...");
      break;
    } else {
      puts("Invalid Input... Please try again!");
    }
    getchar();
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1050 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
je     1199 <main+0x69>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jne    11aa <main+0x7a>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
jmp    1216 <main+0xe6>
movsbl -0x5(%rbp),%eax
cmp    $0x62,%eax
je     11c4 <main+0x94>
movsbl -0x5(%rbp),%eax
cmp    $0x42,%eax
jne    11d5 <main+0xa5>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
jmp    1211 <main+0xe1>
movsbl -0x5(%rbp),%eax
cmp    $0x65,%eax
je     11ef <main+0xbf>
movsbl -0x5(%rbp),%eax
cmp    $0x45,%eax
jne    1200 <main+0xd0>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
jmp    1222 <main+0xf2>
lea    0xe65(%rip),%rdi
call   1030 <puts@plt>
jmp    1211 <main+0xe1>
jmp    1216 <main+0xe6>
mov    $0x0,%al
call   1040 <getchar@plt>
jmp    116f <main+0x3f>
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%r14
lea    0xf(%rsp),%r15
lea    0xeb5(%rip),%rbx
lea    0xec2(%rip),%r12
lea    0xede(%rip),%r13
jmp    119f <main+0x6f>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
and    $0xdf,%al
mov    %rbx,%rdi
cmp    $0x41,%al
je     1193 <main+0x63>
cmp    $0x42,%al
je     1190 <main+0x60>
cmp    $0x45,%al
je     11c5 <main+0x95>
mov    %r13,%rdi
jmp    1193 <main+0x63>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\09 Main Menu:\00"
@.str.1 = [14 x i8] c" a: Formula 1\00"
@.str.2 = [14 x i8] c" b: Formula 2\00"
@.str.3 = [9 x i8] c" e: Exit\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [20 x i8] c"You chose Formula 1\00"
@.str.6 = [20 x i8] c"You chose Formula 2\00"
@.str.7 = [15 x i8] c"Exiting now...\00"
@.str.8 = [35 x i8] c"Invalid Input... Please try again!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %0, %42
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 97
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 65
br i1 %15, label %16, label %18
16: ; preds = %12, %7
%17 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %42
18: ; preds = %12
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 98
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 66
br i1 %25, label %26, label %28
26: ; preds = %22, %18
%27 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %41
28: ; preds = %22
%29 = load i8, i8* %2
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 101
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 69
br i1 %35, label %36, label %38
36: ; preds = %32, %28
%37 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %44
38: ; preds = %32
%39 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
br label %40
40: ; preds = %38
br label %41
41: ; preds = %40, %26
br label %42
42: ; preds = %41, %16
%43 = call i32 (...) @getchar()
br label %7
44: ; preds = %36
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}

LLVM IR (-O2):
@.str = [13 x i8] c"\09 Main Menu:\00"
@.str.1 = [14 x i8] c" a: Formula 1\00"
@.str.2 = [14 x i8] c" b: Formula 2\00"
@.str.3 = [9 x i8] c" e: Exit\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [20 x i8] c"You chose Formula 1\00"
@.str.6 = [20 x i8] c"You chose Formula 2\00"
@.str.7 = [15 x i8] c"Exiting now...\00"
@.str.8 = [35 x i8] c"Invalid Input... Please try again!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %6
6: ; preds = %15, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%8 = load i8, i8* %1
%9 = and i8 %8, -33
switch i8 %9, label %14 [
i8 65, label %15
i8 66, label %10
i8 69, label %11
]
10: ; preds = %6
br label %15
11: ; preds = %6
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
14: ; preds = %6
br label %15
15: ; preds = %6, %10, %14
%16 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), %10 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), %14 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), %6 ]
%17 = call i32 @puts(i8* dereferenceable(1) %16)
%18 = call i32 (...) @getchar()
br label %6
}