#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 *, ...);
main() {
  float findAreaRectangle(float width, float length);
  float findAreaCircle(float radius);
  int choice;
  float width, length, radius, area;
  for (;;) {
    printf("\nEnter the number you want to use\n1.Area of a rectangle\n2.Area "
           "of circle\nEnter your choice: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Enter the length: ");
      scanf("%f", &length);
      printf("Enter the width: ");
      scanf("%f", &width);
      area = findAreaRectangle(width, length);
      printf("The area of the rectangle is %f", area);
      break;
    case 2:
      printf("Enter the radius: ");
      scanf("%f", &radius);
      area = findAreaCircle(radius);
      printf("The area of the circle is %f", area);
      break;
    default:
      printf("Your choice is invalid");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1d(%rbp)
call   1040 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xef3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     1198 <main+0x58>
jmp    1187 <main+0x47>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1208 <main+0xc8>
jmp    1253 <main+0x113>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf25(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf05(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1060 <findAreaRectangle@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe89(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1261 <main+0x121>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movss  -0x14(%rbp),%xmm0
call   1030 <findAreaCircle@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1261 <main+0x121>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    114f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%r14
lea    0xf01(%rip),%r15
lea    0x14(%rsp),%r13
lea    0xf6a(%rip),%rbx
lea    0xf16(%rip),%rbp
lea    0xf5f(%rip),%r12
jmp    11ba <main+0x7a>
nopl   0x0(%rax,%rax,1)
lea    0xf1e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
call   1030 <findAreaCircle@plt>
cvtss2sd %xmm0,%xmm0
lea    0xf05(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     1180 <main+0x40>
cmp    $0x1,%eax
jne    1240 <main+0x100>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1060 <findAreaRectangle@plt>
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
jmp    11b3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ba <main+0x7a>

LLVM IR (-O0):
@.str = [93 x i8] c"\0AEnter the number you want to use\0A1.Area of a rectangle\0A2.Area of circle\0AEnter your choice: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Enter the length: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [18 x i8] c"Enter the width: \00"
@.str.5 = [32 x i8] c"The area of the rectangle is %f\00"
@.str.6 = [19 x i8] c"Enter the radius: \00"
@.str.7 = [29 x i8] c"The area of the circle is %f\00"
@.str.8 = [23 x i8] c"Your choice is invalid\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
br label %7
7: ; preds = %32, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
switch i32 %10, label %30 [
i32 1, label %11
i32 2, label %22
]
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%16 = load float, float* %3
%17 = load float, float* %4
%18 = call float @findAreaRectangle(float %16, float %17)
store float %18, float* %6
%19 = load float, float* %6
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), double %20)
br label %32
22: ; preds = %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%25 = load float, float* %5
%26 = call float @findAreaCircle(float %25)
store float %26, float* %6
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %28)
br label %32
30: ; preds = %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %32
32: ; preds = %30, %22, %11
br label %7
}

LLVM IR (-O2):
@.str = [93 x i8] c"\0AEnter the number you want to use\0A1.Area of a rectangle\0A2.Area of circle\0AEnter your choice: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Enter the length: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [18 x i8] c"Enter the width: \00"
@.str.5 = [32 x i8] c"The area of the rectangle is %f\00"
@.str.6 = [19 x i8] c"Enter the radius: \00"
@.str.7 = [29 x i8] c"The area of the circle is %f\00"
@.str.8 = [23 x i8] c"Your choice is invalid\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast i32* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
br label %9
9: ; preds = %32, %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %30 [
i32 1, label %13
i32 2, label %23
]
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%18 = load float, float* %2
%19 = load float, float* %3
%20 = call float @findAreaRectangle(float %18, float %19)
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), double %21)
br label %32
23: ; preds = %9
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%26 = load float, float* %4
%27 = call float @findAreaCircle(float %26)
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %28)
br label %32
30: ; preds = %9
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %32
32: ; preds = %30, %23, %13
br label %9
}