#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 EOF;
int atoi(char *);
int getchar();
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int year;
  char string[5];
  int c, i;
  for (i = 0; i < 5 - 1 && (c = getchar()) != EOF; ++i)
    string[i] = c;
  string[i] = '\0';
  year = atoi(string);
  if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
    printf("%d is a leap year\n", year);
  else
    printf("%d is not a leap year\n", year);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x4,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jge    116e <main+0x3e>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117e <main+0x4e>
jmp    1199 <main+0x69>
mov    -0x14(%rbp),%eax
mov    %al,%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0xd(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1146 <main+0x16>
movslq -0x18(%rbp),%rax
movb   $0x0,-0xd(%rbp,%rax,1)
lea    -0xd(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d6 <main+0xa6>
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ea <main+0xba>
mov    -0x8(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11fe <main+0xce>
mov    -0x8(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
jmp    120d <main+0xdd>
mov    -0x8(%rbp),%esi
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2ea4(%rip),%r14
cmp    (%r14),%eax
je     1191 <main+0x61>
mov    %al,0x3(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x1,%ebx
cmp    (%r14),%eax
je     1191 <main+0x61>
mov    %al,0x4(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x2,%ebx
cmp    (%r14),%eax
je     1191 <main+0x61>
mov    %al,0x5(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x3,%ebx
cmp    (%r14),%eax
je     1191 <main+0x61>
mov    %al,0x6(%rsp)
mov    $0x4,%ebx
movb   $0x0,0x3(%rsp,%rbx,1)
lea    0x3(%rsp),%rdi
call   1050 <atoi@plt>
imul   $0xc28f5c29,%eax,%ecx
add    $0x51eb850,%ecx
mov    %ecx,%edx
ror    $0x2,%edx
ror    $0x4,%ecx
cmp    $0xa3d70b,%ecx
lea    0xe3f(%rip),%rdi
lea    0xe4b(%rip),%rcx
cmovb  %rdi,%rcx
cmp    $0x28f5c29,%edx
cmovb  %rcx,%rdi
test   $0x3,%al
cmovne %rcx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [19 x i8] c"%d is a leap year\0A\00"
@.str.1 = [23 x i8] c"%d is not a leap year\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
br label %6
6: ; preds = %21, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = call i32 (...) @getchar()
store i32 %10, i32* %4
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br label %13
13: ; preds = %9, %6
%14 = phi i1 [ false, %6 ], [ %12, %9 ]
br i1 %14, label %15, label %24
15: ; preds = %13
%16 = load i32, i32* %4
%17 = trunc i32 %16 to i8
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %19
store i8 %17, i8* %20
br label %21
21: ; preds = %15
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %13
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 %26
store i8 0, i8* %27
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = srem i32 %30, 4
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %24
%34 = load i32, i32* %2
%35 = srem i32 %34, 100
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %33, %24
%38 = load i32, i32* %2
%39 = srem i32 %38, 400
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37, %33
%42 = load i32, i32* %2
%43 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %47
44: ; preds = %37
%45 = load i32, i32* %2
%46 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %41
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [19 x i8] c"%d is a leap year\0A\00"
@.str.1 = [23 x i8] c"%d is not a leap year\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %26, label %6
6: ; preds = %0
%7 = trunc i32 %3 to i8
store i8 %7, i8* %2
%8 = tail call i32 (...) @getchar()
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %26, label %11
11: ; preds = %6
%12 = trunc i32 %8 to i8
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
store i8 %12, i8* %13
%14 = tail call i32 (...) @getchar()
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %26, label %17
17: ; preds = %11
%18 = trunc i32 %14 to i8
%19 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
store i8 %18, i8* %19
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = trunc i32 %20 to i8
%25 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
store i8 %24, i8* %25
br label %26
26: ; preds = %23, %17, %11, %6, %0
%27 = phi i64 [ 0, %0 ], [ 1, %6 ], [ 2, %11 ], [ 3, %17 ], [ 4, %23 ]
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i32 @atoi(i8* %2)
%30 = and i32 %29, 3
%31 = icmp eq i32 %30, 0
%32 = srem i32 %29, 100
%33 = icmp ne i32 %32, 0
%34 = and i1 %31, %33
%35 = srem i32 %29, 400
%36 = icmp eq i32 %35, 0
%37 = or i1 %34, %36
%38 = select i1 %37, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0)
%39 = tail call i32 @printf(i8* %38, i32 %29)
ret i32 0
}