#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 /*<<< orphan*/ cal_mjd(int, double, int, double *);
scalar_t__ floor(double);
void year_mjd(double y, double *mjp) {
  double e0, e1;
  int yf = (int)floor(y);
  if (yf == -1)
    yf = -2;
  cal_mjd(1, 1.0, yf, &e0);
  cal_mjd(1, 1.0, yf + 1, &e1);
  *mjp = e0 + (y - yf) * (e1 - e0);
}


x86 assembly (clang, -O0):
<year_mjd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <floor@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    114f <year_mjd+0x2f>
movl   $0xfffffffe,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    $0x1,%edi
movsd  0xea1(%rip),%xmm0
lea    -0x18(%rbp),%rdx
call   1030 <cal_mjd@plt>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
movsd  0xe85(%rip),%xmm0
lea    -0x20(%rbp),%rdx
call   1030 <cal_mjd@plt>
movsd  -0x18(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm2
subsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<year_mjd>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movsd  %xmm0,(%rsp)
call   1040 <floor@plt>
cmp    $0xffffffff,%eax
mov    $0xfffffffe,%ebx
cmovne %eax,%ebx
movsd  0xeb9(%rip),%xmm0
lea    0x10(%rsp),%rdx
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <cal_mjd@plt>
lea    0x1(%rbx),%esi
lea    0x8(%rsp),%rdx
mov    $0x1,%edi
movsd  0xe93(%rip),%xmm0
call   1030 <cal_mjd@plt>
movsd  0x10(%rsp),%xmm0
cvtsi2sd %ebx,%xmm1
movsd  (%rsp),%xmm2
subsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @year_mjd(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %3
store double* %1, double** %4
%8 = load double, double* %3
%9 = call i64 @floor(double %8)
%10 = trunc i64 %9 to i32
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -2, i32* %7
br label %14
14: ; preds = %13, %2
%15 = load i32, i32* %7
%16 = call i32 @cal_mjd(i32 1, double 1.000000e+00, i32 %15, double* %5)
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
%19 = call i32 @cal_mjd(i32 1, double 1.000000e+00, i32 %18, double* %6)
%20 = load double, double* %5
%21 = load double, double* %3
%22 = load i32, i32* %7
%23 = sitofp i32 %22 to double
%24 = fsub double %21, %23
%25 = load double, double* %6
%26 = load double, double* %5
%27 = fsub double %25, %26
%28 = call double @llvm.fmuladd.f64(double %24, double %27, double %20)
%29 = load double*, double** %4
store double %28, double* %29
ret void
}

LLVM IR (-O2):
define void @year_mjd(double %0, double* nocapture writeonly %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = tail call i64 @floor(double %0)
%8 = trunc i64 %7 to i32
%9 = icmp eq i32 %8, -1
%10 = select i1 %9, i32 -2, i32 %8
%11 = call i32 @cal_mjd(i32 1, double 1.000000e+00, i32 %10, double* %3)
%12 = add nuw nsw i32 %10, 1
%13 = call i32 @cal_mjd(i32 1, double 1.000000e+00, i32 %12, double* %4)
%14 = load double, double* %3
%15 = sitofp i32 %10 to double
%16 = fsub double %0, %15
%17 = load double, double* %4
%18 = fsub double %17, %14
%19 = call double @llvm.fmuladd.f64(double %16, double %18, double %14)
store double %19, double* %1
ret void
}