void mjd_cal(mjd, mn, dy, yr) double mjd;
int *mn, *yr;
double *dy;
{
  static double last_mjd, last_dy;
  static int last_mn, last_yr;
  double d, f;
  double i, a, b, ce, g;
  if (mjd == 0.0) {
    *mn = 12;
    *dy = 31.5;
    *yr = 1899;
    return;
  }
  if (mjd == last_mjd) {
    *mn = last_mn;
    *yr = last_yr;
    *dy = last_dy;
    return;
  }
  d = mjd + 0.5;
  i = floor(d);
  f = d - i;
  if (f == 1) {
    f = 0;
    i += 1;
  }
  if (i > -115860.0) {
    a = floor((i / 36524.25) + .99835726) + 14;
    i += 1 + a - floor(a / 4.0);
  }
  b = floor((i / 365.25) + .802601);
  ce = i - floor((365.25 * b) + .750001) + 416;
  g = floor(ce / 30.6001);
  *mn = g - 1;
  *dy = ce - floor(30.6001 * g) + f;
  *yr = b + 1899;
  if (g > 13.5)
    *mn = g - 13;
  if (*mn < 2.5)
    *yr = b + 1900;
  if (*yr < 1)
    *yr -= 1;
  last_mn = *mn;
  last_dy = *dy;
  last_yr = *yr;
  last_mjd = mjd;
}


