#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 floor(double);
double julian_day(int year, int month, int day, int hour, int minute,
                  int second, double tz) {
  double day_decimal, julian_day, a;
  day_decimal = day + (hour - tz + (minute + second / 60.0) / 60.0) / 24.0;
  if (month < 3) {
    month += 12;
    year--;
  }
  julian_day = floor(365.25 * (year + 4716.0)) + floor(30.6001 * (month + 1)) +
               day_decimal - 1524.5;
  if (julian_day > 2299160.0) {
    a = floor(year / 100);
    julian_day += (2 - a + floor(a / 4));
  }
  return julian_day;
}


x86 assembly (clang, -O0):
<julian_day>:
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)
mov    %r9d,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
cvtsi2sdl -0x18(%rbp),%xmm3
movsd  0xeb6(%rip),%xmm4
divsd  %xmm4,%xmm3
addsd  %xmm3,%xmm2
movsd  0xea6(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  0xe8e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119b <julian_day+0x8b>
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe88(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe74(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe4c(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe04(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126d <julian_day+0x15d>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe09(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdea(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_day>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
cvtsi2sd %edx,%xmm1
cvtsi2sd %ecx,%xmm2
cvtsi2sd %r8d,%xmm3
subsd  %xmm0,%xmm2
cvtsi2sd %r9d,%xmm4
movsd  0xeca(%rip),%xmm0
divsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
divsd  %xmm0,%xmm4
addsd  %xmm2,%xmm4
divsd  0xeba(%rip),%xmm4
addsd  %xmm1,%xmm4
movsd  %xmm4,0x8(%rsp)
lea    0xc(%rsi),%ebp
xor    %eax,%eax
cmp    $0x3,%esi
cmovge %esi,%ebp
setl   %al
sub    %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  0xe99(%rip),%xmm0
mulsd  0xe99(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe84(%rip),%xmm0
call   1030 <floor@plt>
addsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe73(%rip),%xmm0
ucomisd 0xe73(%rip),%xmm0
jbe    121e <julian_day+0x10e>
movslq %ebx,%rax
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe4d(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe43(%rip),%xmm0
call   1030 <floor@plt>
addsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @julian_day(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store double %6, double* %14
%18 = load i32, i32* %10
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %11
%21 = sitofp i32 %20 to double
%22 = load double, double* %14
%23 = fsub double %21, %22
%24 = load i32, i32* %12
%25 = sitofp i32 %24 to double
%26 = load i32, i32* %13
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 6.000000e+01
%29 = fadd double %25, %28
%30 = fdiv double %29, 6.000000e+01
%31 = fadd double %23, %30
%32 = fdiv double %31, 2.400000e+01
%33 = fadd double %19, %32
store double %33, double* %15
%34 = load i32, i32* %9
%35 = icmp slt i32 %34, 3
br i1 %35, label %36, label %41
36: ; preds = %7
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 12
store i32 %38, i32* %9
%39 = load i32, i32* %8
%40 = add nsw i32 %39, -1
store i32 %40, i32* %8
br label %41
41: ; preds = %36, %7
%42 = load i32, i32* %8
%43 = sitofp i32 %42 to double
%44 = fadd double %43, 4.716000e+03
%45 = fmul double 3.652500e+02, %44
%46 = call double @llvm.floor.f64(double %45)
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
%49 = sitofp i32 %48 to double
%50 = fmul double 3.060010e+01, %49
%51 = call double @llvm.floor.f64(double %50)
%52 = fadd double %46, %51
%53 = load double, double* %15
%54 = fadd double %52, %53
%55 = fsub double %54, 1.524500e+03
store double %55, double* %16
%56 = load double, double* %16
%57 = fcmp ogt double %56, 2.299160e+06
br i1 %57, label %58, label %71
58: ; preds = %41
%59 = load i32, i32* %8
%60 = sdiv i32 %59, 100
%61 = sitofp i32 %60 to double
%62 = call double @llvm.floor.f64(double %61)
store double %62, double* %17
%63 = load double, double* %17
%64 = fsub double 2.000000e+00, %63
%65 = load double, double* %17
%66 = fdiv double %65, 4.000000e+00
%67 = call double @llvm.floor.f64(double %66)
%68 = fadd double %64, %67
%69 = load double, double* %16
%70 = fadd double %69, %68
store double %70, double* %16
br label %71
71: ; preds = %58, %41
%72 = load double, double* %16
ret double %72
}

LLVM IR (-O2):
define double @julian_day(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6) {
%8 = sitofp i32 %2 to double
%9 = sitofp i32 %3 to double
%10 = fsub double %9, %6
%11 = sitofp i32 %4 to double
%12 = sitofp i32 %5 to double
%13 = fdiv double %12, 6.000000e+01
%14 = fadd double %13, %11
%15 = fdiv double %14, 6.000000e+01
%16 = fadd double %10, %15
%17 = fdiv double %16, 2.400000e+01
%18 = fadd double %17, %8
%19 = icmp slt i32 %1, 3
%20 = add nsw i32 %1, 12
%21 = select i1 %19, i32 %20, i32 %1
%22 = sext i1 %19 to i32
%23 = add nsw i32 %22, %0
%24 = sitofp i32 %23 to double
%25 = fadd double %24, 4.716000e+03
%26 = fmul double %25, 3.652500e+02
%27 = tail call double @llvm.floor.f64(double %26)
%28 = add nsw i32 %21, 1
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 3.060010e+01
%31 = tail call double @llvm.floor.f64(double %30)
%32 = fadd double %31, %27
%33 = fadd double %32, %18
%34 = fadd double %33, -1.524500e+03
%35 = fcmp ogt double %34, 2.299160e+06
br i1 %35, label %36, label %44
36: ; preds = %7
%37 = sdiv i32 %23, 100
%38 = sitofp i32 %37 to double
%39 = fsub double 2.000000e+00, %38
%40 = fmul double %38, 2.500000e-01
%41 = tail call double @llvm.floor.f64(double %40)
%42 = fadd double %39, %41
%43 = fadd double %42, %34
br label %44
44: ; preds = %36, %7
%45 = phi double [ %43, %36 ], [ %34, %7 ]
ret double %45
}