#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*/ puts(char const *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main() {
  const char *days[7] = {"Sunday",   "Monday", "Tuesday", "Wednesday",
                         "Thursday", "Friday", "Saturday"};
  int a, b, ans = 1;
  scanf("%d%d", &a, &b);
  do
    ans = (ans * a) % 7;
  while (--b);
  puts(days[ans]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x2c96(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x4c(%rbp)
lea    0xed7(%rip),%rdi
lea    -0x44(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x4c(%rbp),%eax
imul   -0x44(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
jne    116f <main+0x3f>
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf11(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%r8d
mov    (%rsp),%edx
lea    -0x1(%rdx),%esi
mov    %edx,%ecx
and    $0x3,%ecx
cmp    $0x3,%esi
jae    1154 <main+0x34>
mov    $0x1,%esi
jmp    120d <main+0xed>
and    $0xfffffffc,%edx
mov    $0x1,%esi
nopl   0x0(%rax)
imul   %r8d,%esi
movslq %esi,%rsi
imul   $0xffffffff92492493,%rsi,%rdi
shr    $0x20,%rdi
add    %esi,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0x2,%edi
add    %eax,%edi
lea    0x0(,%rdi,8),%eax
sub    %eax,%edi
add    %esi,%edi
imul   %r8d,%edi
movslq %edi,%rax
imul   $0xffffffff92492493,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x2,%esi
add    %edi,%esi
lea    0x0(,%rsi,8),%edi
sub    %edi,%esi
add    %eax,%esi
imul   %r8d,%esi
movslq %esi,%rax
imul   $0xffffffff92492493,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x2,%esi
add    %edi,%esi
lea    0x0(,%rsi,8),%edi
sub    %edi,%esi
add    %eax,%esi
imul   %r8d,%esi
movslq %esi,%rax
imul   $0xffffffff92492493,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%edi
shr    $0x1f,%edi
sar    $0x2,%esi
add    %edi,%esi
lea    0x0(,%rsi,8),%edi
sub    %edi,%esi
add    %eax,%esi
add    $0xfffffffc,%edx
jne    1160 <main+0x40>
test   %ecx,%ecx
je     124e <main+0x12e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
imul   %r8d,%esi
movslq %esi,%rax
imul   $0xffffffff92492493,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%edx
shr    $0x1f,%edx
sar    $0x2,%esi
add    %edx,%esi
lea    0x0(,%rsi,8),%edx
sub    %edx,%esi
add    %eax,%esi
add    $0xffffffff,%ecx
jne    1220 <main+0x100>
movl   $0x0,(%rsp)
movslq %esi,%rax
lea    0xde1(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
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.days = [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 = [5 x i8] c"%d%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x i8*]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [7 x i8*]* %2 to i8*
store i32 1, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %3, i32* %4)
br label %8
8: ; preds = %13, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = mul nsw i32 %9, %10
%12 = srem i32 %11, 7
store i32 %12, i32* %5
br label %13
13: ; preds = %8
%14 = load i32, i32* %4
%15 = add nsw i32 %14, -1
store i32 %15, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %13
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @puts(i8* %21)
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 = [5 x i8] c"%d%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add i32 %7, -1
%9 = and i32 %7, 3
%10 = icmp ult i32 %8, 3
br i1 %10, label %26, label %11
11: ; preds = %0
%12 = and i32 %7, -4
br label %13
13: ; preds = %13, %11
%14 = phi i32 [ 1, %11 ], [ %23, %13 ]
%15 = phi i32 [ 0, %11 ], [ %24, %13 ]
%16 = mul nsw i32 %6, %14
%17 = srem i32 %16, 7
%18 = mul nsw i32 %6, %17
%19 = srem i32 %18, 7
%20 = mul nsw i32 %6, %19
%21 = srem i32 %20, 7
%22 = mul nsw i32 %6, %21
%23 = srem i32 %22, 7
%24 = add i32 %15, 4
%25 = icmp eq i32 %24, %12
br i1 %25, label %26, label %13
26: ; preds = %13, %0
%27 = phi i32 [ undef, %0 ], [ %23, %13 ]
%28 = phi i32 [ 1, %0 ], [ %23, %13 ]
%29 = icmp eq i32 %9, 0
br i1 %29, label %37, label %30
30: ; preds = %26, %30
%31 = phi i32 [ %34, %30 ], [ %28, %26 ]
%32 = phi i32 [ %35, %30 ], [ 0, %26 ]
%33 = mul nsw i32 %6, %31
%34 = srem i32 %33, 7
%35 = add i32 %32, 1
%36 = icmp eq i32 %35, %9
br i1 %36, label %37, label %30
37: ; preds = %30, %26
%38 = phi i32 [ %27, %26 ], [ %34, %30 ]
store i32 0, i32* %2
%39 = sext i32 %38 to i64
%40 = shl i64 %39, 2
%41 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %40)
%42 = call i32 @puts(i8* dereferenceable(1) %41)
ret i32 0
}