#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 math_div(long, int);
long leaps_between(long y1, long y2) {
  long leaps1 =
      math_div(y1 - 1, 4) - math_div(y1 - 1, 100) + math_div(y1 - 1, 400);
  long leaps2 =
      math_div(y2 - 1, 4) - math_div(y2 - 1, 100) + math_div(y2 - 1, 400);
  return leaps2 - leaps1;
}


x86 assembly (clang, -O0):
<leaps_between>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x4,%esi
call   1030 <math_div@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x64,%esi
call   1030 <math_div@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x190,%esi
call   1030 <math_div@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x4,%esi
call   1030 <math_div@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x64,%esi
call   1030 <math_div@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
sub    $0x1,%rdi
mov    $0x190,%esi
call   1030 <math_div@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<leaps_between>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <math_div@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <math_div@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    $0x190,%esi
call   1030 <math_div@plt>
mov    %rax,%r13
add    $0xffffffffffffffff,%r12
mov    %r12,%rdi
mov    $0x4,%esi
call   1030 <math_div@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x64,%esi
call   1030 <math_div@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    $0x190,%esi
call   1030 <math_div@plt>
add    %r14,%r13
add    %r15,%rbx
add    %rbp,%r13
sub    %r13,%rbx
add    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @leaps_between(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%7 = load i64, i64* %3
%8 = sub nsw i64 %7, 1
%9 = call i64 @math_div(i64 %8, i32 4)
%10 = load i64, i64* %3
%11 = sub nsw i64 %10, 1
%12 = call i64 @math_div(i64 %11, i32 100)
%13 = sub nsw i64 %9, %12
%14 = load i64, i64* %3
%15 = sub nsw i64 %14, 1
%16 = call i64 @math_div(i64 %15, i32 400)
%17 = add nsw i64 %13, %16
store i64 %17, i64* %5
%18 = load i64, i64* %4
%19 = sub nsw i64 %18, 1
%20 = call i64 @math_div(i64 %19, i32 4)
%21 = load i64, i64* %4
%22 = sub nsw i64 %21, 1
%23 = call i64 @math_div(i64 %22, i32 100)
%24 = sub nsw i64 %20, %23
%25 = load i64, i64* %4
%26 = sub nsw i64 %25, 1
%27 = call i64 @math_div(i64 %26, i32 400)
%28 = add nsw i64 %24, %27
store i64 %28, i64* %6
%29 = load i64, i64* %6
%30 = load i64, i64* %5
%31 = sub nsw i64 %29, %30
ret i64 %31
}

LLVM IR (-O2):
define i64 @leaps_between(i64 %0, i64 %1) {
%3 = add nsw i64 %0, -1
%4 = tail call i64 @math_div(i64 %3, i32 4)
%5 = tail call i64 @math_div(i64 %3, i32 100)
%6 = tail call i64 @math_div(i64 %3, i32 400)
%7 = add nsw i64 %1, -1
%8 = tail call i64 @math_div(i64 %7, i32 4)
%9 = tail call i64 @math_div(i64 %7, i32 100)
%10 = tail call i64 @math_div(i64 %7, i32 400)
%11 = add i64 %4, %6
%12 = add i64 %5, %8
%13 = add i64 %11, %9
%14 = sub i64 %12, %13
%15 = add i64 %14, %10
ret i64 %15
}