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


x86 assembly (clang, -O0):
<julian_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
addsd  -0x28(%rbp),%xmm3
movsd  0xeab(%rip),%xmm4
divsd  %xmm4,%xmm3
addsd  %xmm3,%xmm2
movsd  0xe9b(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  0xe83(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a6 <julian_day+0x96>
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  0xe7d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe69(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <integer@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe41(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <integer@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe17(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xdf9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1278 <julian_day+0x168>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1030 <integer@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xdfe(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xddf(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <integer@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<julian_day>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cvtsi2sd %edx,%xmm3
mov    %edi,%ebx
cvtsi2sd %ecx,%xmm4
subsd  %xmm2,%xmm4
xorps  %xmm2,%xmm2
cvtsi2sd %r8d,%xmm2
addsd  %xmm1,%xmm0
movsd  0xec8(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm4,%xmm0
divsd  0xeb8(%rip),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,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  0xe97(%rip),%xmm0
mulsd  0xe97(%rip),%xmm0
call   1030 <integer@plt>
movsd  %xmm0,0x10(%rsp)
add    $0x1,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe82(%rip),%xmm0
call   1030 <integer@plt>
addsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe71(%rip),%xmm0
ucomisd 0xe71(%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
call   1030 <integer@plt>
movsd  0xe46(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe3c(%rip),%xmm0
call   1030 <integer@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, double %5, double %6, double %7) {
%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
%18 = alloca double
%19 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store double %5, double* %14
store double %6, double* %15
store double %7, double* %16
%20 = load i32, i32* %11
%21 = sitofp i32 %20 to double
%22 = load i32, i32* %12
%23 = sitofp i32 %22 to double
%24 = load double, double* %16
%25 = fsub double %23, %24
%26 = load i32, i32* %13
%27 = sitofp i32 %26 to double
%28 = load double, double* %14
%29 = load double, double* %15
%30 = fadd double %28, %29
%31 = fdiv double %30, 6.000000e+01
%32 = fadd double %27, %31
%33 = fdiv double %32, 6.000000e+01
%34 = fadd double %25, %33
%35 = fdiv double %34, 2.400000e+01
%36 = fadd double %21, %35
store double %36, double* %17
%37 = load i32, i32* %10
%38 = icmp slt i32 %37, 3
br i1 %38, label %39, label %44
39: ; preds = %8
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 12
store i32 %41, i32* %10
%42 = load i32, i32* %9
%43 = add nsw i32 %42, -1
store i32 %43, i32* %9
br label %44
44: ; preds = %39, %8
%45 = load i32, i32* %9
%46 = sitofp i32 %45 to double
%47 = fadd double %46, 4.716000e+03
%48 = fmul double 3.652500e+02, %47
%49 = call double @integer(double %48)
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
%52 = sitofp i32 %51 to double
%53 = fmul double 3.060010e+01, %52
%54 = call double @integer(double %53)
%55 = fadd double %49, %54
%56 = load double, double* %17
%57 = fadd double %55, %56
%58 = fsub double %57, 1.524500e+03
store double %58, double* %18
%59 = load double, double* %18
%60 = fcmp ogt double %59, 2.299160e+06
br i1 %60, label %61, label %74
61: ; preds = %44
%62 = load i32, i32* %9
%63 = sdiv i32 %62, 100
%64 = sitofp i32 %63 to double
%65 = call double @integer(double %64)
store double %65, double* %19
%66 = load double, double* %19
%67 = fsub double 2.000000e+00, %66
%68 = load double, double* %19
%69 = fdiv double %68, 4.000000e+00
%70 = call double @integer(double %69)
%71 = fadd double %67, %70
%72 = load double, double* %18
%73 = fadd double %72, %71
store double %73, double* %18
br label %74
74: ; preds = %61, %44
%75 = load double, double* %18
ret double %75
}

LLVM IR (-O2):
define double @julian_day(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double %5, double %6, double %7) {
%9 = sitofp i32 %2 to double
%10 = sitofp i32 %3 to double
%11 = fsub double %10, %7
%12 = sitofp i32 %4 to double
%13 = fadd double %5, %6
%14 = fdiv double %13, 6.000000e+01
%15 = fadd double %14, %12
%16 = fdiv double %15, 6.000000e+01
%17 = fadd double %11, %16
%18 = fdiv double %17, 2.400000e+01
%19 = fadd double %18, %9
%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 @integer(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 @integer(double %31)
%33 = fadd double %28, %32
%34 = fadd double %19, %33
%35 = fadd double %34, -1.524500e+03
%36 = fcmp ogt double %35, 2.299160e+06
br i1 %36, label %37, label %46
37: ; preds = %8
%38 = sdiv i32 %24, 100
%39 = sitofp i32 %38 to double
%40 = tail call double @integer(double %39)
%41 = fsub double 2.000000e+00, %40
%42 = fmul double %40, 2.500000e-01
%43 = tail call double @integer(double %42)
%44 = fadd double %41, %43
%45 = fadd double %35, %44
br label %46
46: ; preds = %37, %8
%47 = phi double [ %45, %37 ], [ %35, %8 ]
ret double %47
}