#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 PentPyramid(double, double, double);
double QuadPyramid(double, double);
double TriPyramid(double);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double TriPyr, QuadPyr, PentPyr, Edge, Base, Slant, Apothem, Side;
  printf("Calculate Trigonal Pyramid Surface Area\n\n");
  printf("Enter Edge Length in cm.:\n");
  scanf("%lf", &Edge);
  getchar();
  TriPyr = TriPyramid(Edge);
  printf("The Surface Area is: %lf cm^2\n\n\n", TriPyr);
  printf("Calculate Quadrilateral Pyramid Surface Area\n\n");
  printf("Enter Slant Height in cm:\n");
  scanf("%lf", &Slant);
  getchar();
  printf("Enter Base Edge Length in cm:\n");
  scanf("%lf", &Base);
  getchar();
  QuadPyr = QuadPyramid(Slant, Base);
  printf("The Surface Area is: %lf cm^2\n\n\n", QuadPyr);
  printf("Calculate Pentagonal Pyramid Surface Area\n\n");
  printf("Enter Apothem in cm:\n");
  scanf("%lf", &Apothem);
  getchar();
  printf("Enter Side Length in cm:\n");
  scanf("%lf", &Side);
  getchar();
  printf("Enter Slant Height in cm:\n");
  scanf("%lf", &Slant);
  getchar();
  PentPyr = PentPyramid(Apothem, Side, Slant);
  printf("The Surface Area is: %lf cm^2\n\n", PentPyr);
  printf("PROGRAM TERMINATED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsd  -0x28(%rbp),%xmm0
call   1060 <TriPyramid@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe8c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe39(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1080 <QuadPyramid@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xddf(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdba(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd95(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1070 <PentPyramid@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    0xe4a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe66(%rip),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsd  0x20(%rsp),%xmm0
call   1070 <TriPyramid@plt>
lea    0xe44(%rip),%r12
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xf50(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1090 <QuadPyramid@plt>
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
call   1080 <PentPyramid@plt>
lea    0xd6e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Calculate Trigonal Pyramid Surface Area\0A\0A\00"
@.str.1 = [27 x i8] c"Enter Edge Length in cm.:\0A\00"
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [33 x i8] c"The Surface Area is: %lf cm^2\0A\0A\0A\00"
@.str.4 = [47 x i8] c"Calculate Quadrilateral Pyramid Surface Area\0A\0A\00"
@.str.5 = [27 x i8] c"Enter Slant Height in cm:\0A\00"
@.str.6 = [31 x i8] c"Enter Base Edge Length in cm:\0A\00"
@.str.7 = [44 x i8] c"Calculate Pentagonal Pyramid Surface Area\0A\0A\00"
@.str.8 = [22 x i8] c"Enter Apothem in cm:\0A\00"
@.str.9 = [26 x i8] c"Enter Side Length in cm:\0A\00"
@.str.10 = [32 x i8] c"The Surface Area is: %lf cm^2\0A\0A\00"
@.str.11 = [20 x i8] c"PROGRAM TERMINATED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%13 = call i32 (...) @getchar()
%14 = load double, double* %5
%15 = call double @TriPyramid(double %14)
store double %15, double* %2
%16 = load double, double* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%21 = call i32 (...) @getchar()
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %6)
%24 = call i32 (...) @getchar()
%25 = load double, double* %7
%26 = load double, double* %6
%27 = call double @QuadPyramid(double %25, double %26)
store double %27, double* %3
%28 = load double, double* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %8)
%33 = call i32 (...) @getchar()
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %9)
%36 = call i32 (...) @getchar()
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %7)
%39 = call i32 (...) @getchar()
%40 = load double, double* %8
%41 = load double, double* %9
%42 = load double, double* %7
%43 = call double @PentPyramid(double %40, double %41, double %42)
store double %43, double* %4
%44 = load double, double* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), double %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [4 x i8] c"%lf\00"
@.str.3 = [33 x i8] c"The Surface Area is: %lf cm^2\0A\0A\0A\00"
@.str.10 = [32 x i8] c"The Surface Area is: %lf cm^2\0A\0A\00"
@str = [41 x i8] c"Calculate Trigonal Pyramid Surface Area\0A\00"
@str.12 = [26 x i8] c"Enter Edge Length in cm.:\00"
@str.13 = [46 x i8] c"Calculate Quadrilateral Pyramid Surface Area\0A\00"
@str.15 = [30 x i8] c"Enter Base Edge Length in cm:\00"
@str.16 = [43 x i8] c"Calculate Pentagonal Pyramid Surface Area\0A\00"
@str.17 = [21 x i8] c"Enter Apothem in cm:\00"
@str.18 = [25 x i8] c"Enter Side Length in cm:\00"
@str.19 = [26 x i8] c"Enter Slant Height in cm:\00"
@str.20 = [19 x i8] c"PROGRAM TERMINATED\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %1 to i8*
%7 = bitcast double* %2 to i8*
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %1)
%14 = call i32 (...) @getchar()
%15 = load double, double* %1
%16 = call double @TriPyramid(double %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.19, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%21 = call i32 (...) @getchar()
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.15, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %2)
%24 = call i32 (...) @getchar()
%25 = load double, double* %3
%26 = load double, double* %2
%27 = call double @QuadPyramid(double %25, double %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %27)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.16, i64 0, i64 0))
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.17, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %4)
%32 = call i32 (...) @getchar()
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.18, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %5)
%35 = call i32 (...) @getchar()
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.19, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double* %3)
%38 = call i32 (...) @getchar()
%39 = load double, double* %4
%40 = load double, double* %5
%41 = load double, double* %3
%42 = call double @PentPyramid(double %39, double %40, double %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), double %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.20, i64 0, i64 0))
ret i32 0
}