#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 ln_get_mercury_earth_dist(double);
double ln_get_mercury_phase(double);
double ln_get_mercury_solar_dist(double);
int log10(double);
double ln_get_mercury_magnitude(double JD) {
  double delta, r, i, i2, i3;
  r = ln_get_mercury_solar_dist(JD);
  delta = ln_get_mercury_earth_dist(JD);
  i = ln_get_mercury_phase(JD);
  i2 = i * i;
  i3 = i2 * i;
  return -0.42 + 5 * log10(r * delta) + 0.0380 * i - 0.000273 * i2 +
         0.000002 * i3;
}


x86 assembly (clang, -O0):
<ln_get_mercury_magnitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <ln_get_mercury_solar_dist@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <ln_get_mercury_earth_dist@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <ln_get_mercury_phase@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1060 <log10@plt>
imul   $0x5,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe62(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe49(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe2c(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  0xe0f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln_get_mercury_magnitude>:
sub    $0x28,%rsp
movsd  %xmm0,(%rsp)
call   1040 <ln_get_mercury_solar_dist@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1050 <ln_get_mercury_earth_dist@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <ln_get_mercury_phase@plt>
movsd  %xmm0,0x10(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1060 <log10@plt>
lea    (%rax,%rax,4),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe4e(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe48(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
mulsd  0xe3e(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
mulsd  0xe35(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @ln_get_mercury_magnitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = load double, double* %2
%9 = call double @ln_get_mercury_solar_dist(double %8)
store double %9, double* %4
%10 = load double, double* %2
%11 = call double @ln_get_mercury_earth_dist(double %10)
store double %11, double* %3
%12 = load double, double* %2
%13 = call double @ln_get_mercury_phase(double %12)
store double %13, double* %5
%14 = load double, double* %5
%15 = load double, double* %5
%16 = fmul double %14, %15
store double %16, double* %6
%17 = load double, double* %6
%18 = load double, double* %5
%19 = fmul double %17, %18
store double %19, double* %7
%20 = load double, double* %4
%21 = load double, double* %3
%22 = fmul double %20, %21
%23 = call i32 @log10(double %22)
%24 = mul nsw i32 5, %23
%25 = sitofp i32 %24 to double
%26 = fadd double -4.200000e-01, %25
%27 = load double, double* %5
%28 = call double @llvm.fmuladd.f64(double 3.800000e-02, double %27, double %26)
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double -2.730000e-04, double %29, double %28)
%31 = load double, double* %7
%32 = call double @llvm.fmuladd.f64(double 2.000000e-06, double %31, double %30)
ret double %32
}

LLVM IR (-O2):
define double @ln_get_mercury_magnitude(double %0) {
%2 = tail call double @ln_get_mercury_solar_dist(double %0)
%3 = tail call double @ln_get_mercury_earth_dist(double %0)
%4 = tail call double @ln_get_mercury_phase(double %0)
%5 = fmul double %4, %4
%6 = fmul double %4, %5
%7 = fmul double %2, %3
%8 = tail call i32 @log10(double %7)
%9 = mul nsw i32 %8, 5
%10 = sitofp i32 %9 to double
%11 = fadd double %10, -4.200000e-01
%12 = tail call double @llvm.fmuladd.f64(double %4, double 3.800000e-02, double %11)
%13 = tail call double @llvm.fmuladd.f64(double %5, double -2.730000e-04, double %12)
%14 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e-06, double %13)
ret double %14
}