#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, float 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)
movss  %xmm0,-0x1c(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
cvtsi2sdl -0x18(%rbp),%xmm3
movsd  0xeb2(%rip),%xmm4
divsd  %xmm4,%xmm3
addsd  %xmm3,%xmm2
movsd  0xea2(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  0xe8a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119f <julian_day+0x8f>
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  0xe84(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe70(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe48(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe00(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1271 <julian_day+0x161>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe05(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xde6(%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
cvtsi2sd %edx,%xmm1
cvtsi2ss %ecx,%xmm2
mov    %edi,%ebx
subss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %r8d,%xmm0
cvtss2sd %xmm2,%xmm2
cvtsi2sd %r9d,%xmm4
movsd  0xec3(%rip),%xmm3
divsd  %xmm3,%xmm4
addsd  %xmm0,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm2,%xmm4
divsd  0xeb3(%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  0xe92(%rip),%xmm0
mulsd  0xe92(%rip),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe7d(%rip),%xmm0
call   1030 <floor@plt>
addsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe6c(%rip),%xmm0
ucomisd 0xe6c(%rip),%xmm0
jbe    1225 <julian_day+0x115>
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  0xe46(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe3c(%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, float %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca float
%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 float %6, float* %14
%18 = load i32, i32* %10
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %11
%21 = sitofp i32 %20 to float
%22 = load float, float* %14
%23 = fsub float %21, %22
%24 = fpext float %23 to double
%25 = load i32, i32* %12
%26 = sitofp i32 %25 to double
%27 = load i32, i32* %13
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 6.000000e+01
%30 = fadd double %26, %29
%31 = fdiv double %30, 6.000000e+01
%32 = fadd double %24, %31
%33 = fdiv double %32, 2.400000e+01
%34 = fadd double %19, %33
store double %34, double* %15
%35 = load i32, i32* %9
%36 = icmp slt i32 %35, 3
br i1 %36, label %37, label %42
37: ; preds = %7
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 12
store i32 %39, i32* %9
%40 = load i32, i32* %8
%41 = add nsw i32 %40, -1
store i32 %41, i32* %8
br label %42
42: ; preds = %37, %7
%43 = load i32, i32* %8
%44 = sitofp i32 %43 to double
%45 = fadd double %44, 4.716000e+03
%46 = fmul double 3.652500e+02, %45
%47 = call double @llvm.floor.f64(double %46)
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
%50 = sitofp i32 %49 to double
%51 = fmul double 3.060010e+01, %50
%52 = call double @llvm.floor.f64(double %51)
%53 = fadd double %47, %52
%54 = load double, double* %15
%55 = fadd double %53, %54
%56 = fsub double %55, 1.524500e+03
store double %56, double* %16
%57 = load double, double* %16
%58 = fcmp ogt double %57, 2.299160e+06
br i1 %58, label %59, label %72
59: ; preds = %42
%60 = load i32, i32* %8
%61 = sdiv i32 %60, 100
%62 = sitofp i32 %61 to double
%63 = call double @llvm.floor.f64(double %62)
store double %63, double* %17
%64 = load double, double* %17
%65 = fsub double 2.000000e+00, %64
%66 = load double, double* %17
%67 = fdiv double %66, 4.000000e+00
%68 = call double @llvm.floor.f64(double %67)
%69 = fadd double %65, %68
%70 = load double, double* %16
%71 = fadd double %70, %69
store double %71, double* %16
br label %72
72: ; preds = %59, %42
%73 = load double, double* %16
ret double %73
}

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