#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*/ formula1();
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') {
      formula1();
    } 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    0xeaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x61,%eax
je     11a9 <main+0x69>
movsbl -0x5(%rbp),%eax
cmp    $0x41,%eax
jne    11b5 <main+0x75>
mov    $0x0,%al
call   1040 <formula1@plt>
jmp    1221 <main+0xe1>
movsbl -0x5(%rbp),%eax
cmp    $0x62,%eax
je     11cf <main+0x8f>
movsbl -0x5(%rbp),%eax
cmp    $0x42,%eax
jne    11e0 <main+0xa0>
lea    0xe5f(%rip),%rdi
call   1030 <puts@plt>
jmp    121c <main+0xdc>
movsbl -0x5(%rbp),%eax
cmp    $0x65,%eax
je     11fa <main+0xba>
movsbl -0x5(%rbp),%eax
cmp    $0x45,%eax
jne    120b <main+0xcb>
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
jmp    122d <main+0xed>
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
jmp    121c <main+0xdc>
jmp    1221 <main+0xe1>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    117f <main+0x3f>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%r14
lea    0x7(%rsp),%rbx
lea    0xeaa(%rip),%r15
lea    0xec6(%rip),%r12
jmp    11af <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movzbl 0x7(%rsp),%eax
and    $0xdf,%al
cmp    $0x41,%al
je     11e0 <main+0xa0>
cmp    $0x42,%al
je     11a0 <main+0x60>
cmp    $0x45,%al
je     11e9 <main+0xa9>
mov    %r12,%rdi
jmp    11a3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <formula1@plt>
jmp    11a8 <main+0x68>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
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 2\00"
@.str.6 = [15 x i8] c"Exiting now...\00"
@.str.7 = [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 (...) @formula1()
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.5, 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.6, i64 0, i64 0))
br label %44
38: ; preds = %32
%39 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, 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 2\00"
@.str.6 = [15 x i8] c"Exiting now...\00"
@.str.7 = [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 = %19, %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 %17 [
i8 65, label %10
i8 66, label %12
i8 69, label %14
]
10: ; preds = %6
%11 = call i32 (...) @formula1()
br label %19
12: ; preds = %6
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %19
14: ; preds = %6
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
17: ; preds = %6
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %19
19: ; preds = %12, %17, %10
%20 = call i32 (...) @getchar()
br label %6
}