#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 *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, a, b, c, i, j, k;
  scanf("%d", &n);
  printf("Sun Mon Tue Wen Thu Fri Sat\n");
  if (n != 7) {
    for (i = 0; i <= n; i++) {
      printf("   ");
    }
  } else {
    for (j = 1; j < 30; j++) {
      for (k = 1; k <= 7; k++) {
        if (j <= 9)
          printf(" ");
        else
          printf(" ");
        printf(" %d", j);
        j++;
      }
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeec(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x7,-0x8(%rbp)
je     118b <main+0x6b>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1186 <main+0x66>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115e <main+0x3e>
jmp    1221 <main+0x101>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1e,-0x1c(%rbp)
jge    121c <main+0xfc>
movl   $0x1,-0x20(%rbp)
cmpl   $0x7,-0x20(%rbp)
jg     1200 <main+0xe0>
cmpl   $0x9,-0x1c(%rbp)
jg     11ca <main+0xaa>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <main+0xb8>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <main+0x83>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1192 <main+0x72>
jmp    1221 <main+0x101>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeb2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0x7,%eax
jne    132e <main+0x1ee>
mov    $0x7,%ebp
lea    0xe82(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x6(%rbp),%r15d
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x5(%rbp),%r12d
cmp    $0x9,%r15d
ja     1280 <main+0x140>
mov    $0xa,%ebx
cmp    $0xf,%ebp
je     1283 <main+0x143>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%ebx
cmp    $0x8,%r15d
jae    129c <main+0x15c>
lea    -0x4(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x3(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%ebx
cmp    $0x6,%r15d
jae    12ce <main+0x18e>
lea    -0x2(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x4,%r15d
mov    $0xa,%ebx
cmovb  %ebp,%ebx
jmp    12ff <main+0x1bf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x4(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x3(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x2(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbp),%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x8,%ebp
cmp    $0x16,%r15d
jb     1190 <main+0x50>
jmp    1353 <main+0x213>
test   %eax,%eax
js     1353 <main+0x213>
mov    $0xffffffff,%ebp
lea    0xcc2(%rip),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     1340 <main+0x200>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"Sun Mon Tue Wen Thu Fri Sat\0A\00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [4 x i8] c" %d\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 7
br i1 %12, label %13, label %24
13: ; preds = %0
store i32 0, i32* %6
br label %14
14: ; preds = %20, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %2
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %14
23: ; preds = %14
br label %53
24: ; preds = %0
store i32 1, i32* %7
br label %25
25: ; preds = %49, %24
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 30
br i1 %27, label %28, label %52
28: ; preds = %25
store i32 1, i32* %8
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %8
%31 = icmp sle i32 %30, 7
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = load i32, i32* %7
%34 = icmp sle i32 %33, 9
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %39
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = load i32, i32* %7
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %44
44: ; preds = %39
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %29
47: ; preds = %29
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %25
52: ; preds = %25
br label %53
53: ; preds = %52, %23
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" \00"
@.str.4 = [4 x i8] c" %d\00"
@str = [28 x i8] c"Sun Mon Tue Wen Thu Fri Sat\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 7
br i1 %6, label %15, label %7
7: ; preds = %0
%8 = icmp slt i32 %5, 0
br i1 %8, label %73, label %9
9: ; preds = %7, %9
%10 = phi i32 [ %12, %9 ], [ 0, %7 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = add nuw nsw i32 %10, 1
%13 = load i32, i32* %1
%14 = icmp slt i32 %10, %13
br i1 %14, label %9, label %73
15: ; preds = %0, %66
%16 = phi i32 [ %71, %66 ], [ 1, %0 ]
%17 = icmp ult i32 %16, 10
%18 = call i32 @putchar(i32 32)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%20 = add nuw nsw i32 %16, 1
br i1 %17, label %21, label %23
21: ; preds = %15
%22 = icmp eq i32 %16, 9
br i1 %22, label %23, label %28
23: ; preds = %15, %21
%24 = phi i32 [ 10, %21 ], [ %20, %15 ]
%25 = call i32 @putchar(i32 32)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%27 = add nuw nsw i32 %16, 2
br label %32
28: ; preds = %21
%29 = call i32 @putchar(i32 32)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%31 = icmp ult i32 %16, 8
br i1 %31, label %40, label %32
32: ; preds = %28, %23
%33 = phi i32 [ %27, %23 ], [ 10, %28 ]
%34 = call i32 @putchar(i32 32)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%36 = add nuw nsw i32 %16, 3
%37 = call i32 @putchar(i32 32)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%39 = add nuw nsw i32 %16, 4
br label %48
40: ; preds = %28
%41 = add nuw nsw i32 %16, 2
%42 = call i32 @putchar(i32 32)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%44 = add nuw nsw i32 %16, 3
%45 = call i32 @putchar(i32 32)
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%47 = icmp ult i32 %16, 6
br i1 %47, label %56, label %48
48: ; preds = %40, %32
%49 = phi i32 [ %39, %32 ], [ 10, %40 ]
%50 = call i32 @putchar(i32 32)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%52 = add nuw nsw i32 %16, 5
%53 = call i32 @putchar(i32 32)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%55 = add nuw nsw i32 %16, 6
br label %66
56: ; preds = %40
%57 = add nuw nsw i32 %16, 4
%58 = call i32 @putchar(i32 32)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%60 = add nuw nsw i32 %16, 5
%61 = call i32 @putchar(i32 32)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%63 = add nuw nsw i32 %16, 6
%64 = icmp ult i32 %16, 4
%65 = select i1 %64, i32 %63, i32 10
br label %66
66: ; preds = %56, %48
%67 = phi i32 [ %55, %48 ], [ %65, %56 ]
%68 = call i32 @putchar(i32 32)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %67)
%70 = call i32 @putchar(i32 10)
%71 = add nuw nsw i32 %16, 8
%72 = icmp ult i32 %16, 22
br i1 %72, label %15, label %73
73: ; preds = %9, %66, %7
ret i32 0
}