#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 isLeap(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ whichDay(int);
int main() {
  int year, count;
  count = 1;
  puts("Welcome to Which_Day. This is a c program to print the day of the week "
       "of 1st January of the an entered year.");
  for (int j = 1; j < 10; j++) {
    puts("Enter the Year in YY format:");
    scanf("%d", &year);
    if (year <= 0) {
      puts("Year cannot be negative or zero.Input again in YY Format");
      j--;
      continue;
    }
    for (int i = 1; i <= year; i++) {
      if (count > 7)
        count -= 7;
      if (isLeap(i) == 1)
        count += 2;
      else
        count += 1;
    }
    printf("Wait.. we are processing the input \n ");
    whichDay(count > 0 ? count - 7 : count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1264 <main+0x114>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xef5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     11c3 <main+0x73>
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1256 <main+0x106>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1224 <main+0xd4>
cmpl   $0x7,-0xc(%rbp)
jle    11e9 <main+0x99>
mov    -0xc(%rbp),%eax
sub    $0x7,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <isLeap@plt>
cmp    $0x1,%eax
jne    1208 <main+0xb8>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1211 <main+0xc1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1216 <main+0xc6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ca <main+0x7a>
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1248 <main+0xf8>
mov    -0xc(%rbp),%eax
sub    $0x7,%eax
mov    %eax,-0x18(%rbp)
jmp    124e <main+0xfe>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <whichDay@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <main+0x29>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r12d
lea    0xf17(%rip),%r15
lea    0x4(%rsp),%rbx
mov    $0x1,%r13d
jmp    11ae <main+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
add    $0xffffffff,%r12d
lea    0x1(%r12),%eax
cmp    $0x9,%r12d
mov    %eax,%r12d
jge    121a <main+0xca>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1190 <main+0x40>
xor    %ebp,%ebp
xchg   %ax,%ax
add    $0x1,%ebp
lea    -0x7(%r13),%r14d
cmp    $0x8,%r13d
cmovl  %r13d,%r14d
mov    %ebp,%edi
call   1060 <isLeap@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
lea    (%rcx,%r14,1),%r13d
add    $0x1,%r13d
cmp    0x4(%rsp),%ebp
jl     11d0 <main+0x80>
lea    0xec4(%rip),%rdi
call   1050 <printf@plt>
lea    -0x7(%r13),%edi
test   %r13d,%r13d
cmovle %r13d,%edi
call   1040 <whichDay@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [110 x i8] c"Welcome to Which_Day. This is a c program to print the day of the week of 1st January of the an entered year.\00"
@.str.1 = [29 x i8] c"Enter the Year in YY format:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [57 x i8] c"Year cannot be negative or zero.Input again in YY Format\00"
@.str.4 = [38 x i8] c"Wait.. we are processing the input \0A \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
%6 = call i32 @puts(i8* getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %7
7: ; preds = %56, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %59
10: ; preds = %7
%11 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
br label %56
19: ; preds = %10
store i32 1, i32* %5
br label %20
20: ; preds = %41, %19
%21 = load i32, i32* %5
%22 = load i32, i32* %2
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %44
24: ; preds = %20
%25 = load i32, i32* %3
%26 = icmp sgt i32 %25, 7
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 7
store i32 %29, i32* %3
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %5
%32 = call i32 @isLeap(i32 %31)
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 2
store i32 %36, i32* %3
br label %40
37: ; preds = %30
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %20
44: ; preds = %20
%45 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %3
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i32, i32* %3
%50 = sub nsw i32 %49, 7
br label %53
51: ; preds = %44
%52 = load i32, i32* %3
br label %53
53: ; preds = %51, %48
%54 = phi i32 [ %50, %48 ], [ %52, %51 ]
%55 = call i32 @whichDay(i32 %54)
br label %56
56: ; preds = %53, %15
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %7
59: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [110 x i8] c"Welcome to Which_Day. This is a c program to print the day of the week of 1st January of the an entered year.\00"
@.str.1 = [29 x i8] c"Enter the Year in YY format:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [57 x i8] c"Year cannot be negative or zero.Input again in YY Format\00"
@.str.4 = [38 x i8] c"Wait.. we are processing the input \0A \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @.str, i64 0, i64 0))
br label %5
4: ; preds = %34
ret i32 0
5: ; preds = %0, %34
%6 = phi i32 [ 1, %0 ], [ %37, %34 ]
%7 = phi i32 [ 1, %0 ], [ %35, %34 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %21
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
%14 = add nsw i32 %6, -1
br label %34
15: ; preds = %21
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp sgt i32 %30, 0
%18 = add nsw i32 %30, -7
%19 = select i1 %17, i32 %18, i32 %30
%20 = call i32 @whichDay(i32 %19)
br label %34
21: ; preds = %5, %21
%22 = phi i32 [ %31, %21 ], [ 1, %5 ]
%23 = phi i32 [ %30, %21 ], [ %7, %5 ]
%24 = icmp sgt i32 %23, 7
%25 = add nsw i32 %23, -7
%26 = select i1 %24, i32 %25, i32 %23
%27 = call i32 @isLeap(i32 %22)
%28 = icmp eq i32 %27, 1
%29 = select i1 %28, i32 2, i32 1
%30 = add nsw i32 %29, %26
%31 = add nuw nsw i32 %22, 1
%32 = load i32, i32* %1
%33 = icmp slt i32 %22, %32
br i1 %33, label %21, label %15
34: ; preds = %15, %12
%35 = phi i32 [ %7, %12 ], [ %30, %15 ]
%36 = phi i32 [ %14, %12 ], [ %6, %15 ]
%37 = add nsw i32 %36, 1
%38 = icmp slt i32 %36, 9
br i1 %38, label %5, label %4
}