#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 CalculateAirDensity(double);
int /*<<< orphan*/ printf(char *, double, double, double);
double CalculateCDA(double Weight, double Altitude, double DescentRate) {
  double Density;
  Density = CalculateAirDensity(Altitude);
  printf("Alt %.0lf, Rate %.1lf, CDA %.1lf\n", Altitude, DescentRate,
         (Weight * 9.81) / (0.5 * Density * DescentRate * DescentRate));
  return (Weight * 9.81) / (0.5 * Density * DescentRate * DescentRate);
}


x86 assembly (clang, -O0):
<CalculateCDA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <CalculateAirDensity@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm2
mulsd  -0x8(%rbp),%xmm2
movsd  0xe9b(%rip),%xmm3
mulsd  -0x20(%rbp),%xmm3
mulsd  -0x18(%rbp),%xmm3
mulsd  -0x18(%rbp),%xmm3
divsd  %xmm3,%xmm2
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
movsd  0xe7c(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateCDA>:
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
movapd %xmm1,%xmm0
call   1030 <CalculateAirDensity@plt>
movsd  (%rsp),%xmm2
mulsd  0xeb5(%rip),%xmm2
mulsd  0xeb5(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
lea    0xe9f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Alt %.0lf, Rate %.1lf, CDA %.1lf\0A\00"
define double @CalculateCDA(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %5
%9 = call double @CalculateAirDensity(double %8)
store double %9, double* %7
%10 = load double, double* %5
%11 = load double, double* %6
%12 = load double, double* %4
%13 = fmul double %12, 9.810000e+00
%14 = load double, double* %7
%15 = fmul double 5.000000e-01, %14
%16 = load double, double* %6
%17 = fmul double %15, %16
%18 = load double, double* %6
%19 = fmul double %17, %18
%20 = fdiv double %13, %19
%21 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %10, double %11, double %20)
%22 = load double, double* %4
%23 = fmul double %22, 9.810000e+00
%24 = load double, double* %7
%25 = fmul double 5.000000e-01, %24
%26 = load double, double* %6
%27 = fmul double %25, %26
%28 = load double, double* %6
%29 = fmul double %27, %28
%30 = fdiv double %23, %29
ret double %30
}

LLVM IR (-O2):
@.str = [34 x i8] c"Alt %.0lf, Rate %.1lf, CDA %.1lf\0A\00"
define double @CalculateCDA(double %0, double %1, double %2) {
%4 = tail call double @CalculateAirDensity(double %1)
%5 = fmul double %0, 9.810000e+00
%6 = fmul double %4, 5.000000e-01
%7 = fmul double %6, %2
%8 = fmul double %7, %2
%9 = fdiv double %5, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), double %1, double %2, double %9)
ret double %9
}