#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, b, count = 0;
  printf("Enter the year:");
  scanf("%d", &a);
  b = a % 4;
  switch (b) {
  case 0:
    if (a % 4 == 0)
      count += 2;
  case 1:
    if (a % 4 == 1)
      count += 1;
  case 2:
    if (a % 4 == 2)
      count += 2;
  case 3:
    if (a % 4 == 3)
      count += 3;
  }
  switch (count) {
  case 0:
    printf("Monday");
  case 1:
    printf("Tuesday");
  case 2:
    printf("Wednesday");
  case 3:
    printf("Thursday");
  case 4:
    printf("Friday");
  case 5:
    printf("Saturday");
  case 6:
    printf("Sunday");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%edx
add    $0x3,%edx
test   %eax,%eax
mov    %eax,%ecx
cmovs  %edx,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     1216 <main+0xf6>
mov    -0x18(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ab <main+0x8b>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11b0 <main+0x90>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11cd <main+0xad>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d2 <main+0xb2>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    11ef <main+0xcf>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    11f4 <main+0xd4>
mov    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1211 <main+0xf1>
mov    -0x10(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x10(%rbp)
jmp    1216 <main+0xf6>
mov    -0x10(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x6,%rax
ja     128f <main+0x16f>
mov    -0x20(%rbp),%rax
lea    0xdde(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
lea    0xdf4(%rip),%rdi
call   1030 <printf@plt>
lea    0xdf2(%rip),%rdi
call   1030 <printf@plt>
lea    0xdef(%rip),%rdi
call   1030 <printf@plt>
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
lea    0xf08(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
cmp    $0x3,%eax
ja     1195 <main+0x75>
xor    %ecx,%ecx
lea    0xea3(%rip),%rdx
movslq (%rdx,%rax,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
mov    $0x2,%ecx
xor    %edx,%edx
cmp    $0x1,%eax
sete   %dl
or     %ecx,%edx
mov    %edx,%ecx
lea    0x2(%rcx),%edx
cmp    $0x2,%eax
cmovne %ecx,%edx
cmp    $0x6,%edx
ja     11e9 <main+0xc9>
lea    0xe84(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter the year:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"Monday\00"
@.str.3 = [8 x i8] c"Tuesday\00"
@.str.4 = [10 x i8] c"Wednesday\00"
@.str.5 = [9 x i8] c"Thursday\00"
@.str.6 = [7 x i8] c"Friday\00"
@.str.7 = [9 x i8] c"Saturday\00"
@.str.8 = [7 x i8] c"Sunday\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = srem i32 %7, 4
store i32 %8, i32* %3
%9 = load i32, i32* %3
switch i32 %9, label %42 [
i32 0, label %10
i32 1, label %18
i32 2, label %26
i32 3, label %34
]
10: ; preds = %0
%11 = load i32, i32* %2
%12 = srem i32 %11, 4
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 2
store i32 %16, i32* %4
br label %17
17: ; preds = %14, %10
br label %18
18: ; preds = %0, %17
%19 = load i32, i32* %2
%20 = srem i32 %19, 4
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %25
25: ; preds = %22, %18
br label %26
26: ; preds = %0, %25
%27 = load i32, i32* %2
%28 = srem i32 %27, 4
%29 = icmp eq i32 %28, 2
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 2
store i32 %32, i32* %4
br label %33
33: ; preds = %30, %26
br label %34
34: ; preds = %0, %33
%35 = load i32, i32* %2
%36 = srem i32 %35, 4
%37 = icmp eq i32 %36, 3
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 3
store i32 %40, i32* %4
br label %41
41: ; preds = %38, %34
br label %42
42: ; preds = %41, %0
%43 = load i32, i32* %4
switch i32 %43, label %58 [
i32 0, label %44
i32 1, label %46
i32 2, label %48
i32 3, label %50
i32 4, label %52
i32 5, label %54
i32 6, label %56
]
44: ; preds = %42
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %42, %44
%47 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %48
48: ; preds = %42, %46
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %42, %48
%51 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %42, %50
%53 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %54
54: ; preds = %42, %52
%55 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %56
56: ; preds = %42, %54
%57 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %58
58: ; preds = %56, %42
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter the year:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"Monday\00"
@.str.3 = [8 x i8] c"Tuesday\00"
@.str.4 = [10 x i8] c"Wednesday\00"
@.str.5 = [9 x i8] c"Thursday\00"
@.str.6 = [7 x i8] c"Friday\00"
@.str.7 = [9 x i8] c"Saturday\00"
@.str.8 = [7 x i8] c"Sunday\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = srem i32 %5, 4
switch i32 %6, label %18 [
i32 0, label %7
i32 1, label %8
i32 2, label %13
i32 3, label %24
]
7: ; preds = %0
br label %8
8: ; preds = %7, %0
%9 = phi i32 [ 0, %0 ], [ 2, %7 ]
%10 = icmp eq i32 %6, 1
%11 = zext i1 %10 to i32
%12 = or i32 %9, %11
br label %13
13: ; preds = %8, %0
%14 = phi i32 [ 0, %0 ], [ %12, %8 ]
%15 = icmp eq i32 %6, 2
%16 = add nsw i32 %14, 2
%17 = select i1 %15, i32 %16, i32 %14
switch i32 %17, label %32 [
i32 0, label %18
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 4, label %26
i32 5, label %28
i32 6, label %30
]
18: ; preds = %0, %13
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %13, %18
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %13, %20
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %0, %13, %22
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %13, %24
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %13, %26
%29 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %30
30: ; preds = %13, %28
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %32
32: ; preds = %30, %13
ret i32 0
}