#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*/ areaComputation();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ perimeterComputation();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ volumeComputation();
int main() {
  char selection;
  while (1) {
    printf("\n Main Menu");
    printf("\n================");
    printf("\n A - AREA");
    printf("\n B - VOLUME");
    printf("\n C - PERIMETER");
    printf("\n E - Exit");
    printf("\n Enter selection: ");
    scanf("%c", &selection);
    switch (selection) {
    case 'A':
    case 'a':
      areaComputation();
      break;
    case 'B':
    case 'b':
      volumeComputation();
      break;
    case 'C':
    case 'c':
      break;
    case 'E':
    case 'e':
      perimeterComputation();
      break;
    default:
      printf("\n Invalid selection");
      return main();
    }
    getchar();
    printf("\n");
    if (selection == 'E' || selection == 'e')
      break;
  }
  printf("\n Bye ...\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf14(%rip),%rdi
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
call   1030 <printf@plt>
lea    0xf14(%rip),%rdi
call   1030 <printf@plt>
lea    0xf18(%rip),%rdi
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1080 <scanf@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x24,%eax
ja     1236 <main+0xc6>
mov    -0x10(%rbp),%rax
lea    0xdfc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <areaComputation@plt>
jmp    124f <main+0xdf>
mov    $0x0,%al
call   1050 <volumeComputation@plt>
jmp    124f <main+0xdf>
jmp    124f <main+0xdf>
mov    $0x0,%al
call   1090 <perimeterComputation@plt>
jmp    124f <main+0xdf>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
call   1070 <main@plt>
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x129>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x45,%eax
je     127c <main+0x10c>
movsbl -0x5(%rbp),%eax
cmp    $0x65,%eax
jne    1281 <main+0x111>
jmp    1286 <main+0x116>
jmp    117f <main+0xf>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf28(%rip),%rbx
lea    0xf31(%rip),%rbp
lea    0xf35(%rip),%r14
lea    0xf42(%rip),%r15
lea    0x7(%rsp),%r12
lea    0xe3d(%rip),%r13
jmp    11f7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <areaComputation@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl 0x7(%rsp),%eax
and    $0xdf,%al
cmp    $0x45,%al
je     127c <main+0xec>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10a0 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffbf,%eax
cmp    $0x24,%eax
ja     1299 <main+0x109>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
xor    %eax,%eax
call   1070 <volumeComputation@plt>
jmp    11d7 <main+0x47>
nopl   (%rax)
xor    %eax,%eax
call   10b0 <perimeterComputation@plt>
jmp    11d7 <main+0x47>
lea    0xe8d(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5c(%rip),%rdi
call   1050 <printf@plt>
call   1090 <main@plt>
jmp    1288 <main+0xf8>

LLVM IR (-O0):
@.str = [12 x i8] c"\0A Main Menu\00"
@.str.1 = [18 x i8] c"\0A================\00"
@.str.2 = [11 x i8] c"\0A A - AREA\00"
@.str.3 = [13 x i8] c"\0A B - VOLUME\00"
@.str.4 = [16 x i8] c"\0A C - PERIMETER\00"
@.str.5 = [11 x i8] c"\0A E - Exit\00"
@.str.6 = [20 x i8] c"\0A Enter selection: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [20 x i8] c"\0A Invalid selection\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [11 x i8] c"\0A Bye ...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %0, %35
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %21 [
i32 65, label %14
i32 97, label %14
i32 66, label %16
i32 98, label %16
i32 67, label %18
i32 99, label %18
i32 69, label %19
i32 101, label %19
]
14: ; preds = %3, %3
%15 = call i32 (...) @areaComputation()
br label %24
16: ; preds = %3, %3
%17 = call i32 (...) @volumeComputation()
br label %24
18: ; preds = %3, %3
br label %24
19: ; preds = %3, %3
%20 = call i32 (...) @perimeterComputation()
br label %24
21: ; preds = %3
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 @main()
store i32 %23, i32* %1
br label %38
24: ; preds = %19, %18, %16, %14
%25 = call i32 (...) @getchar()
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 69
br i1 %29, label %34, label %30
30: ; preds = %24
%31 = load i8, i8* %2
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 101
br i1 %33, label %34, label %35
34: ; preds = %30, %24
br label %36
35: ; preds = %30
br label %3
36: ; preds = %34
%37 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %38
38: ; preds = %36, %21
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [12 x i8] c"\0A Main Menu\00"
@.str.1 = [18 x i8] c"\0A================\00"
@.str.2 = [11 x i8] c"\0A A - AREA\00"
@.str.3 = [13 x i8] c"\0A B - VOLUME\00"
@.str.4 = [16 x i8] c"\0A C - PERIMETER\00"
@.str.5 = [11 x i8] c"\0A E - Exit\00"
@.str.6 = [20 x i8] c"\0A Enter selection: \00"
@.str.7 = [3 x i8] c"%c\00"
@.str.8 = [20 x i8] c"\0A Invalid selection\00"
@str = [10 x i8] c"\0A Bye ...\00"
define i32 @main() {
%1 = alloca i8
br label %2
2: ; preds = %22, %0
%3 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%11 = load i8, i8* %1
%12 = sext i8 %11 to i32
switch i32 %12, label %19 [
i32 65, label %13
i32 97, label %13
i32 66, label %15
i32 98, label %15
i32 67, label %22
i32 99, label %22
i32 69, label %17
i32 101, label %17
]
13: ; preds = %2, %2
%14 = call i32 (...) @areaComputation()
br label %22
15: ; preds = %2, %2
%16 = call i32 (...) @volumeComputation()
br label %22
17: ; preds = %2, %2
%18 = call i32 (...) @perimeterComputation()
br label %22
19: ; preds = %2
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 @main()
br label %30
22: ; preds = %2, %2, %17, %15, %13
%23 = call i32 (...) @getchar()
%24 = call i32 @putchar(i32 10)
%25 = load i8, i8* %1
%26 = and i8 %25, -33
%27 = icmp eq i8 %26, 69
br i1 %27, label %28, label %2
28: ; preds = %22
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %19
ret i32 0
}