#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 floor(int);
double date2MJD(int yr, int mo, int day, int hr, int min, double sec) {
  double part1, part2;
  double MJD;
  part1 = 367 * ((double)yr) -
          floor(7 * ((double)yr + floor(((double)mo + 9) / 12.0)) / 4.0) +
          floor(275 * (double)mo / 9.0) + (double)day;
  part2 = -678987 + ((sec / 60.0 + (double)min) / 60.0 + (double)hr) / 24.0;
  MJD = part1 + part2;
  return MJD;
}


x86 assembly (clang, -O0):
<date2MJD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xeca(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xee6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
movsd  -0x50(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
movsd  0xebc(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xea8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
movsd  -0x48(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe35(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xdf8(%rip),%xmm0
divsd  %xmm0,%xmm1
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xde3(%rip),%xmm0
divsd  %xmm0,%xmm1
cvtsi2sdl -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xdc6(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdb2(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date2MJD>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %r8d,%ebp
mov    %ecx,%r14d
mov    %edx,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  %xmm0,0x10(%rsp)
addsd  0xeb8(%rip),%xmm0
divsd  0xeb8(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xea2(%rip),%xmm0
mulsd  0xea2(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe8c(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  0xe86(%rip),%xmm2
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  0xe4c(%rip),%xmm2
cvttsd2si %xmm2,%edi
call   1030 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
addsd  0x8(%rsp),%xmm1
movsd  0xe57(%rip),%xmm3
cvtsi2sd %ebp,%xmm4
movsd  0x18(%rsp),%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
divsd  0xe35(%rip),%xmm0
addsd  %xmm1,%xmm2
addsd  0xe31(%rip),%xmm0
addsd  %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @date2MJD(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double %5, double* %12
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %8
%21 = sitofp i32 %20 to double
%22 = fadd double %21, 9.000000e+00
%23 = fdiv double %22, 1.200000e+01
%24 = fptosi double %23 to i32
%25 = call i32 @floor(i32 %24)
%26 = sitofp i32 %25 to double
%27 = fadd double %19, %26
%28 = fmul double 7.000000e+00, %27
%29 = fdiv double %28, 4.000000e+00
%30 = fptosi double %29 to i32
%31 = call i32 @floor(i32 %30)
%32 = sitofp i32 %31 to double
%33 = fneg double %32
%34 = call double @llvm.fmuladd.f64(double 3.670000e+02, double %17, double %33)
%35 = load i32, i32* %8
%36 = sitofp i32 %35 to double
%37 = fmul double 2.750000e+02, %36
%38 = fdiv double %37, 9.000000e+00
%39 = fptosi double %38 to i32
%40 = call i32 @floor(i32 %39)
%41 = sitofp i32 %40 to double
%42 = fadd double %34, %41
%43 = load i32, i32* %9
%44 = sitofp i32 %43 to double
%45 = fadd double %42, %44
store double %45, double* %13
%46 = load double, double* %12
%47 = fdiv double %46, 6.000000e+01
%48 = load i32, i32* %11
%49 = sitofp i32 %48 to double
%50 = fadd double %47, %49
%51 = fdiv double %50, 6.000000e+01
%52 = load i32, i32* %10
%53 = sitofp i32 %52 to double
%54 = fadd double %51, %53
%55 = fdiv double %54, 2.400000e+01
%56 = fadd double -6.789870e+05, %55
store double %56, double* %14
%57 = load double, double* %13
%58 = load double, double* %14
%59 = fadd double %57, %58
store double %59, double* %15
%60 = load double, double* %15
ret double %60
}

LLVM IR (-O2):
define double @date2MJD(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double %5) {
%7 = sitofp i32 %0 to double
%8 = sitofp i32 %1 to double
%9 = fadd double %8, 9.000000e+00
%10 = fdiv double %9, 1.200000e+01
%11 = fptosi double %10 to i32
%12 = tail call i32 @floor(i32 %11)
%13 = sitofp i32 %12 to double
%14 = fadd double %7, %13
%15 = fmul double %14, 7.000000e+00
%16 = fmul double %15, 2.500000e-01
%17 = fptosi double %16 to i32
%18 = tail call i32 @floor(i32 %17)
%19 = sitofp i32 %18 to double
%20 = fneg double %19
%21 = tail call double @llvm.fmuladd.f64(double %7, double 3.670000e+02, double %20)
%22 = fmul double %8, 2.750000e+02
%23 = fdiv double %22, 9.000000e+00
%24 = fptosi double %23 to i32
%25 = tail call i32 @floor(i32 %24)
%26 = sitofp i32 %25 to double
%27 = fadd double %21, %26
%28 = sitofp i32 %2 to double
%29 = fadd double %27, %28
%30 = fdiv double %5, 6.000000e+01
%31 = sitofp i32 %4 to double
%32 = fadd double %30, %31
%33 = fdiv double %32, 6.000000e+01
%34 = sitofp i32 %3 to double
%35 = fadd double %33, %34
%36 = fdiv double %35, 2.400000e+01
%37 = fadd double %36, -6.789870e+05
%38 = fadd double %37, %29
ret double %38
}