#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 */
scalar_t__ getDaysInYear(int);
double getJulianYear(int targetYear) {
  double totalDays = 2442412.5;
  int year;
  if (targetYear < 1975)
    for (year = 1975; year > targetYear; year--)
      totalDays -= getDaysInYear(year);
  else
    for (year = 1975; year < targetYear; year++)
      totalDays += getDaysInYear(year);
  return totalDays;
}


x86 assembly (clang, -O0):
<getJulianYear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movsd  0xedd(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x7b7,-0x4(%rbp)
jge    1176 <getJulianYear+0x66>
movl   $0x7b7,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    1171 <getJulianYear+0x61>
mov    -0x14(%rbp),%edi
call   1030 <getDaysInYear@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    113c <getJulianYear+0x2c>
jmp    11b3 <getJulianYear+0xa3>
movl   $0x7b7,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ae <getJulianYear+0x9e>
mov    -0x14(%rbp),%edi
call   1030 <getDaysInYear@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <getJulianYear+0x6d>
jmp    11b3 <getJulianYear+0xa3>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getJulianYear>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
movsd  0xee3(%rip),%xmm0
cmp    $0x7b6,%edi
jg     1160 <getJulianYear+0x50>
mov    $0x7b7,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1030 <getDaysInYear@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0xffffffff,%ebp
cmp    %ebx,%ebp
jg     1130 <getJulianYear+0x20>
jmp    119e <getJulianYear+0x8e>
cmp    $0x7b7,%ebx
je     119e <getJulianYear+0x8e>
mov    $0x7b7,%ebp
nopl   (%rax)
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1030 <getDaysInYear@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1170 <getJulianYear+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @getJulianYear(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
store i32 %0, i32* %2
store double 0x4142A25640000000, double* %3
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1975
br i1 %6, label %7, label %22
7: ; preds = %1
store i32 1975, i32* %4
br label %8
8: ; preds = %18, %7
%9 = load i32, i32* %4
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
%13 = load i32, i32* %4
%14 = call i64 @getDaysInYear(i32 %13)
%15 = sitofp i64 %14 to double
%16 = load double, double* %3
%17 = fsub double %16, %15
store double %17, double* %3
br label %18
18: ; preds = %12
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
br label %37
22: ; preds = %1
store i32 1975, i32* %4
br label %23
23: ; preds = %33, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = load i32, i32* %4
%29 = call i64 @getDaysInYear(i32 %28)
%30 = sitofp i64 %29 to double
%31 = load double, double* %3
%32 = fadd double %31, %30
store double %32, double* %3
br label %33
33: ; preds = %27
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %23
36: ; preds = %23
br label %37
37: ; preds = %36, %21
%38 = load double, double* %3
ret double %38
}

LLVM IR (-O2):
define double @getJulianYear(i32 %0) {
%2 = icmp slt i32 %0, 1975
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = icmp eq i32 %0, 1975
br i1 %4, label %21, label %13
5: ; preds = %1, %5
%6 = phi i32 [ %11, %5 ], [ 1975, %1 ]
%7 = phi double [ %10, %5 ], [ 0x4142A25640000000, %1 ]
%8 = tail call i64 @getDaysInYear(i32 %6)
%9 = sitofp i64 %8 to double
%10 = fsub double %7, %9
%11 = add nsw i32 %6, -1
%12 = icmp sgt i32 %11, %0
br i1 %12, label %5, label %21
13: ; preds = %3, %13
%14 = phi i32 [ %19, %13 ], [ 1975, %3 ]
%15 = phi double [ %18, %13 ], [ 0x4142A25640000000, %3 ]
%16 = tail call i64 @getDaysInYear(i32 %14)
%17 = sitofp i64 %16 to double
%18 = fadd double %15, %17
%19 = add nuw nsw i32 %14, 1
%20 = icmp eq i32 %19, %0
br i1 %20, label %21, label %13
21: ; preds = %13, %5, %3
%22 = phi double [ 0x4142A25640000000, %3 ], [ %10, %5 ], [ %18, %13 ]
ret double %22
}