#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 */
struct tm {
  int tm_mon;
  int tm_year;
  double tm_mday;
};

/* Variables and functions */
double floor(double);
double sunmodel_get_jd(struct tm *gmt) {
  int month, year;
  double a, b, jd;
  month = gmt->tm_mon + 1;
  year = gmt->tm_year + 1900;
  if (month <= 2) {
    year -= 1;
    month += 12;
  }
  a = floor(year * 0.01);
  b = 2.0 - a + floor(a * 0.25);
  jd = floor(365.25 * (year + 4716.0)) + floor(30.6001 * (month + 1.0)) +
       gmt->tm_mday + b - 1524.5;
  return jd;
}


x86 assembly (clang, -O0):
<sunmodel_get_jd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
add    $0x76c,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0xc(%rbp)
jg     1153 <sunmodel_get_jd+0x43>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xed8(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xeba(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea0(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe70(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe5c(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe39(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe25(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdf2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sunmodel_get_jd>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rax
movq   %rax,%xmm0
xor    %ecx,%ecx
cmp    $0x2,%eax
setl   %cl
movd   %ecx,%xmm1
pshufd $0x50,%xmm1,%xmm1
pslld  $0x1f,%xmm1
psrad  $0x1f,%xmm1
movdqa %xmm1,%xmm2
pandn  0xeb9(%rip),%xmm2
pand   0xec1(%rip),%xmm1
por    %xmm2,%xmm1
paddd  %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
unpckhpd %xmm0,%xmm0
mulsd  0xed3(%rip),%xmm0
call   1030 <floor@plt>
movsd  0xece(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  0xec4(%rip),%xmm0
call   1030 <floor@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
addpd  0xe75(%rip),%xmm0
mulpd  0xe7d(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <floor@plt>
movsd  %xmm0,0x28(%rsp)
movapd 0x10(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
call   1030 <floor@plt>
addsd  0x28(%rsp),%xmm0
addsd  0x8(%rbx),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xe6c(%rip),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, double }
define double @sunmodel_get_jd(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store %struct.tm* %0, %struct.tm** %2
%8 = load %struct.tm*, %struct.tm** %2
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
%12 = load %struct.tm*, %struct.tm** %2
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1900
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %1
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
store i32 %20, i32* %4
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 12
store i32 %22, i32* %3
br label %23
23: ; preds = %18, %1
%24 = load i32, i32* %4
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 1.000000e-02
%27 = call double @llvm.floor.f64(double %26)
store double %27, double* %5
%28 = load double, double* %5
%29 = fsub double 2.000000e+00, %28
%30 = load double, double* %5
%31 = fmul double %30, 2.500000e-01
%32 = call double @llvm.floor.f64(double %31)
%33 = fadd double %29, %32
store double %33, double* %6
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to double
%36 = fadd double %35, 4.716000e+03
%37 = fmul double 3.652500e+02, %36
%38 = call double @llvm.floor.f64(double %37)
%39 = load i32, i32* %3
%40 = sitofp i32 %39 to double
%41 = fadd double %40, 1.000000e+00
%42 = fmul double 3.060010e+01, %41
%43 = call double @llvm.floor.f64(double %42)
%44 = fadd double %38, %43
%45 = load %struct.tm*, %struct.tm** %2
%46 = getelementptr inbounds %struct.tm, %struct.tm* %45, i32 0, i32 2
%47 = load double, double* %46
%48 = fadd double %44, %47
%49 = load double, double* %6
%50 = fadd double %48, %49
%51 = fsub double %50, 1.524500e+03
store double %51, double* %7
%52 = load double, double* %7
ret double %52
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, double }
define double @sunmodel_get_jd(%struct.tm* nocapture %0) {
%2 = bitcast %struct.tm* %0 to <2 x i32>*
%3 = load <2 x i32>, <2 x i32>* %2
%4 = extractelement <2 x i32> %3, i64 0
%5 = icmp slt i32 %4, 2
%6 = insertelement <2 x i1> poison, i1 %5, i64 0
%7 = shufflevector <2 x i1> %6, <2 x i1> poison, <2 x i32> zeroinitializer
%8 = select <2 x i1> %7, <2 x i32> <i32 13, i32 1899>, <2 x i32> <i32 1, i32 1900>
%9 = add nsw <2 x i32> %8, %3
%10 = sitofp <2 x i32> %9 to <2 x double>
%11 = extractelement <2 x double> %10, i64 1
%12 = fmul double %11, 1.000000e-02
%13 = tail call double @llvm.floor.f64(double %12)
%14 = fsub double 2.000000e+00, %13
%15 = fmul double %13, 2.500000e-01
%16 = tail call double @llvm.floor.f64(double %15)
%17 = fadd double %14, %16
%18 = fadd <2 x double> %10, <double 1.000000e+00, double 4.716000e+03>
%19 = fmul <2 x double> %18, <double 3.060010e+01, double 3.652500e+02>
%20 = call <2 x double> @llvm.floor.v2f64(<2 x double> %19)
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%22 = fadd <2 x double> %21, %20
%23 = extractelement <2 x double> %22, i64 0
%24 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%25 = load double, double* %24
%26 = fadd double %25, %23
%27 = fadd double %26, %17
%28 = fadd double %27, -1.524500e+03
ret double %28
}