#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 */
int INT_MAX;
int is_leap(int y) {
  if (y > INT_MAX - 1900)
    y -= 2000;
  y += 1900;
  return !(y % 4) && ((y % 100) || !(y % 400));
}


x86 assembly (clang, -O0):
<is_leap>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ed7(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x76c,%ecx
cmp    %ecx,%eax
jle    112c <is_leap+0x2c>
mov    -0x4(%rbp),%eax
sub    $0x7d0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    $0x0,%edx
mov    %al,-0x5(%rbp)
jne    1185 <is_leap+0x85>
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x6(%rbp)
jne    117f <is_leap+0x7f>
mov    -0x4(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
setne  %al
xor    $0xff,%al
mov    %al,-0x6(%rbp)
mov    -0x6(%rbp),%al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_leap>:
mov    0x2ee1(%rip),%rax
mov    $0xfffff894,%edx
add    (%rax),%edx
lea    -0x7d0(%rdi),%ecx
cmp    %edi,%edx
cmovge %edi,%ecx
xor    %eax,%eax
test   $0x3,%cl
je     1121 <is_leap+0x21>
ret
add    $0x76c,%ecx
imul   $0xc28f5c29,%ecx,%ecx
add    $0x51eb850,%ecx
mov    %ecx,%edx
ror    $0x2,%edx
mov    $0x1,%eax
cmp    $0x28f5c28,%edx
ja     1120 <is_leap+0x20>
ror    $0x4,%ecx
xor    %eax,%eax
cmp    $0xa3d70b,%ecx
setb   %al
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @is_leap(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @INT_MAX
%5 = sub nsw i32 %4, 1900
%6 = icmp sgt i32 %3, %5
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 2000
store i32 %9, i32* %2
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1900
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = srem i32 %13, 4
%15 = icmp ne i32 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %10
%17 = load i32, i32* %2
%18 = srem i32 %17, 100
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i32, i32* %2
%22 = srem i32 %21, 400
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br label %25
25: ; preds = %20, %16
%26 = phi i1 [ true, %16 ], [ %24, %20 ]
br label %27
27: ; preds = %25, %10
%28 = phi i1 [ false, %10 ], [ %26, %25 ]
%29 = zext i1 %28 to i32
ret i32 %29
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @is_leap(i32 %0) {
%2 = load i32, i32* @INT_MAX
%3 = add nsw i32 %2, -1900
%4 = icmp slt i32 %3, %0
%5 = add nsw i32 %0, -2000
%6 = select i1 %4, i32 %5, i32 %0
%7 = add nsw i32 %6, 1900
%8 = and i32 %6, 3
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %1
%11 = srem i32 %7, 100
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = srem i32 %7, 400
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %10, %13, %1
%18 = phi i32 [ 0, %1 ], [ 1, %10 ], [ %16, %13 ]
ret i32 %18
}