#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 *, char *);
int /*<<< orphan*/ scanf(char *, char *, int *);
scalar_t__ strcmp(char *, char *);
int main(void) {
  int n, i;
  char *week[7] = {"Sunday",   "Monday", "Tuesday", "Wednesday",
                   "Thursday", "Friday", "Saturday"};
  char buf[10];
  scanf("%s\n%d", buf, &n);
  for (i = 0; i < 7; i++)
    if (strcmp(buf, week[i]) == 0)
      break;
  printf("%s", week[(i + (n % 7)) % 7]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c86(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
lea    -0x5a(%rbp),%rsi
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rdx
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x7,-0xc(%rbp)
jge    11bd <main+0x7d>
lea    -0x5a(%rbp),%rdi
movslq -0xc(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11aa <main+0x6a>
jmp    11bd <main+0x7d>
jmp    11af <main+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117f <main+0x3f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%eax
add    %edx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xefd(%rip),%rdi
lea    0x2(%rsp),%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f3 <main+0xc3>
lea    0xe9a(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f7 <main+0xc7>
lea    0xe8b(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fe <main+0xce>
lea    0xe7d(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1205 <main+0xd5>
lea    0xe71(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120c <main+0xdc>
lea    0xe64(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1213 <main+0xe3>
lea    0xe55(%rip),%rsi
lea    0x2(%rsp),%rdi
call   1040 <strcmp@plt>
cmp    $0x1,%rax
mov    $0x7,%ecx
sbb    $0x0,%ecx
jmp    1218 <main+0xe8>
xor    %ecx,%ecx
jmp    1218 <main+0xe8>
mov    $0x1,%ecx
jmp    1218 <main+0xe8>
mov    $0x2,%ecx
jmp    1218 <main+0xe8>
mov    $0x3,%ecx
jmp    1218 <main+0xe8>
mov    $0x4,%ecx
jmp    1218 <main+0xe8>
mov    $0x5,%ecx
movslq 0xc(%rsp),%rdx
imul   $0xffffffff92492493,%rdx,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x2,%eax
add    %esi,%eax
lea    0x0(,%rax,8),%esi
sub    %esi,%eax
add    %edx,%eax
add    %ecx,%eax
movsbl %al,%ecx
imul   $0xffffff93,%ecx,%ecx
shr    $0x8,%ecx
add    %al,%cl
mov    %ecx,%edx
shr    $0x7,%dl
sar    $0x2,%cl
add    %dl,%cl
movzbl %cl,%ecx
lea    0x0(,%rcx,8),%edx
sub    %ecx,%edx
sub    %dl,%al
movsbq %al,%rax
lea    0xdd5(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
lea    0xdc2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"Sunday\00"
@.str.1 = [7 x i8] c"Monday\00"
@.str.2 = [8 x i8] c"Tuesday\00"
@.str.3 = [10 x i8] c"Wednesday\00"
@.str.4 = [9 x i8] c"Thursday\00"
@.str.5 = [7 x i8] c"Friday\00"
@.str.6 = [9 x i8] c"Saturday\00"
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
@.str.7 = [6 x i8] c"%s\0A%d\00"
@.str.8 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %4, i32* %1)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %27, label %8
8: ; preds = %0
%9 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %27, label %11
11: ; preds = %8
%12 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %27, label %14
14: ; preds = %11
%15 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i32 6, i32 7
br label %27
27: ; preds = %23, %20, %17, %14, %11, %8, %0
%28 = phi i32 [ 0, %0 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ %26, %23 ]
%29 = load i32, i32* %1
%30 = srem i32 %29, 7
%31 = add nsw i32 %30, %28
%32 = trunc i32 %31 to i8
%33 = srem i8 %32, 7
%34 = sext i8 %33 to i64
%35 = shl i64 %34, 2
%36 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %36)
ret i32 0
}