int main(void) {
  int month[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
  char day[][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int x, y;
  scanf("%d %d", &x, &y);
  printf("%s", day[(month[x - 1] + y) % 7]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x30(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
mov    0xedc(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xed9(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xed6(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xed4(%rip),%eax
mov    %eax,-0x38(%rbp)
lea    0xece(%rip),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
add    -0x58(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
lea    -0x50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movups 0xf11(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xf09(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
lea    0xea0(%rip),%rcx
mov    0x8(%rsp),%edx
add    -0x4(%rcx,%rax,4),%edx
movslq %edx,%rax
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.month = [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
@__const.main.day = [7 x [4 x i8]] [[4 x i8] c"SUN\00", [4 x i8] c"MON\00", [4 x i8] c"TUE\00", [4 x i8] c"WED\00", [4 x i8] c"THU\00", [4 x i8] c"FRI\00", [4 x i8] c"SAT\00"]
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = alloca [7 x [4 x i8]]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [12 x i32]* %1 to i8*
%6 = bitcast [7 x [4 x i8]]* %2 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = load i32, i32* %4
%14 = add nsw i32 %12, %13
%15 = srem i32 %14, 7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [7 x [4 x i8]], [7 x [4 x i8]]* %2, i64 0, i64 %16
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@__const.main.month = [12 x i32] [i32 0, i32 31, i32 59, i32 90, i32 120, i32 151, i32 181, i32 212, i32 243, i32 273, i32 304, i32 334]
@__const.main.day = [7 x [4 x i8]] [[4 x i8] c"SUN\00", [4 x i8] c"MON\00", [4 x i8] c"TUE\00", [4 x i8] c"WED\00", [4 x i8] c"THU\00", [4 x i8] c"FRI\00", [4 x i8] c"SAT\00"]
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [7 x [4 x i8]]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [7 x [4 x i8]], [7 x [4 x i8]]* %1, i64 0, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [12 x i32], [12 x i32]* @__const.main.month, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = load i32, i32* %3
%14 = add nsw i32 %13, %12
%15 = srem i32 %14, 7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [7 x [4 x i8]], [7 x [4 x i8]]* %1, i64 0, i64 %16, i64 0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
ret i32 0
}