#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void areaComputation() {
  int s, x, y, r;
  double Area;
  do {
    printf("\n COMPUTE AREA OF:\n");
    printf("=========================");
    printf("\n 1 - square");
    printf("\n 2 - rectangle");
    printf("\n 3 - circle");
    printf("\n 4 - back to main\n");
    printf("Enter Selection : ");
    scanf("%i", &s);
    if (s == 1) {
      printf("Enter Value of x: ");
      scanf("%i", &x);
      Area = x * x;
      printf("Area of square is %.2f sq. units.", Area);
    } else if (s == 2) {
      printf("Enter Value of x: ");
      scanf("%i", &x);
      printf("Enter Value of y: ");
      scanf("%i", &y);
      Area = x * y;
      printf("Area of rectangle is %.2f", Area);
    } else if (s == 3) {
      printf("Enter Value of r: ");
      scanf("%i", &r);
      Area = r * r * 3.14159;
      ;
      printf("Area of circle is %.2f.", Area);
    } else if (s == 4) {
      printf("Returning to Main Menu  ... ");
    } else {
      printf("Invalid input! Please try again ... ");
    }
  } while (s != 4);
}


x86 assembly (clang, -O0):
<areaComputation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11ea <areaComputation+0xca>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xebf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12ee <areaComputation+0x1ce>
cmpl   $0x2,-0x4(%rbp)
jne    1258 <areaComputation+0x138>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe86(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12e9 <areaComputation+0x1c9>
cmpl   $0x3,-0x4(%rbp)
jne    12b4 <areaComputation+0x194>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe10(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
imul   -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xd6d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12e4 <areaComputation+0x1c4>
cmpl   $0x4,-0x4(%rbp)
jne    12d1 <areaComputation+0x1b1>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12df <areaComputation+0x1bf>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e4 <areaComputation+0x1c4>
jmp    12e9 <areaComputation+0x1c9>
jmp    12ee <areaComputation+0x1ce>
jmp    12f3 <areaComputation+0x1d3>
cmpl   $0x4,-0x4(%rbp)
jne    1128 <areaComputation+0x8>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<areaComputation>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xf0a(%rip),%rbx
lea    0x1008(%rip),%rbp
lea    0xf09(%rip),%r14
lea    0xf15(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xea2(%rip),%r13
jmp    11b2 <areaComputation+0x82>
nopl   0x0(%rax,%rax,1)
lea    0xefb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
imul   %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xee5(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmpl   $0x4,0xc(%rsp)
je     12e9 <areaComputation+0x1b9>
lea    0xf88(%rip),%rdi
call   1030 <puts@plt>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1280 <areaComputation+0x150>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
lea    0xe46(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
imul   0x8(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe48(%rip),%rdi
jmp    11a0 <areaComputation+0x70>
nopw   0x0(%rax,%rax,1)
lea    0xe95(%rip),%rdi
jmp    12d7 <areaComputation+0x1a7>
nopl   0x0(%rax)
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
imul   %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd3f(%rip),%xmm0
lea    0xe1f(%rip),%rdi
jmp    11a0 <areaComputation+0x70>
nopl   (%rax)
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x4,0xc(%rsp)
jne    11b2 <areaComputation+0x82>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0A COMPUTE AREA OF:\0A\00"
@.str.1 = [26 x i8] c"=========================\00"
@.str.2 = [13 x i8] c"\0A 1 - square\00"
@.str.3 = [16 x i8] c"\0A 2 - rectangle\00"
@.str.4 = [13 x i8] c"\0A 3 - circle\00"
@.str.5 = [20 x i8] c"\0A 4 - back to main\0A\00"
@.str.6 = [19 x i8] c"Enter Selection : \00"
@.str.7 = [3 x i8] c"%i\00"
@.str.8 = [19 x i8] c"Enter Value of x: \00"
@.str.9 = [34 x i8] c"Area of square is %.2f sq. units.\00"
@.str.10 = [19 x i8] c"Enter Value of y: \00"
@.str.11 = [26 x i8] c"Area of rectangle is %.2f\00"
@.str.12 = [19 x i8] c"Enter Value of r: \00"
@.str.13 = [24 x i8] c"Area of circle is %.2f.\00"
@.str.14 = [29 x i8] c"Returning to Main Menu ... \00"
@.str.15 = [37 x i8] c"Invalid input! Please try again ... \00"
define void @areaComputation() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
br label %6
6: ; preds = %64, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %26
17: ; preds = %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = load i32, i32* %2
%22 = mul nsw i32 %20, %21
%23 = sitofp i32 %22 to double
store double %23, double* %5
%24 = load double, double* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), double %24)
br label %63
26: ; preds = %6
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%34 = load i32, i32* %2
%35 = load i32, i32* %3
%36 = mul nsw i32 %34, %35
%37 = sitofp i32 %36 to double
store double %37, double* %5
%38 = load double, double* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), double %38)
br label %62
40: ; preds = %26
%41 = load i32, i32* %1
%42 = icmp eq i32 %41, 3
br i1 %42, label %43, label %53
43: ; preds = %40
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%46 = load i32, i32* %4
%47 = load i32, i32* %4
%48 = mul nsw i32 %46, %47
%49 = sitofp i32 %48 to double
%50 = fmul double %49, 3.141590e+00
store double %50, double* %5
%51 = load double, double* %5
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), double %51)
br label %61
53: ; preds = %40
%54 = load i32, i32* %1
%55 = icmp eq i32 %54, 4
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0))
br label %60
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
br label %61
61: ; preds = %60, %43
br label %62
62: ; preds = %61, %29
br label %63
63: ; preds = %62, %17
br label %64
64: ; preds = %63
%65 = load i32, i32* %1
%66 = icmp ne i32 %65, 4
br i1 %66, label %6, label %67
67: ; preds = %64
ret void
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"=========================\00"
@.str.2 = [13 x i8] c"\0A 1 - square\00"
@.str.3 = [16 x i8] c"\0A 2 - rectangle\00"
@.str.4 = [13 x i8] c"\0A 3 - circle\00"
@.str.6 = [19 x i8] c"Enter Selection : \00"
@.str.7 = [3 x i8] c"%i\00"
@.str.8 = [19 x i8] c"Enter Value of x: \00"
@.str.9 = [34 x i8] c"Area of square is %.2f sq. units.\00"
@.str.10 = [19 x i8] c"Enter Value of y: \00"
@.str.11 = [26 x i8] c"Area of rectangle is %.2f\00"
@.str.12 = [19 x i8] c"Enter Value of r: \00"
@.str.13 = [24 x i8] c"Area of circle is %.2f.\00"
@.str.14 = [29 x i8] c"Returning to Main Menu ... \00"
@.str.15 = [37 x i8] c"Invalid input! Please try again ... \00"
@str = [19 x i8] c"\0A COMPUTE AREA OF:\00"
@str.16 = [19 x i8] c"\0A 4 - back to main\00"
define void @areaComputation() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
br label %9
9: ; preds = %48, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.16, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
switch i32 %18, label %46 [
i32 1, label %19
i32 2, label %26
i32 3, label %36
i32 4, label %44
]
19: ; preds = %9
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
%23 = mul nsw i32 %22, %22
%24 = sitofp i32 %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), double %24)
br label %48
26: ; preds = %9
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = mul nsw i32 %32, %31
%34 = sitofp i32 %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), double %34)
br label %48
36: ; preds = %9
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%39 = load i32, i32* %4
%40 = mul nsw i32 %39, %39
%41 = sitofp i32 %40 to double
%42 = fmul double %41, 3.141590e+00
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), double %42)
br label %48
44: ; preds = %9
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.14, i64 0, i64 0))
br label %48
46: ; preds = %9
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.15, i64 0, i64 0))
br label %48
48: ; preds = %19, %36, %46, %44, %26
%49 = load i32, i32* %1
%50 = icmp eq i32 %49, 4
br i1 %50, label %51, label %9
51: ; preds = %48
ret void
}