#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 */
int floor(double);
double fmod(double, double);
void su_jul_to_cal_date(long jul, int *y, int *m, int *d) {
  if (jul >= 2299161)
    jul += (long)(floor(floor((jul - 4479.5) / 36524.25) * 0.75 + 0.5) - 37.);
  *y = (int)floor(jul / 365.25) - 4712;
  *d = (int)floor((fmod((fmod((jul - 59.25), 365.25) + 365.25), 365.25)));
  *m = (int)(fmod((fmod((floor((*d + 0.5) / 30.6) + 2), 12) + 12), 12)) + 1;
  *d = (int)floor((fmod((fmod((*d + 0.5), 30.6) + 30.6), 30.6))) + 1;
  if (*y <= 0)
    --(*y);
}


x86 assembly (clang, -O0):
<su_jul_to_cal_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x231519,-0x8(%rbp)
jl     11a7 <su_jul_to_cal_date+0x87>
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xecc(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe8f(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <floor@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe6a(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,%ecx
sub    $0x1268,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xe45(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe39(%rip),%xmm1
call   1030 <fmod@plt>
call   1040 <floor@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xdef(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdfb(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
add    $0x2,%eax
cvtsi2sd %eax,%xmm0
movsd  0xdeb(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xdde(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdd2(%rip),%xmm1
call   1030 <fmod@plt>
cvttsd2si %xmm0,%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xd90(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xd9c(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xd8f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xd83(%rip),%xmm1
call   1030 <fmod@plt>
call   1040 <floor@plt>
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jg     12d2 <su_jul_to_cal_date+0x1b2>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<su_jul_to_cal_date>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    $0x231519,%rdi
jl     117c <su_jul_to_cal_date+0x5c>
cvtsi2sd %rbx,%xmm0
addsd  0xeb6(%rip),%xmm0
divsd  0xeb6(%rip),%xmm0
call   1040 <floor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xeaa(%rip),%xmm0
addsd  0xeaa(%rip),%xmm0
call   1040 <floor@plt>
cltq
add    %rax,%rbx
add    $0xffffffffffffffdb,%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,(%rsp)
divsd  0xe8f(%rip),%xmm0
call   1040 <floor@plt>
add    $0xffffed98,%eax
mov    %eax,(%r14)
movsd  (%rsp),%xmm0
addsd  0xe7d(%rip),%xmm0
movsd  0xe6d(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xe60(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <fmod@plt>
call   1040 <floor@plt>
mov    %eax,(%r12)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe37(%rip),%xmm0
divsd  0xe47(%rip),%xmm0
call   1040 <floor@plt>
add    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe38(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xe2b(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <fmod@plt>
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,(%r15)
xorps  %xmm0,%xmm0
cvtsi2sdl (%r12),%xmm0
addsd  0xde7(%rip),%xmm0
movsd  0xdf7(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xdea(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <fmod@plt>
call   1040 <floor@plt>
add    $0x1,%eax
mov    %eax,(%r12)
mov    (%r14),%eax
test   %eax,%eax
jg     1268 <su_jul_to_cal_date+0x148>
add    $0xffffffff,%eax
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @su_jul_to_cal_date(i64 %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i64 %0, i64* %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i64, i64* %5
%10 = icmp sge i64 %9, 2299161
br i1 %10, label %11, label %25
11: ; preds = %4
%12 = load i64, i64* %5
%13 = sitofp i64 %12 to double
%14 = fsub double %13, 4.479500e+03
%15 = fdiv double %14, 0x40E1D58800000000
%16 = call i32 @floor(double %15)
%17 = sitofp i32 %16 to double
%18 = call double @llvm.fmuladd.f64(double %17, double 7.500000e-01, double 5.000000e-01)
%19 = call i32 @floor(double %18)
%20 = sitofp i32 %19 to double
%21 = fsub double %20, 3.700000e+01
%22 = fptosi double %21 to i64
%23 = load i64, i64* %5
%24 = add nsw i64 %23, %22
store i64 %24, i64* %5
br label %25
25: ; preds = %11, %4
%26 = load i64, i64* %5
%27 = sitofp i64 %26 to double
%28 = fdiv double %27, 3.652500e+02
%29 = call i32 @floor(double %28)
%30 = sub nsw i32 %29, 4712
%31 = load i32*, i32** %6
store i32 %30, i32* %31
%32 = load i64, i64* %5
%33 = sitofp i64 %32 to double
%34 = fsub double %33, 5.925000e+01
%35 = call double @fmod(double %34, double 3.652500e+02)
%36 = fadd double %35, 3.652500e+02
%37 = call double @fmod(double %36, double 3.652500e+02)
%38 = call i32 @floor(double %37)
%39 = load i32*, i32** %8
store i32 %38, i32* %39
%40 = load i32*, i32** %8
%41 = load i32, i32* %40
%42 = sitofp i32 %41 to double
%43 = fadd double %42, 5.000000e-01
%44 = fdiv double %43, 3.060000e+01
%45 = call i32 @floor(double %44)
%46 = add nsw i32 %45, 2
%47 = sitofp i32 %46 to double
%48 = call double @fmod(double %47, double 1.200000e+01)
%49 = fadd double %48, 1.200000e+01
%50 = call double @fmod(double %49, double 1.200000e+01)
%51 = fptosi double %50 to i32
%52 = add nsw i32 %51, 1
%53 = load i32*, i32** %7
store i32 %52, i32* %53
%54 = load i32*, i32** %8
%55 = load i32, i32* %54
%56 = sitofp i32 %55 to double
%57 = fadd double %56, 5.000000e-01
%58 = call double @fmod(double %57, double 3.060000e+01)
%59 = fadd double %58, 3.060000e+01
%60 = call double @fmod(double %59, double 3.060000e+01)
%61 = call i32 @floor(double %60)
%62 = add nsw i32 %61, 1
%63 = load i32*, i32** %8
store i32 %62, i32* %63
%64 = load i32*, i32** %6
%65 = load i32, i32* %64
%66 = icmp sle i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %25
%68 = load i32*, i32** %6
%69 = load i32, i32* %68
%70 = add nsw i32 %69, -1
store i32 %70, i32* %68
br label %71
71: ; preds = %67, %25
ret void
}

LLVM IR (-O2):
define void @su_jul_to_cal_date(i64 %0, i32* nocapture %1, i32* nocapture writeonly %2, i32* nocapture %3) {
%5 = icmp sgt i64 %0, 2299160
br i1 %5, label %6, label %17
6: ; preds = %4
%7 = sitofp i64 %0 to double
%8 = fadd double %7, -4.479500e+03
%9 = fdiv double %8, 0x40E1D58800000000
%10 = tail call i32 @floor(double %9)
%11 = sitofp i32 %10 to double
%12 = tail call double @llvm.fmuladd.f64(double %11, double 7.500000e-01, double 5.000000e-01)
%13 = tail call i32 @floor(double %12)
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, -37
%16 = add nsw i64 %15, %0
br label %17
17: ; preds = %6, %4
%18 = phi i64 [ %16, %6 ], [ %0, %4 ]
%19 = sitofp i64 %18 to double
%20 = fdiv double %19, 3.652500e+02
%21 = tail call i32 @floor(double %20)
%22 = add nsw i32 %21, -4712
store i32 %22, i32* %1
%23 = fadd double %19, -5.925000e+01
%24 = tail call double @fmod(double %23, double 3.652500e+02)
%25 = fadd double %24, 3.652500e+02
%26 = tail call double @fmod(double %25, double 3.652500e+02)
%27 = tail call i32 @floor(double %26)
store i32 %27, i32* %3
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 5.000000e-01
%30 = fdiv double %29, 3.060000e+01
%31 = tail call i32 @floor(double %30)
%32 = add nsw i32 %31, 2
%33 = sitofp i32 %32 to double
%34 = tail call double @fmod(double %33, double 1.200000e+01)
%35 = fadd double %34, 1.200000e+01
%36 = tail call double @fmod(double %35, double 1.200000e+01)
%37 = fptosi double %36 to i32
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
%39 = load i32, i32* %3
%40 = sitofp i32 %39 to double
%41 = fadd double %40, 5.000000e-01
%42 = tail call double @fmod(double %41, double 3.060000e+01)
%43 = fadd double %42, 3.060000e+01
%44 = tail call double @fmod(double %43, double 3.060000e+01)
%45 = tail call i32 @floor(double %44)
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
%47 = load i32, i32* %1
%48 = icmp slt i32 %47, 1
br i1 %48, label %49, label %51
49: ; preds = %17
%50 = add nsw i32 %47, -1
store i32 %50, i32* %1
br label %51
51: ; preds = %49, %17
ret void
}