#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 ip(double);
double GCalendarToJD(int yy, int mm, double dd) {
  int A, B, m, y;
  double T1, T2, Tr;
  if (mm > 2) {
    y = yy;
    m = mm;
  } else {
    y = yy - 1;
    m = mm + 12;
  }
  A = y / 100;
  B = 2 - A + A / 4;
  T1 = ip(365.25 * (y + 4716));
  T2 = ip(30.6001 * (m + 1));
  Tr = T1 + T2 + dd + B - 1524.5;
  return (Tr);
}


x86 assembly (clang, -O0):
<GCalendarToJD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    113e <GCalendarToJD+0x2e>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <GCalendarToJD+0x40>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    $0x2,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x126c,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe7e(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <ip@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe56(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <ip@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe20(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCalendarToJD>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
lea    0xc(%rsi),%ebx
xor    %eax,%eax
cmp    $0x3,%esi
setl   %al
cmovge %esi,%ebx
sub    %eax,%edi
movslq %edi,%rax
imul   $0xffffffffae147ae1,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x51eb851f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x27,%rdx
add    %esi,%edx
lea    (%rcx,%rdx,1),%ebp
add    $0x2,%ebp
add    $0x126c,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe8f(%rip),%xmm0
call   1030 <ip@plt>
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe7a(%rip),%xmm0
call   1030 <ip@plt>
addsd  0x8(%rsp),%xmm0
cvtsi2sd %ebp,%xmm1
addsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
addsd  0xe61(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @GCalendarToJD(i32 %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 2
%5 = add nsw i32 %1, 12
%6 = xor i1 %4, true
%7 = sext i1 %6 to i32
%8 = add nsw i32 %7, %0
%9 = select i1 %4, i32 %1, i32 %5
%10 = sdiv i32 %8, -100
%11 = add nsw i32 %10, 2
%12 = sdiv i32 %8, 400
%13 = add nsw i32 %11, %12
%14 = add nsw i32 %8, 4716
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 3.652500e+02
%17 = tail call double @ip(double %16)
%18 = add nsw i32 %9, 1
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 3.060010e+01
%21 = tail call double @ip(double %20)
%22 = fadd double %17, %21
%23 = fadd double %22, %2
%24 = sitofp i32 %13 to double
%25 = fadd double %23, %24
%26 = fadd double %25, -1.524500e+03
ret double %26
}