#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_mars_earth_dist(double);
double ln_get_mars_phase(double);
double ln_get_mars_solar_dist(double);
int log10(double);
double ln_get_mars_magnitude(double JD) {
  double delta, r, i;
  r = ln_get_mars_solar_dist(JD);
  delta = ln_get_mars_earth_dist(JD);
  i = ln_get_mars_phase(JD);
  return -1.52 + 5 * log10(r * delta) + 0.016 * i;
}


x86 assembly (clang, -O0):
<ln_get_mars_magnitude>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <ln_get_mars_solar_dist@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <ln_get_mars_earth_dist@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <ln_get_mars_phase@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1060 <log10@plt>
imul   $0x5,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe70(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe57(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln_get_mars_magnitude>:
sub    $0x18,%rsp
movsd  %xmm0,(%rsp)
call   1040 <ln_get_mars_solar_dist@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <ln_get_mars_earth_dist@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <ln_get_mars_phase@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1060 <log10@plt>
lea    (%rax,%rax,4),%eax
cvtsi2sd %eax,%xmm1
addsd  0xe6d(%rip),%xmm1
movsd  (%rsp),%xmm0
mulsd  0xe68(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ln_get_mars_magnitude(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
%6 = load double, double* %2
%7 = call double @ln_get_mars_solar_dist(double %6)
store double %7, double* %4
%8 = load double, double* %2
%9 = call double @ln_get_mars_earth_dist(double %8)
store double %9, double* %3
%10 = load double, double* %2
%11 = call double @ln_get_mars_phase(double %10)
store double %11, double* %5
%12 = load double, double* %4
%13 = load double, double* %3
%14 = fmul double %12, %13
%15 = call i32 @log10(double %14)
%16 = mul nsw i32 5, %15
%17 = sitofp i32 %16 to double
%18 = fadd double -1.520000e+00, %17
%19 = load double, double* %5
%20 = call double @llvm.fmuladd.f64(double 1.600000e-02, double %19, double %18)
ret double %20
}

LLVM IR (-O2):
define double @ln_get_mars_magnitude(double %0) {
%2 = tail call double @ln_get_mars_solar_dist(double %0)
%3 = tail call double @ln_get_mars_earth_dist(double %0)
%4 = tail call double @ln_get_mars_phase(double %0)
%5 = fmul double %2, %3
%6 = tail call i32 @log10(double %5)
%7 = mul nsw i32 %6, 5
%8 = sitofp i32 %7 to double
%9 = fadd double %8, -1.520000e+00
%10 = tail call double @llvm.fmuladd.f64(double %4, double 1.600000e-02, double %9)
ret double %10
}