#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 /*<<< orphan*/ GetLine(char *, int);
scalar_t__ LeapYear(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char line[1000];
  printf("Enter a year to calculate if it's a leap year or not: ");
  GetLine(line, 1000);
  int i;
  int year = 0;
  for (i = 0; line[i] != '\0'; ++i) {
    if (line[i] < '0' || line[i] > '9') {
      printf("An Integer was expected! Exiting..\n");
      break;
    } else {
      year = year * 10 + line[i] - '0';
    }
  }
  printf("Year %d is %sa leap year, exiting..\n", year,
         LeapYear(year) ? "" : "not ");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <GetLine@plt>
movl   $0x0,-0x3f8(%rbp)
movl   $0x0,-0x3f4(%rbp)
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     120a <main+0xda>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x30,%eax
jl     11bd <main+0x8d>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x39,%eax
jle    11d0 <main+0xa0>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    120a <main+0xda>
imul   $0xa,-0x3f8(%rbp),%eax
movslq -0x3f4(%rbp),%rcx
movsbl -0x3f0(%rbp,%rcx,1),%ecx
ff
add    %ecx,%eax
sub    $0x30,%eax
mov    %eax,-0x3f8(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    1175 <main+0x45>
mov    -0x3f8(%rbp),%eax
mov    %eax,-0x3fc(%rbp)
mov    -0x3f8(%rbp),%edi
call   1050 <LeapYear@plt>
mov    -0x3fc(%rbp),%esi
mov    %rax,%rcx
lea    0xe4f(%rip),%rdx
lea    0xe22(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3f0,%rsp
lea    0xeb1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <GetLine@plt>
mov    (%rsp),%cl
test   %cl,%cl
je     11ad <main+0x6d>
lea    0x1(%rsp),%rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x3a(%rcx),%edx
cmp    $0xf5,%dl
jbe    11a1 <main+0x61>
movzbl %cl,%ecx
lea    (%rbx,%rbx,4),%edx
lea    (%rcx,%rdx,2),%ebx
add    $0xffffffd0,%ebx
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1180 <main+0x40>
jmp    11ad <main+0x6d>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <LeapYear@plt>
test   %rax,%rax
lea    0xe9e(%rip),%rax
lea    0xe96(%rip),%rdx
cmove  %rax,%rdx
lea    0xe67(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Enter a year to calculate if it's a leap year or not: \00"
@.str.1 = [36 x i8] c"An Integer was expected! Exiting..\0A\00"
@.str.2 = [37 x i8] c"Year %d is %sa leap year, exiting..\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"not \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%7 = call i32 @GetLine(i8* %6, i32 1000)
store i32 0, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %42, %0
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %45
15: ; preds = %8
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %20, 48
br i1 %21, label %29, label %22
22: ; preds = %15
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp sgt i32 %27, 57
br i1 %28, label %29, label %31
29: ; preds = %22, %15
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %45
31: ; preds = %22
%32 = load i32, i32* %4
%33 = mul nsw i32 %32, 10
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = add nsw i32 %33, %38
%40 = sub nsw i32 %39, 48
store i32 %40, i32* %4
br label %41
41: ; preds = %31
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %8
45: ; preds = %29, %8
%46 = load i32, i32* %4
%47 = load i32, i32* %4
%48 = call i64 @LeapYear(i32 %47)
%49 = icmp ne i64 %48, 0
%50 = zext i1 %49 to i64
%51 = select i1 %49, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %46, i8* %51)
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [55 x i8] c"Enter a year to calculate if it's a leap year or not: \00"
@.str.2 = [37 x i8] c"Year %d is %sa leap year, exiting..\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [5 x i8] c"not \00"
@str = [35 x i8] c"An Integer was expected! Exiting..\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @GetLine(i8* %2, i32 1000)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %0, %15
%8 = phi i64 [ %20, %15 ], [ 0, %0 ]
%9 = phi i8 [ %22, %15 ], [ %5, %0 ]
%10 = phi i32 [ %19, %15 ], [ 0, %0 ]
%11 = add i8 %9, -58
%12 = icmp ult i8 %11, -10
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %24
15: ; preds = %7
%16 = zext i8 %9 to i32
%17 = mul nsw i32 %10, 10
%18 = add i32 %17, -48
%19 = add i32 %18, %16
%20 = add nuw i64 %8, 1
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %7
24: ; preds = %15, %0, %13
%25 = phi i32 [ %10, %13 ], [ 0, %0 ], [ %19, %15 ]
%26 = call i64 @LeapYear(i32 %25)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %25, i8* %28)
ret i32 0
}