#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 calc_dow(unsigned short, unsigned short, unsigned short);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, unsigned short *, unsigned short *,
                         unsigned short *);
int main(int argc, char *argv[]) {
  unsigned short dd;
  unsigned short mm;
  unsigned short yyyy;
  printf("Enter date (DD MM YYYY): ");
  scanf("%hu %hu %hu", &dd, &mm, &yyyy);
  switch (calc_dow(dd, mm, yyyy)) {
  case 0:
    printf("Sunday\n");
    break;
  case 1:
    printf("Monday\n");
    break;
  case 2:
    printf("Tuesday\n");
    break;
  case 3:
    printf("Wednesday\n");
    break;
  case 4:
    printf("Thursday\n");
    break;
  case 5:
    printf("Friday\n");
    break;
  case 6:
    printf("Saturday\n");
    break;
  default:
    printf("Unknown day of the week!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x12(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x16(%rbp),%rcx
call   1050 <scanf@plt>
movzwl -0x12(%rbp),%edi
movzwl -0x14(%rbp),%esi
movzwl -0x16(%rbp),%edx
call   1040 <calc_dow@plt>
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x6,%eax
ja     1215 <main+0xe5>
mov    -0x20(%rbp),%rax
lea    0xe6b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
jmp    1221 <main+0xf1>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0x6(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0x2(%rsp),%rcx
call   1060 <scanf@plt>
movzwl 0x6(%rsp),%edi
movzwl 0x4(%rsp),%esi
movzwl 0x2(%rsp),%edx
call   1050 <calc_dow@plt>
cmp    $0x6,%eax
ja     1193 <main+0x53>
cltq
lea    0xeee(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    119a <main+0x5a>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter date (DD MM YYYY): \00"
@.str.1 = [12 x i8] c"%hu %hu %hu\00"
@.str.2 = [8 x i8] c"Sunday\0A\00"
@.str.3 = [8 x i8] c"Monday\0A\00"
@.str.4 = [9 x i8] c"Tuesday\0A\00"
@.str.5 = [11 x i8] c"Wednesday\0A\00"
@.str.6 = [10 x i8] c"Thursday\0A\00"
@.str.7 = [8 x i8] c"Friday\0A\00"
@.str.8 = [10 x i8] c"Saturday\0A\00"
@.str.9 = [26 x i8] c"Unknown day of the week!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i16* %6, i16* %7, i16* %8)
%11 = load i16, i16* %6
%12 = load i16, i16* %7
%13 = load i16, i16* %8
%14 = call i32 @calc_dow(i16 zeroext %11, i16 zeroext %12, i16 zeroext %13)
switch i32 %14, label %29 [
i32 0, label %15
i32 1, label %17
i32 2, label %19
i32 3, label %21
i32 4, label %23
i32 5, label %25
i32 6, label %27
]
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %31
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %31
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %31
21: ; preds = %2
%22 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
br label %31
23: ; preds = %2
%24 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %31
25: ; preds = %2
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %31
27: ; preds = %2
%28 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
br label %31
29: ; preds = %2
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %25, %23, %21, %19, %17, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter date (DD MM YYYY): \00"
@.str.1 = [12 x i8] c"%hu %hu %hu\00"
@str = [9 x i8] c"Saturday\00"
@str.10 = [7 x i8] c"Friday\00"
@str.11 = [9 x i8] c"Thursday\00"
@str.12 = [10 x i8] c"Wednesday\00"
@str.13 = [8 x i8] c"Tuesday\00"
@str.14 = [7 x i8] c"Monday\00"
@str.15 = [7 x i8] c"Sunday\00"
@str.16 = [25 x i8] c"Unknown day of the week!\00"
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.15 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.14 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @str.13 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.12 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.11 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.10 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = bitcast i16* %3 to i8*
%7 = bitcast i16* %4 to i8*
%8 = bitcast i16* %5 to i8*
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i16* %3, i16* %4, i16* %5)
%11 = load i16, i16* %3
%12 = load i16, i16* %4
%13 = load i16, i16* %5
%14 = call i32 @calc_dow(i16 zeroext %11, i16 zeroext %12, i16 zeroext %13)
%15 = icmp ult i32 %14, 7
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = sext i32 %14 to i64
%18 = shl i64 %17, 2
%19 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %18)
br label %20
20: ; preds = %2, %16
%21 = phi i8* [ %19, %16 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0), %2 ]
%22 = call i32 @puts(i8* dereferenceable(1) %21)
ret i32 0
}