#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 */
double calcBoxVol(float);
double calcCCPVol(float, float);
double calcRectVol(float, float, float);
double calcSphereVol(float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *, ...);
int main(void) {
  int getOp(void);
  void help(void);
  float v, l, b, h, r;
  int opType;
  v = 0;
  l = 0;
  b = 0;
  h = 0;
  r = 0;
  opType = 0;
  printf("Enter the opertation type: ");
  opType = getOp();
  if (opType == 1) {
    printf("Enter Length, Breadth, Height: ");
    scanf("%f, %f, %f", &l, &b, &h);
    printf("Volume = %f\n", calcRectVol(l, b, h));
    return 0;
  } else if (opType == 2) {
    printf("Enter Side: ");
    scanf("%f", &l);
    printf("Volume = %f\n", calcBoxVol(l));
    return 0;
  } else if (opType == 3) {
    printf("Enter radius: ");
    scanf("%f", &r);
    printf("Volume = %f\n", calcSphereVol(r));
    return 0;
  } else if (opType == 4) {
    printf("Enter radius, height: ");
    scanf("%f, %f", &r, &h);
    printf("Volume = %f\n", calcCCPVol(r, h));
    return 0;
  } else if (opType == 5) {
    help();
    return 0;
  } else {
    help();
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
call   1050 <getOp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1234 <main+0xb4>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1060 <calcRectVol@plt>
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ce>
cmpl   $0x2,-0x1c(%rbp)
jne    1282 <main+0x102>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
call   10a0 <calcBoxVol@plt>
lea    0xdd8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ce>
cmpl   $0x3,-0x1c(%rbp)
jne    12d0 <main+0x150>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda3(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0x18(%rbp),%xmm0
call   1080 <calcSphereVol@plt>
lea    0xd8a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ce>
cmpl   $0x4,-0x1c(%rbp)
jne    1327 <main+0x1a7>
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd51(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0x18(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
call   1030 <calcCCPVol@plt>
lea    0xd33(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ce>
cmpl   $0x5,-0x1c(%rbp)
jne    1342 <main+0x1c2>
call   1090 <help@plt>
movl   $0x0,-0x4(%rbp)
jmp    134e <main+0x1ce>
call   1090 <help@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
call   1050 <getOp@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1216 <main+0x96>
lea    0xe3a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0xc(%rsp),%rcx
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
call   1060 <calcRectVol@plt>
jmp    12b3 <main+0x133>
call   1090 <help@plt>
jmp    12c1 <main+0x141>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe23(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x10(%rsp),%xmm0
call   10a0 <calcBoxVol@plt>
jmp    12b3 <main+0x133>
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf5(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x8(%rsp),%xmm0
call   1080 <calcSphereVol@plt>
jmp    12b3 <main+0x133>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc3(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
call   1030 <calcCCPVol@plt>
lea    0xda1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter the opertation type: \00"
@.str.1 = [32 x i8] c"Enter Length, Breadth, Height: \00"
@.str.2 = [11 x i8] c"%f, %f, %f\00"
@.str.3 = [13 x i8] c"Volume = %f\0A\00"
@.str.4 = [13 x i8] c"Enter Side: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [15 x i8] c"Enter radius: \00"
@.str.7 = [23 x i8] c"Enter radius, height: \00"
@.str.8 = [7 x i8] c"%f, %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @getOp()
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %20
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float* %3, float* %4, float* %5)
%15 = load float, float* %3
%16 = load float, float* %4
%17 = load float, float* %5
%18 = call double @calcRectVol(float %15, float %16, float %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %18)
store i32 0, i32* %1
br label %53
20: ; preds = %0
%21 = load i32, i32* %7
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%26 = load float, float* %3
%27 = call double @calcBoxVol(float %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %27)
store i32 0, i32* %1
br label %53
29: ; preds = %20
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, 3
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %6)
%35 = load float, float* %6
%36 = call double @calcSphereVol(float %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %36)
store i32 0, i32* %1
br label %53
38: ; preds = %29
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 4
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%43 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), float* %6, float* %5)
%44 = load float, float* %6
%45 = load float, float* %5
%46 = call double @calcCCPVol(float %44, float %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %46)
store i32 0, i32* %1
br label %53
48: ; preds = %38
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 5
br i1 %50, label %51, label %52
51: ; preds = %48
store i32 0, i32* %1
br label %53
52: ; preds = %48
store i32 0, i32* %1
br label %53
53: ; preds = %52, %51, %41, %32, %23, %12
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter the opertation type: \00"
@.str.1 = [32 x i8] c"Enter Length, Breadth, Height: \00"
@.str.2 = [11 x i8] c"%f, %f, %f\00"
@.str.3 = [13 x i8] c"Volume = %f\0A\00"
@.str.4 = [13 x i8] c"Enter Side: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [15 x i8] c"Enter radius: \00"
@.str.7 = [23 x i8] c"Enter radius, height: \00"
@.str.8 = [7 x i8] c"%f, %f\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @getOp()
switch i32 %10, label %39 [
i32 1, label %11
i32 2, label %19
i32 3, label %25
i32 4, label %31
i32 5, label %38
]
11: ; preds = %0
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), float* %1, float* %2, float* %3)
%14 = load float, float* %1
%15 = load float, float* %2
%16 = load float, float* %3
%17 = call double @calcRectVol(float %14, float %15, float %16)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %17)
br label %40
19: ; preds = %0
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %1)
%22 = load float, float* %1
%23 = call double @calcBoxVol(float %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %23)
br label %40
25: ; preds = %0
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%28 = load float, float* %4
%29 = call double @calcSphereVol(float %28)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %29)
br label %40
31: ; preds = %0
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 (i8*, float*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), float* %4, float* %3)
%34 = load float, float* %4
%35 = load float, float* %3
%36 = call double @calcCCPVol(float %34, float %35)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %36)
br label %40
38: ; preds = %0
tail call void @help()
br label %40
39: ; preds = %0
tail call void @help()
br label %40
40: ; preds = %39, %38, %31, %25, %19, %11
ret i32 0
}