#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__ gregorian_non_leap(int);
long gregorian_cal_to_jul(int y, int m, int d) {
  long c;
  c = (long)((y - 1) / 100);
  return (1461L * (y - 1)) / 4 + c / 4 - c + (m * 489) / 16 -
         ((m > 2) ? (gregorian_non_leap(y) ? 32L : 31L) : 30L) + d + 1721425L;
}


x86 assembly (clang, -O0):
<gregorian_cal_to_jul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cltq
imul   $0x5b5,%rax,%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x4,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
imul   $0x1e9,-0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11c1 <gregorian_cal_to_jul+0xb1>
mov    -0x4(%rbp),%edi
call   1030 <gregorian_non_leap@plt>
mov    %rax,%rdx
mov    $0x1f,%eax
mov    $0x20,%ecx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    11cf <gregorian_cal_to_jul+0xbf>
mov    $0x1e,%eax
mov    %rax,-0x38(%rbp)
jmp    11cf <gregorian_cal_to_jul+0xbf>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0x1a4451,%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gregorian_cal_to_jul>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
lea    -0x1(%rdi),%ebx
mov    $0xffffffffffffffe2,%rcx
cmp    $0x3,%esi
jl     1139 <gregorian_cal_to_jul+0x29>
call   1030 <gregorian_non_leap@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
or     $0xffffffffffffffe0,%rcx
movslq %ebx,%rdx
imul   $0xffffffffae147ae1,%rdx,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x25,%rsi
add    %eax,%esi
imul   $0x5b5,%rdx,%rdi
lea    0x3(%rdi),%rax
test   %rdi,%rdi
cmovns %rdi,%rax
sar    $0x2,%rax
imul   $0x51eb851f,%rdx,%rdx
mov    %rdx,%rdi
shr    $0x3f,%rdi
sar    $0x27,%rdx
add    %edi,%edx
movslq %esi,%rsi
imul   $0x1e9,%ebp,%edi
lea    0xf(%rdi),%ebp
test   %edi,%edi
cmovns %edi,%ebp
sar    $0x4,%ebp
movslq %ebp,%rdi
movslq %r14d,%rbp
movslq %edx,%rdx
add    %rsi,%rdx
add    %rbp,%rdx
add    %rax,%rdx
add    %rdi,%rdx
lea    (%rcx,%rdx,1),%rax
add    $0x1a4451,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @gregorian_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 = sub nsw i32 %8, 1
%10 = sdiv i32 %9, 100
%11 = sext i32 %10 to i64
store i64 %11, i64* %7
%12 = load i32, i32* %4
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = mul nsw i64 1461, %14
%16 = sdiv i64 %15, 4
%17 = load i64, i64* %7
%18 = sdiv i64 %17, 4
%19 = add nsw i64 %16, %18
%20 = load i64, i64* %7
%21 = sub nsw i64 %19, %20
%22 = load i32, i32* %5
%23 = mul nsw i32 %22, 489
%24 = sdiv i32 %23, 16
%25 = sext i32 %24 to i64
%26 = add nsw i64 %21, %25
%27 = load i32, i32* %5
%28 = icmp sgt i32 %27, 2
br i1 %28, label %29, label %35
29: ; preds = %3
%30 = load i32, i32* %4
%31 = call i64 @gregorian_non_leap(i32 %30)
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i64 32, i64 31
br label %36
35: ; preds = %3
br label %36
36: ; preds = %35, %29
%37 = phi i64 [ %34, %29 ], [ 30, %35 ]
%38 = sub nsw i64 %26, %37
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = add nsw i64 %38, %40
%42 = add nsw i64 %41, 1721425
ret i64 %42
}

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