#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 */
scalar_t__ neg_julian_non_leap(int);
long neg_julian_cal_to_jul(int y, int m, int d) {
  return (1461L * (y + 1L)) / 4L + (m * 489) / 16 -
         ((m > 2) ? (neg_julian_non_leap(y) ? 32L : 31L) : 30L) + d + 1721057L;
}


x86 assembly (clang, -O0):
<neg_julian_cal_to_jul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movslq -0x4(%rbp),%rax
add    $0x1,%rax
imul   $0x5b5,%rax,%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
imul   $0x1e9,-0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    118d <neg_julian_cal_to_jul+0x7d>
mov    -0x4(%rbp),%edi
call   1030 <neg_julian_non_leap@plt>
mov    %rax,%rdx
mov    $0x1f,%eax
mov    $0x20,%ecx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    119b <neg_julian_cal_to_jul+0x8b>
mov    $0x1e,%eax
mov    %rax,-0x28(%rbp)
jmp    119b <neg_julian_cal_to_jul+0x8b>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x1a42e1,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<neg_julian_cal_to_jul>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0xffffffffffffffe2,%rcx
cmp    $0x3,%esi
jl     113a <neg_julian_cal_to_jul+0x2a>
mov    %ebx,%edi
call   1030 <neg_julian_non_leap@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
or     $0xffffffffffffffe0,%rcx
movslq %ebx,%rax
imul   $0x5b5,%rax,%rax
lea    0x5b5(%rax),%rdx
add    $0x5b8,%rax
test   %rdx,%rdx
cmovns %rdx,%rax
sar    $0x2,%rax
imul   $0x1e9,%ebp,%edx
lea    0xf(%rdx),%esi
test   %edx,%edx
cmovns %edx,%esi
sar    $0x4,%esi
movslq %esi,%rdx
movslq %r14d,%rsi
add    %rdx,%rsi
add    %rax,%rsi
lea    (%rcx,%rsi,1),%rax
add    $0x1a42e1,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @neg_julian_cal_to_jul(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = add nsw i64 %8, 1
%10 = mul nsw i64 1461, %9
%11 = sdiv i64 %10, 4
%12 = load i32, i32* %5
%13 = mul nsw i32 %12, 489
%14 = sdiv i32 %13, 16
%15 = sext i32 %14 to i64
%16 = add nsw i64 %11, %15
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %25
19: ; preds = %3
%20 = load i32, i32* %4
%21 = call i64 @neg_julian_non_leap(i32 %20)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i64 32, i64 31
br label %26
25: ; preds = %3
br label %26
26: ; preds = %25, %19
%27 = phi i64 [ %24, %19 ], [ 30, %25 ]
%28 = sub nsw i64 %16, %27
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = add nsw i64 %28, %30
%32 = add nsw i64 %31, 1721057
ret i64 %32
}

LLVM IR (-O2):
define i64 @neg_julian_cal_to_jul(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 2
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = tail call i64 @neg_julian_non_leap(i32 %0)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i64 -31, i64 -32
br label %9
9: ; preds = %3, %5
%10 = phi i64 [ %8, %5 ], [ -30, %3 ]
%11 = sext i32 %0 to i64
%12 = mul nsw i64 %11, 1461
%13 = add nsw i64 %12, 1461
%14 = sdiv i64 %13, 4
%15 = mul nsw i32 %1, 489
%16 = sdiv i32 %15, 16
%17 = sext i32 %16 to i64
%18 = sext i32 %2 to i64
%19 = add nsw i64 %18, 1721057
%20 = add nsw i64 %19, %17
%21 = add nsw i64 %20, %14
%22 = add nsw i64 %21, %10
ret i64 %22
}