#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 DaysInYear(int);
double TimeFromYear(int);
int floor(double);
int YearFromTime(double t) {
  int y = floor(t / ((((24.0 * 60.0) * 60.0) * 1000.0) * 365.2425)) + 1970;
  double t2 = TimeFromYear(y);
  if (t2 > t)
    --y;
  else if (t2 + (((24.0 * 60.0) * 60.0) * 1000.0) * DaysInYear(y) <= t)
    ++y;
  return y;
}


x86 assembly (clang, -O0):
<YearFromTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
add    $0x7b2,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <TimeFromYear@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1186 <YearFromTime+0x56>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <YearFromTime+0x9d>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <DaysInYear@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe60(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11c8 <YearFromTime+0x98>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <YearFromTime+0x9d>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<YearFromTime>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
divsd  0xebc(%rip),%xmm0
call   1050 <floor@plt>
mov    %eax,%ebx
lea    0x7b2(%rbx),%ebp
mov    %ebp,%edi
call   1040 <TimeFromYear@plt>
ucomisd 0x8(%rsp),%xmm0
jbe    1168 <YearFromTime+0x38>
add    $0x7b1,%ebx
jmp    1195 <YearFromTime+0x65>
mov    %ebp,%edi
movsd  %xmm0,0x10(%rsp)
call   1030 <DaysInYear@plt>
mulsd  0xe8b(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     1197 <YearFromTime+0x67>
add    $0x7b3,%ebx
mov    %ebx,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @YearFromTime(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
store double %0, double* %2
%5 = load double, double* %2
%6 = fdiv double %5, 0x421D63C37F000000
%7 = call i32 @floor(double %6)
%8 = add nsw i32 %7, 1970
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call double @TimeFromYear(i32 %9)
store double %10, double* %4
%11 = load double, double* %4
%12 = load double, double* %2
%13 = fcmp ogt double %11, %12
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = load i32, i32* %3
%16 = add nsw i32 %15, -1
store i32 %16, i32* %3
br label %28
17: ; preds = %1
%18 = load double, double* %4
%19 = load i32, i32* %3
%20 = call double @DaysInYear(i32 %19)
%21 = call double @llvm.fmuladd.f64(double 8.640000e+07, double %20, double %18)
%22 = load double, double* %2
%23 = fcmp ole double %21, %22
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %17
br label %28
28: ; preds = %27, %14
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @YearFromTime(double %0) {
%2 = fdiv double %0, 0x421D63C37F000000
%3 = tail call i32 @floor(double %2)
%4 = add nsw i32 %3, 1970
%5 = tail call double @TimeFromYear(i32 %4)
%6 = fcmp ogt double %5, %0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = add nsw i32 %3, 1969
br label %15
9: ; preds = %1
%10 = tail call double @DaysInYear(i32 %4)
%11 = tail call double @llvm.fmuladd.f64(double %10, double 8.640000e+07, double %5)
%12 = fcmp ugt double %11, %0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = add nsw i32 %3, 1971
br label %15
15: ; preds = %9, %13, %7
%16 = phi i32 [ %8, %7 ], [ %14, %13 ], [ %4, %9 ]
ret i32 %16
}