#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 */
long gregorian_cal_to_jul(int, int, int);
long neg_julian_cal_to_jul(int, int, int);
long pos_julian_cal_to_jul(int, int, int);
long cal_to_jul(int y, int m, int d) {
  long n;
  n = gregorian_cal_to_jul(y, m, d);
  if (n < 2299161L) {
    n = (y < 0) ? neg_julian_cal_to_jul(y, m, d)
                : pos_julian_cal_to_jul(y, m, d);
  }
  return n;
}


x86 assembly (clang, -O0):
<cal_to_jul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <gregorian_cal_to_jul@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x231519,-0x18(%rbp)
jge    119c <cal_to_jul+0x6c>
cmpl   $0x0,-0x4(%rbp)
jge    1182 <cal_to_jul+0x52>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <neg_julian_cal_to_jul@plt>
mov    %rax,-0x20(%rbp)
jmp    1194 <cal_to_jul+0x64>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <pos_julian_cal_to_jul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_to_jul>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <gregorian_cal_to_jul@plt>
cmp    $0x231518,%rax
jg     115c <cal_to_jul+0x2c>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
test   %ebx,%ebx
js     1161 <cal_to_jul+0x31>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <pos_julian_cal_to_jul@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <neg_julian_cal_to_jul@plt>

LLVM IR (-O0):
define i64 @cal_to_jul(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = call i64 @gregorian_cal_to_jul(i32 %8, i32 %9, i32 %10)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp slt i64 %12, 2299161
br i1 %13, label %14, label %29
14: ; preds = %3
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i64 @neg_julian_cal_to_jul(i32 %18, i32 %19, i32 %20)
br label %27
22: ; preds = %14
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i64 @pos_julian_cal_to_jul(i32 %23, i32 %24, i32 %25)
br label %27
27: ; preds = %22, %17
%28 = phi i64 [ %21, %17 ], [ %26, %22 ]
store i64 %28, i64* %7
br label %29
29: ; preds = %27, %3
%30 = load i64, i64* %7
ret i64 %30
}

LLVM IR (-O2):
define i64 @cal_to_jul(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @gregorian_cal_to_jul(i32 %0, i32 %1, i32 %2)
%5 = icmp slt i64 %4, 2299161
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = icmp slt i32 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i64 @neg_julian_cal_to_jul(i32 %0, i32 %1, i32 %2)
br label %12
10: ; preds = %6
%11 = tail call i64 @pos_julian_cal_to_jul(i32 %0, i32 %1, i32 %2)
br label %12
12: ; preds = %8, %10, %3
%13 = phi i64 [ %4, %3 ], [ %9, %8 ], [ %11, %10 ]
ret i64 %13
}