#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 *);
void calc_day(int n) {
  int result;
  result = (n - 621049) % 7;
  switch (result) {
  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("Something went wrong\n");
    break;
  }
}


x86 assembly (clang, -O0):
<calc_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    %edx,%ecx
add    $0xfff68607,%ecx
mov    %edx,%eax
movslq %ecx,%rcx
imul   $0xffffffff92492493,%rcx,%rcx
shr    $0x20,%rcx
mov    %ecx,%edx
mov    %edx,%ecx
lea    -0x979f9(%rcx,%rax,1),%edx
mov    %edx,%ecx
shr    $0x1f,%ecx
sar    $0x2,%edx
add    %ecx,%edx
mov    %edx,%ecx
shl    $0x3,%ecx
sub    %ecx,%edx
mov    %edx,%ecx
lea    -0x979f9(%rax,%rcx,1),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x6,%rax
ja     11fa <calc_day+0xea>
mov    -0x10(%rbp),%rax
lea    0xe86(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <calc_day+0xf6>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_day>:
mov    %edi,%eax
add    $0xfff68607,%eax
cltq
imul   $0xffffffff92492493,%rax,%rax
shr    $0x20,%rax
add    %edi,%eax
add    $0xfff68607,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x2,%eax
add    %ecx,%eax
lea    0x0(,%rax,8),%ecx
sub    %ecx,%eax
add    %edi,%eax
add    $0xfff68607,%eax
cmp    $0x6,%eax
ja     115f <calc_day+0x4f>
cltq
lea    0xefd(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <puts@plt>
lea    0xed3(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Sunday\0A\00"
@.str.1 = [8 x i8] c"Monday\0A\00"
@.str.2 = [9 x i8] c"Tuesday\0A\00"
@.str.3 = [11 x i8] c"Wednesday\0A\00"
@.str.4 = [10 x i8] c"Thursday\0A\00"
@.str.5 = [8 x i8] c"Friday\0A\00"
@.str.6 = [10 x i8] c"Saturday\0A\00"
@.str.7 = [22 x i8] c"Something went wrong\0A\00"
define void @calc_day(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = sub nsw i32 %4, 621049
%6 = srem i32 %5, 7
store i32 %6, i32* %3
%7 = load i32, i32* %3
switch i32 %7, label %22 [
i32 0, label %8
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
i32 5, label %18
i32 6, label %20
]
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %24
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %24
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %24
14: ; preds = %1
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %24
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %24
18: ; preds = %1
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %24
20: ; preds = %1
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %24
22: ; preds = %1
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %24
24: ; preds = %22, %20, %18, %16, %14, %12, %10, %8
ret void
}

LLVM IR (-O2):
@str = [9 x i8] c"Saturday\00"
@str.8 = [7 x i8] c"Friday\00"
@str.9 = [9 x i8] c"Thursday\00"
@str.10 = [10 x i8] c"Wednesday\00"
@str.11 = [8 x i8] c"Tuesday\00"
@str.12 = [7 x i8] c"Monday\00"
@str.13 = [7 x i8] c"Sunday\00"
@str.14 = [21 x i8] c"Something went wrong\00"
@reltable.calc_day = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.13 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.12 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @str.11 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.10 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.9 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @str.8 to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str to i64), i64 ptrtoint ([7 x i32]* @reltable.calc_day to i64)) to i32)]
define void @calc_day(i32 %0) {
%2 = add nsw i32 %0, -621049
%3 = srem i32 %2, 7
%4 = icmp ult i32 %3, 7
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.calc_day to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0), %1 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}