x86 assembly (clang, -O0):
<mjd_cal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116a <mjd_cal+0x5a>
jp     116a <mjd_cal+0x5a>
mov    -0x10(%rbp),%rax
movl   $0xc,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xf31(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x76b,(%rax)
jmp    1441 <mjd_cal+0x331>
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2eb9(%rip),%xmm0
jne    11b0 <mjd_cal+0xa0>
jp     11b0 <mjd_cal+0xa0>
mov    0x2eb7(%rip),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2eaf(%rip),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movsd  0x2e95(%rip),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1441 <mjd_cal+0x331>
movsd  0xe50(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1217 <mjd_cal+0x107>
jp     1217 <mjd_cal+0x107>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdf3(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdec(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    129f <mjd_cal+0x18f>
movsd  -0x38(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xde1(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  0xdc8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd97(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xd98(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdac(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xdb0(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xd7b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd77(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  0xd4a(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xd2c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xcc9(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xcf1(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
subsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xcbe(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x58(%rbp),%xmm0
movsd  0xc9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13c3 <mjd_cal+0x2b3>
movsd  -0x58(%rbp),%xmm0
movsd  0xcbb(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xca5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    13f4 <mjd_cal+0x2e4>
movsd  0xc9b(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x1,(%rax)
jge    140c <mjd_cal+0x2fc>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
sub    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x2c28(%rip)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x2c10(%rip)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x2c10(%rip)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2bef(%rip)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mjd_cal>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114e <mjd_cal+0x3e>
jp     114e <mjd_cal+0x3e>
movl   $0xc,(%r15)
movabs $0x403f800000000000,%rax
80 3f 40
mov    %rax,(%rbx)
movl   $0x76b,(%r14)
jmp    1370 <mjd_cal+0x260>
movsd  0x2eda(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1181 <mjd_cal+0x71>
jp     1181 <mjd_cal+0x71>
mov    0x2edc(%rip),%eax
mov    %eax,(%r15)
mov    0x2ed7(%rip),%eax
mov    %eax,(%r14)
movsd  0x2ec0(%rip),%xmm0
movsd  %xmm0,(%rbx)
jmp    1370 <mjd_cal+0x260>
movsd  0xe77(%rip),%xmm1
movsd  %xmm0,0x20(%rsp)
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movsd  0x18(%rsp),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm0,%xmm1
movsd  0xe50(%rip),%xmm0
ucomisd %xmm0,%xmm1
jne    11c4 <mjd_cal+0xb4>
jp     11c4 <mjd_cal+0xb4>
addsd  %xmm0,%xmm2
jne    11cc <mjd_cal+0xbc>
jp     11cc <mjd_cal+0xbc>
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x18(%rsp)
ucomisd 0xe36(%rip),%xmm2
jbe    1236 <mjd_cal+0x126>
movapd %xmm2,%xmm0
divsd  0xe30(%rip),%xmm0
addsd  0xe30(%rip),%xmm0
movsd  %xmm2,0x8(%rsp)
call   1030 <floor@plt>
addsd  0xe25(%rip),%xmm0
movsd  0xdfd(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe13(%rip),%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
divsd  0xdf4(%rip),%xmm2
addsd  0xdf4(%rip),%xmm2
movapd %xmm2,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xdd5(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xdd9(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
addsd  0xdc6(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
divsd  0xdbc(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0xdb1(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
mov    %eax,(%r15)
movsd  0xd96(%rip),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
subsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rbx)
movsd  0xd73(%rip),%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
movsd  0x28(%rsp),%xmm0
mov    %eax,(%r14)
ucomisd 0xd62(%rip),%xmm0
jbe    1321 <mjd_cal+0x211>
addsd  0xd60(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%r15)
jmp    1324 <mjd_cal+0x214>
mov    (%r15),%eax
movsd  0x20(%rsp),%xmm0
cmp    $0x2,%eax
jg     1344 <mjd_cal+0x234>
addsd  0xd49(%rip),%xmm2
cvttsd2si %xmm2,%eax
mov    %eax,(%r14)
test   %eax,%eax
jg     1351 <mjd_cal+0x241>
jmp    134b <mjd_cal+0x23b>
mov    (%r14),%eax
test   %eax,%eax
jg     1351 <mjd_cal+0x241>
add    $0xffffffff,%eax
mov    %eax,(%r14)
mov    (%r15),%ecx
mov    %ecx,0x2ce6(%rip)
movsd  %xmm1,0x2cd6(%rip)
mov    %eax,0x2cdc(%rip)
movsd  %xmm0,0x2cc0(%rip)
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@mjd_cal.last_mjd = internal global double 0.000000e+00
@mjd_cal.last_dy = internal global double 0.000000e+00
@mjd_cal.last_mn = internal global i32 0
@mjd_cal.last_yr = internal global i32 0
define void @mjd_cal(double %0, i32* %1, double* %2, i32* %3) {
%5 = alloca double
%6 = alloca i32*
%7 = alloca double*
%8 = alloca i32*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %5
store i32* %1, i32** %6
store double* %2, double** %7
store i32* %3, i32** %8
%16 = load double, double* %5
%17 = fcmp oeq double %16, 0.000000e+00
br i1 %17, label %18, label %22
18: ; preds = %4
%19 = load i32*, i32** %6
store i32 12, i32* %19
%20 = load double*, double** %7
store double 3.150000e+01, double* %20
%21 = load i32*, i32** %8
store i32 1899, i32* %21
br label %126
22: ; preds = %4
%23 = load double, double* %5
%24 = load double, double* @mjd_cal.last_mjd
%25 = fcmp oeq double %23, %24
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = load i32, i32* @mjd_cal.last_mn
%28 = load i32*, i32** %6
store i32 %27, i32* %28
%29 = load i32, i32* @mjd_cal.last_yr
%30 = load i32*, i32** %8
store i32 %29, i32* %30
%31 = load double, double* @mjd_cal.last_dy
%32 = load double*, double** %7
store double %31, double* %32
br label %126
33: ; preds = %22
%34 = load double, double* %5
%35 = fadd double %34, 5.000000e-01
store double %35, double* %9
%36 = load double, double* %9
%37 = call double @llvm.floor.f64(double %36)
store double %37, double* %11
%38 = load double, double* %9
%39 = load double, double* %11
%40 = fsub double %38, %39
store double %40, double* %10
%41 = load double, double* %10
%42 = fcmp oeq double %41, 1.000000e+00
br i1 %42, label %43, label %46
43: ; preds = %33
store double 0.000000e+00, double* %10
%44 = load double, double* %11
%45 = fadd double %44, 1.000000e+00
store double %45, double* %11
br label %46
46: ; preds = %43, %33
%47 = load double, double* %11
%48 = fcmp ogt double %47, -1.158600e+05
br i1 %48, label %49, label %63
49: ; preds = %46
%50 = load double, double* %11
%51 = fdiv double %50, 0x40E1D58800000000
%52 = fadd double %51, 0x3FEFF28AECAD92CB
%53 = call double @llvm.floor.f64(double %52)
%54 = fadd double %53, 1.400000e+01
store double %54, double* %12
%55 = load double, double* %12
%56 = fadd double 1.000000e+00, %55
%57 = load double, double* %12
%58 = fdiv double %57, 4.000000e+00
%59 = call double @llvm.floor.f64(double %58)
%60 = fsub double %56, %59
%61 = load double, double* %11
%62 = fadd double %61, %60
store double %62, double* %11
br label %63
63: ; preds = %49, %46
%64 = load double, double* %11
%65 = fdiv double %64, 3.652500e+02
%66 = fadd double %65, 8.026010e-01
%67 = call double @llvm.floor.f64(double %66)
store double %67, double* %13
%68 = load double, double* %11
%69 = load double, double* %13
%70 = call double @llvm.fmuladd.f64(double 3.652500e+02, double %69, double 7.500010e-01)
%71 = call double @llvm.floor.f64(double %70)
%72 = fsub double %68, %71
%73 = fadd double %72, 4.160000e+02
store double %73, double* %14
%74 = load double, double* %14
%75 = fdiv double %74, 3.060010e+01
%76 = call double @llvm.floor.f64(double %75)
store double %76, double* %15
%77 = load double, double* %15
%78 = fsub double %77, 1.000000e+00
%79 = fptosi double %78 to i32
%80 = load i32*, i32** %6
store i32 %79, i32* %80
%81 = load double, double* %14
%82 = load double, double* %15
%83 = fmul double 3.060010e+01, %82
%84 = call double @llvm.floor.f64(double %83)
%85 = fsub double %81, %84
%86 = load double, double* %10
%87 = fadd double %85, %86
%88 = load double*, double** %7
store double %87, double* %88
%89 = load double, double* %13
%90 = fadd double %89, 1.899000e+03
%91 = fptosi double %90 to i32
%92 = load i32*, i32** %8
store i32 %91, i32* %92
%93 = load double, double* %15
%94 = fcmp ogt double %93, 1.350000e+01
br i1 %94, label %95, label %100
95: ; preds = %63
%96 = load double, double* %15
%97 = fsub double %96, 1.300000e+01
%98 = fptosi double %97 to i32
%99 = load i32*, i32** %6
store i32 %98, i32* %99
br label %100
100: ; preds = %95, %63
%101 = load i32*, i32** %6
%102 = load i32, i32* %101
%103 = sitofp i32 %102 to double
%104 = fcmp olt double %103, 2.500000e+00
br i1 %104, label %105, label %110
105: ; preds = %100
%106 = load double, double* %13
%107 = fadd double %106, 1.900000e+03
%108 = fptosi double %107 to i32
%109 = load i32*, i32** %8
store i32 %108, i32* %109
br label %110
110: ; preds = %105, %100
%111 = load i32*, i32** %8
%112 = load i32, i32* %111
%113 = icmp slt i32 %112, 1
br i1 %113, label %114, label %118
114: ; preds = %110
%115 = load i32*, i32** %8
%116 = load i32, i32* %115
%117 = sub nsw i32 %116, 1
store i32 %117, i32* %115
br label %118
118: ; preds = %114, %110
%119 = load i32*, i32** %6
%120 = load i32, i32* %119
store i32 %120, i32* @mjd_cal.last_mn
%121 = load double*, double** %7
%122 = load double, double* %121
store double %122, double* @mjd_cal.last_dy
%123 = load i32*, i32** %8
%124 = load i32, i32* %123
store i32 %124, i32* @mjd_cal.last_yr
%125 = load double, double* %5
store double %125, double* @mjd_cal.last_mjd
br label %126
126: ; preds = %118, %26, %18
ret void
}

LLVM IR (-O2):
@mjd_cal.last_mjd = internal unnamed_addr global double 0.000000e+00
@mjd_cal.last_dy = internal unnamed_addr global double 0.000000e+00
@mjd_cal.last_mn = internal unnamed_addr global i32 0
@mjd_cal.last_yr = internal unnamed_addr global i32 0
define void @mjd_cal(double %0, i32* nocapture %1, double* nocapture %2, i32* nocapture %3) {
%5 = fcmp oeq double %0, 0.000000e+00
br i1 %5, label %6, label %7
6: ; preds = %4
store i32 12, i32* %1
store double 3.150000e+01, double* %2
store i32 1899, i32* %3
br label %74
7: ; preds = %4
%8 = load double, double* @mjd_cal.last_mjd
%9 = fcmp oeq double %8, %0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load i32, i32* @mjd_cal.last_mn
store i32 %11, i32* %1
%12 = load i32, i32* @mjd_cal.last_yr
store i32 %12, i32* %3
%13 = load double, double* @mjd_cal.last_dy
store double %13, double* %2
br label %74
14: ; preds = %7
%15 = fadd double %0, 5.000000e-01
%16 = tail call double @llvm.floor.f64(double %15)
%17 = fsub double %15, %16
%18 = fcmp oeq double %17, 1.000000e+00
%19 = fadd double %16, 1.000000e+00
%20 = select i1 %18, double %19, double %16
%21 = select i1 %18, double 0.000000e+00, double %17
%22 = fcmp ogt double %20, -1.158600e+05
br i1 %22, label %23, label %33
23: ; preds = %14
%24 = fdiv double %20, 0x40E1D58800000000
%25 = fadd double %24, 0x3FEFF28AECAD92CB
%26 = tail call double @llvm.floor.f64(double %25)
%27 = fadd double %26, 1.400000e+01
%28 = fadd double %27, 1.000000e+00
%29 = fmul double %27, 2.500000e-01
%30 = tail call double @llvm.floor.f64(double %29)
%31 = fsub double %28, %30
%32 = fadd double %20, %31
br label %33
33: ; preds = %23, %14
%34 = phi double [ %32, %23 ], [ %20, %14 ]
%35 = fdiv double %34, 3.652500e+02
%36 = fadd double %35, 8.026010e-01
%37 = tail call double @llvm.floor.f64(double %36)
%38 = tail call double @llvm.fmuladd.f64(double %37, double 3.652500e+02, double 7.500010e-01)
%39 = tail call double @llvm.floor.f64(double %38)
%40 = fsub double %34, %39
%41 = fadd double %40, 4.160000e+02
%42 = fdiv double %41, 3.060010e+01
%43 = tail call double @llvm.floor.f64(double %42)
%44 = fadd double %43, -1.000000e+00
%45 = fptosi double %44 to i32
store i32 %45, i32* %1
%46 = fmul double %43, 3.060010e+01
%47 = tail call double @llvm.floor.f64(double %46)
%48 = fsub double %41, %47
%49 = fadd double %21, %48
store double %49, double* %2
%50 = fadd double %37, 1.899000e+03
%51 = fptosi double %50 to i32
store i32 %51, i32* %3
%52 = fcmp ogt double %43, 1.350000e+01
br i1 %52, label %53, label %56
53: ; preds = %33
%54 = fadd double %43, -1.300000e+01
%55 = fptosi double %54 to i32
store i32 %55, i32* %1
br label %58
56: ; preds = %33
%57 = load i32, i32* %1
br label %58
58: ; preds = %56, %53
%59 = phi i32 [ %57, %56 ], [ %55, %53 ]
%60 = icmp slt i32 %59, 3
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = fadd double %37, 1.900000e+03
%63 = fptosi double %62 to i32
store i32 %63, i32* %3
br label %66
64: ; preds = %58
%65 = load i32, i32* %3
br label %66
66: ; preds = %64, %61
%67 = phi i32 [ %65, %64 ], [ %63, %61 ]
%68 = icmp slt i32 %67, 1
br i1 %68, label %69, label %71
69: ; preds = %66
%70 = add nsw i32 %67, -1
store i32 %70, i32* %3
br label %71
71: ; preds = %69, %66
%72 = phi i32 [ %70, %69 ], [ %67, %66 ]
%73 = load i32, i32* %1
store i32 %73, i32* @mjd_cal.last_mn
store double %49, double* @mjd_cal.last_dy
store i32 %72, i32* @mjd_cal.last_yr
store double %0, double* @mjd_cal.last_mjd
br label %74
74: ; preds = %71, %10, %6
ret void
}