#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 fabs(double);
double floor(double);
double swe_julday(int year, int month, int day, double hour, int gregflag) {
  double jd;
  double u, u0, u1, u2;
  u = year;
  if (month < 3)
    u -= 1;
  u0 = u + 4712.0;
  u1 = month + 1.0;
  if (u1 < 4)
    u1 += 12.0;
  jd = floor(u0 * 365.25) + floor(30.6 * u1 + 0.000001) + day + hour / 24.0 -
       63.5;
  if (gregflag == 1) {
    u2 = floor(fabs(u) / 100) - floor(fabs(u) / 400);
    if (u < 0.0)
      u2 = -u2;
    jd = jd - u2 + 2;
    if ((u < 0.0) && (u / 100 == floor(u / 100)) && (u / 400 != floor(u / 400)))
      jd -= 1;
  }
  return jd;
}


x86 assembly (clang, -O0):
<swe_julday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1163 <swe_julday+0x43>
movsd  -0x30(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea5(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe75(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11b0 <swe_julday+0x90>
movsd  0xe72(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe88(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe1d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe05(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    137a <swe_julday+0x25a>
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    $0x190,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    12a9 <swe_julday+0x189>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  0xd8d(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1375 <swe_julday+0x255>
movsd  -0x30(%rbp),%xmm0
movsd  0xd71(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd5b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    1375 <swe_julday+0x255>
jp     1375 <swe_julday+0x255>
movsd  -0x30(%rbp),%xmm0
movsd  0xd35(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd1f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    135f <swe_julday+0x23f>
jp     135f <swe_julday+0x23f>
jmp    1375 <swe_julday+0x255>
movsd  -0x28(%rbp),%xmm0
movsd  0xc94(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    137a <swe_julday+0x25a>
movsd  -0x28(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swe_julday>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%ebx
mov    %edx,%ebp
cvtsi2sd %edi,%xmm2
cmp    $0x3,%esi
movsd  %xmm0,(%rsp)
jge    1140 <swe_julday+0x20>
addsd  0xec0(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xeba(%rip),%xmm0
cvtsi2sd %esi,%xmm1
addsd  %xmm2,%xmm0
addsd  0xeb2(%rip),%xmm1
movsd  0xeb2(%rip),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm1,%xmm3
cmpltsd 0xea9(%rip),%xmm3
andpd  %xmm3,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,0x20(%rsp)
mulsd  0xe97(%rip),%xmm0
call   1040 <floor@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
mulsd  0xe86(%rip),%xmm0
addsd  0xe86(%rip),%xmm0
call   1040 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
addsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
divsd  0xe6b(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xe67(%rip),%xmm0
cmp    $0x1,%ebx
jne    12fe <swe_julday+0x1de>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x27,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm3
ucomisd %xmm3,%xmm0
movapd 0xe0b(%rip),%xmm1
xorpd  %xmm2,%xmm1
movapd %xmm2,%xmm4
movapd %xmm3,%xmm2
cmpltsd %xmm0,%xmm2
movapd %xmm2,%xmm0
andnpd %xmm4,%xmm0
andpd  %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  (%rsp),%xmm0
subsd  %xmm2,%xmm0
addsd  0xdb9(%rip),%xmm0
jbe    12fe <swe_julday+0x1de>
movsd  %xmm0,(%rsp)
movapd %xmm3,%xmm0
divsd  0xdae(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <floor@plt>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    12f9 <swe_julday+0x1d9>
jp     12f9 <swe_julday+0x1d9>
movsd  0x8(%rsp),%xmm0
divsd  0xd8f(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <floor@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    12ea <swe_julday+0x1ca>
jnp    12f9 <swe_julday+0x1d9>
movsd  (%rsp),%xmm0
addsd  0xd09(%rip),%xmm0
jmp    12fe <swe_julday+0x1de>
movsd  (%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @swe_julday(i32 %0, i32 %1, i32 %2, double %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double %3, double* %9
store i32 %4, i32* %10
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
store double %17, double* %12
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = load double, double* %12
%22 = fsub double %21, 1.000000e+00
store double %22, double* %12
br label %23
23: ; preds = %20, %5
%24 = load double, double* %12
%25 = fadd double %24, 4.712000e+03
store double %25, double* %13
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = fadd double %27, 1.000000e+00
store double %28, double* %14
%29 = load double, double* %14
%30 = fcmp olt double %29, 4.000000e+00
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load double, double* %14
%33 = fadd double %32, 1.200000e+01
store double %33, double* %14
br label %34
34: ; preds = %31, %23
%35 = load double, double* %13
%36 = fmul double %35, 3.652500e+02
%37 = call double @llvm.floor.f64(double %36)
%38 = load double, double* %14
%39 = call double @llvm.fmuladd.f64(double 3.060000e+01, double %38, double 0x3EB0C6F7A0B5ED8D)
%40 = call double @llvm.floor.f64(double %39)
%41 = fadd double %37, %40
%42 = load i32, i32* %8
%43 = sitofp i32 %42 to double
%44 = fadd double %41, %43
%45 = load double, double* %9
%46 = fdiv double %45, 2.400000e+01
%47 = fadd double %44, %46
%48 = fsub double %47, 6.350000e+01
store double %48, double* %11
%49 = load i32, i32* %10
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %93
51: ; preds = %34
%52 = load double, double* %12
%53 = call i32 @fabs(double %52)
%54 = sdiv i32 %53, 100
%55 = sitofp i32 %54 to double
%56 = call double @llvm.floor.f64(double %55)
%57 = load double, double* %12
%58 = call i32 @fabs(double %57)
%59 = sdiv i32 %58, 400
%60 = sitofp i32 %59 to double
%61 = call double @llvm.floor.f64(double %60)
%62 = fsub double %56, %61
store double %62, double* %15
%63 = load double, double* %12
%64 = fcmp olt double %63, 0.000000e+00
br i1 %64, label %65, label %68
65: ; preds = %51
%66 = load double, double* %15
%67 = fneg double %66
store double %67, double* %15
br label %68
68: ; preds = %65, %51
%69 = load double, double* %11
%70 = load double, double* %15
%71 = fsub double %69, %70
%72 = fadd double %71, 2.000000e+00
store double %72, double* %11
%73 = load double, double* %12
%74 = fcmp olt double %73, 0.000000e+00
br i1 %74, label %75, label %92
75: ; preds = %68
%76 = load double, double* %12
%77 = fdiv double %76, 1.000000e+02
%78 = load double, double* %12
%79 = fdiv double %78, 1.000000e+02
%80 = call double @llvm.floor.f64(double %79)
%81 = fcmp oeq double %77, %80
br i1 %81, label %82, label %92
82: ; preds = %75
%83 = load double, double* %12
%84 = fdiv double %83, 4.000000e+02
%85 = load double, double* %12
%86 = fdiv double %85, 4.000000e+02
%87 = call double @llvm.floor.f64(double %86)
%88 = fcmp une double %84, %87
br i1 %88, label %89, label %92
89: ; preds = %82
%90 = load double, double* %11
%91 = fsub double %90, 1.000000e+00
store double %91, double* %11
br label %92
92: ; preds = %89, %82, %75, %68
br label %93
93: ; preds = %92, %34
%94 = load double, double* %11
ret double %94
}

LLVM IR (-O2):
define double @swe_julday(i32 %0, i32 %1, i32 %2, double %3, i32 %4) {
%6 = sitofp i32 %0 to double
%7 = icmp slt i32 %1, 3
%8 = fadd double %6, -1.000000e+00
%9 = select i1 %7, double %8, double %6
%10 = fadd double %9, 4.712000e+03
%11 = sitofp i32 %1 to double
%12 = fadd double %11, 1.000000e+00
%13 = fcmp olt double %12, 4.000000e+00
%14 = fadd double %12, 1.200000e+01
%15 = select i1 %13, double %14, double %12
%16 = fmul double %10, 3.652500e+02
%17 = tail call double @llvm.floor.f64(double %16)
%18 = tail call double @llvm.fmuladd.f64(double %15, double 3.060000e+01, double 0x3EB0C6F7A0B5ED8D)
%19 = tail call double @llvm.floor.f64(double %18)
%20 = fadd double %17, %19
%21 = sitofp i32 %2 to double
%22 = fadd double %20, %21
%23 = fdiv double %3, 2.400000e+01
%24 = fadd double %23, %22
%25 = fadd double %24, -6.350000e+01
%26 = icmp eq i32 %4, 1
br i1 %26, label %27, label %50
27: ; preds = %5
%28 = tail call i32 @fabs(double %9)
%29 = sdiv i32 %28, 100
%30 = sitofp i32 %29 to double
%31 = tail call i32 @fabs(double %9)
%32 = sdiv i32 %31, 400
%33 = sitofp i32 %32 to double
%34 = fsub double %30, %33
%35 = fcmp olt double %9, 0.000000e+00
%36 = fneg double %34
%37 = select i1 %35, double %36, double %34
%38 = fsub double %25, %37
%39 = fadd double %38, 2.000000e+00
br i1 %35, label %40, label %50
40: ; preds = %27
%41 = fdiv double %9, 1.000000e+02
%42 = tail call double @llvm.floor.f64(double %41)
%43 = fcmp oeq double %41, %42
br i1 %43, label %44, label %50
44: ; preds = %40
%45 = fdiv double %9, 4.000000e+02
%46 = tail call double @llvm.floor.f64(double %45)
%47 = fcmp une double %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = fadd double %39, -1.000000e+00
br label %50
50: ; preds = %27, %40, %44, %48, %5
%51 = phi double [ %49, %48 ], [ %39, %44 ], [ %39, %40 ], [ %39, %27 ], [ %25, %5 ]
ret double %51
}