#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 pow(int, double);
double QuadPyramid(double SlantHeight, double BaseEdge) {
  double SArea;
  SArea =
      pow(BaseEdge, 2) +
      2 * BaseEdge * pow(((pow(SlantHeight, 2) - pow(BaseEdge, 2)) / 4), .5);
  return SArea;
}


x86 assembly (clang, -O0):
<QuadPyramid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%edi
movsd  0xed9(%rip),%xmm0
call   1030 <pow@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xec3(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvttsd2si -0x8(%rbp),%edi
movsd  0xeac(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,-0x2c(%rbp)
cvttsd2si -0x10(%rbp),%edi
movsd  0xe97(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
movsd  0xe71(%rip),%xmm0
call   1030 <pow@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuadPyramid>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm1,%ebp
movsd  0xed3(%rip),%xmm0
mov    %ebp,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
cvttsd2si 0x8(%rsp),%edi
movsd  0xea3(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,%ebx
mov    %ebp,%edi
movsd  0xe92(%rip),%xmm0
call   1030 <pow@plt>
sub    %eax,%ebx
lea    0x3(%rbx),%edi
test   %ebx,%ebx
cmovns %ebx,%edi
sar    $0x2,%edi
movsd  0xe80(%rip),%xmm0
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @QuadPyramid(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %3
store double %1, double* %4
%6 = load double, double* %4
%7 = fptosi double %6 to i32
%8 = call i32 @pow(i32 %7, double 2.000000e+00)
%9 = sitofp i32 %8 to double
%10 = load double, double* %4
%11 = fmul double 2.000000e+00, %10
%12 = load double, double* %3
%13 = fptosi double %12 to i32
%14 = call i32 @pow(i32 %13, double 2.000000e+00)
%15 = load double, double* %4
%16 = fptosi double %15 to i32
%17 = call i32 @pow(i32 %16, double 2.000000e+00)
%18 = sub nsw i32 %14, %17
%19 = sdiv i32 %18, 4
%20 = call i32 @pow(i32 %19, double 5.000000e-01)
%21 = sitofp i32 %20 to double
%22 = call double @llvm.fmuladd.f64(double %11, double %21, double %9)
store double %22, double* %5
%23 = load double, double* %5
ret double %23
}

LLVM IR (-O2):
define double @QuadPyramid(double %0, double %1) {
%3 = fptosi double %1 to i32
%4 = tail call i32 @pow(i32 %3, double 2.000000e+00)
%5 = sitofp i32 %4 to double
%6 = fmul double %1, 2.000000e+00
%7 = fptosi double %0 to i32
%8 = tail call i32 @pow(i32 %7, double 2.000000e+00)
%9 = tail call i32 @pow(i32 %3, double 2.000000e+00)
%10 = sub nsw i32 %8, %9
%11 = sdiv i32 %10, 4
%12 = tail call i32 @pow(i32 %11, double 5.000000e-01)
%13 = sitofp i32 %12 to double
%14 = tail call double @llvm.fmuladd.f64(double %6, double %13, double %5)
ret double %14
}