#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 main(void) {
  char function;
  float base_length, height, base_width, radius;
  printf("Geometry Type (c-circle, t-triangle, r-rectangle): ");
  scanf("%c", &function);
  if (function == 99 || function == 67) {
    printf("Enter radius (cm): ");
    scanf("%f", &radius);
    printf("Area of this circle is %.1f square centimetres\n",
           3.14159265358979323846 * (radius * radius));
  } else {
    if (function == 116 || function == 84) {
      printf("Enter base length (cm): ");
      scanf("%f", &base_length);
      printf("Enter height (cm): ");
      scanf("%f", &height);
      printf("Area of this triangle is %.1f square centimetres\n",
             (base_length * height) * 0.5);
    } else {
      if (function == 114 || function == 82) {
        printf("Enter base width (cm): ");
        scanf("%f", &base_width);
        printf("Enter height (cm): ");
        scanf("%f", &height);
        printf("Area of this rectangle is %.1f square centimetres\n",
               base_width * height);
      } else {
        printf("Invalid Input\n");
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x63,%eax
je     1169 <main+0x49>
movsbl -0x5(%rbp),%eax
cmp    $0x43,%eax
jne    11b6 <main+0x96>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x18(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
mulsd  %xmm1,%xmm0
lea    0xeb4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d0 <main+0x1b0>
movsbl -0x5(%rbp),%eax
cmp    $0x74,%eax
je     11d0 <main+0xb0>
movsbl -0x5(%rbp),%eax
cmp    $0x54,%eax
jne    123d <main+0x11d>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe56(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdda(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xe8a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12cb <main+0x1ab>
movsbl -0x5(%rbp),%eax
cmp    $0x72,%eax
je     1257 <main+0x137>
movsbl -0x5(%rbp),%eax
cmp    $0x52,%eax
jne    12b8 <main+0x198>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdef(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x14(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12c6 <main+0x1a6>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cb <main+0x1ab>
jmp    12d0 <main+0x1b0>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xefa(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
and    $0xdf,%al
cmp    $0x54,%al
je     11b3 <main+0x83>
cmp    $0x52,%al
je     1215 <main+0xe5>
cmp    $0x43,%al
jne    1276 <main+0x146>
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
mulss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe61(%rip),%xmm0
lea    0xeb0(%rip),%rdi
jmp    126d <main+0x13d>
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe93(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xdf4(%rip),%xmm0
lea    0xea8(%rip),%rdi
jmp    126d <main+0x13d>
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe31(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movss  0x8(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe98(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1282 <main+0x152>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Geometry Type (c-circle, t-triangle, r-rectangle): \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"Enter radius (cm): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [48 x i8] c"Area of this circle is %.1f square centimetres\0A\00"
@.str.5 = [25 x i8] c"Enter base length (cm): \00"
@.str.6 = [20 x i8] c"Enter height (cm): \00"
@.str.7 = [50 x i8] c"Area of this triangle is %.1f square centimetres\0A\00"
@.str.8 = [24 x i8] c"Enter base width (cm): \00"
@.str.9 = [51 x i8] c"Area of this rectangle is %.1f square centimetres\0A\00"
@.str.10 = [15 x i8] c"Invalid Input\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 99
br i1 %11, label %16, label %12
12: ; preds = %0
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 67
br i1 %15, label %16, label %25
16: ; preds = %12, %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %6)
%19 = load float, float* %6
%20 = load float, float* %6
%21 = fmul float %19, %20
%22 = fpext float %21 to double
%23 = fmul double 0x400921FB54442D18, %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %23)
br label %66
25: ; preds = %12
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 116
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8, i8* %2
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 84
br i1 %32, label %33, label %44
33: ; preds = %29, %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%38 = load float, float* %3
%39 = load float, float* %4
%40 = fmul float %38, %39
%41 = fpext float %40 to double
%42 = fmul double %41, 5.000000e-01
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), double %42)
br label %65
44: ; preds = %29
%45 = load i8, i8* %2
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 114
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i8, i8* %2
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 82
br i1 %51, label %52, label %62
52: ; preds = %48, %44
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%57 = load float, float* %5
%58 = load float, float* %4
%59 = fmul float %57, %58
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), double %60)
br label %64
62: ; preds = %48
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %64
64: ; preds = %62, %52
br label %65
65: ; preds = %64, %33
br label %66
66: ; preds = %65, %16
%67 = load i32, i32* %1
ret i32 %67
}

LLVM IR (-O2):
@.str = [52 x i8] c"Geometry Type (c-circle, t-triangle, r-rectangle): \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"Enter radius (cm): \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [48 x i8] c"Area of this circle is %.1f square centimetres\0A\00"
@.str.5 = [25 x i8] c"Enter base length (cm): \00"
@.str.6 = [20 x i8] c"Enter height (cm): \00"
@.str.7 = [50 x i8] c"Area of this triangle is %.1f square centimetres\0A\00"
@.str.8 = [24 x i8] c"Enter base width (cm): \00"
@.str.9 = [51 x i8] c"Area of this rectangle is %.1f square centimetres\0A\00"
@str = [14 x i8] c"Invalid Input\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 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), i8* %1)
%12 = load i8, i8* %1
%13 = and i8 %12, -33
switch i8 %13, label %43 [
i8 67, label %14
i8 84, label %22
i8 82, label %33
]
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %5)
%17 = load float, float* %5
%18 = fmul float %17, %17
%19 = fpext float %18 to double
%20 = fmul double %19, 0x400921FB54442D18
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %20)
br label %45
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, 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* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%27 = load float, float* %2
%28 = load float, float* %3
%29 = fmul float %27, %28
%30 = fpext float %29 to double
%31 = fmul double %30, 5.000000e-01
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), double %31)
br label %45
33: ; preds = %0
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%35 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%38 = load float, float* %4
%39 = load float, float* %3
%40 = fmul float %38, %39
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.9, i64 0, i64 0), double %41)
br label %45
43: ; preds = %0
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %22, %43, %33, %14
ret i32 0
}