#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, day;
  printf("Enter number of days in month: ");
  scanf("%d", &n);
  printf("Enter starting day of the week (1=пн 7=вс): ");
  scanf("%d", &day);
  printf(" пн вт ср чт пт сб вс\n");
  for (int i = 1; i < day; i++) {
    printf("   ");
  }
  for (int i = 1; i <= n; i++) {
    printf("%3d", i);
    if (day % 7 == 0) {
      printf("\n");
    }
    ++day;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <main+0x88>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1180 <main+0x60>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1205 <main+0xe5>
mov    -0x14(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ee <main+0xce>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11af <main+0x8f>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec8(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x2,(%rsp)
jl     11b2 <main+0x72>
mov    $0x1,%ebp
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    (%rsp),%ebp
jl     11a0 <main+0x60>
cmpl   $0x0,0x4(%rsp)
jle    1211 <main+0xd1>
lea    0xe98(%rip),%rbx
xor    %ebp,%ebp
jmp    11dc <main+0x9c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%eax
mov    %eax,(%rsp)
cmp    0x4(%rsp),%ebp
jge    1211 <main+0xd1>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
imul   $0xb6db6db7,%eax,%ecx
add    $0x12492492,%ecx
cmp    $0x24924924,%ecx
ja     11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
jmp    11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Enter number of days in month: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"Enter starting day of the week (1=\D0\BF\D0\BD 7=\D0\B2\D1\81): \00"
@.str.3 = [37 x i8] c" \D0\BF\D0\BD \D0\B2\D1\82 \D1\81\D1\80 \D1\87\D1\82 \D0\BF\D1\82 \D1\81\D0\B1 \D0\B2\D1\81\0A\00"
@.str.4 = [4 x i8] c" \00"
@.str.5 = [4 x i8] c"%3d\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %11
11: ; preds = %17, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %15
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %11
20: ; preds = %11
store i32 1, i32* %5
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %2
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %3
%29 = srem i32 %28, 7
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %33
33: ; preds = %31, %25
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %36
36: ; preds = %33
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %21
39: ; preds = %21
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter number of days in month: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [49 x i8] c"Enter starting day of the week (1=\D0\BF\D0\BD 7=\D0\B2\D1\81): \00"
@.str.4 = [4 x i8] c" \00"
@.str.5 = [4 x i8] c"%3d\00"
@str = [36 x i8] c" \D0\BF\D0\BD \D0\B2\D1\82 \D1\81\D1\80 \D1\87\D1\82 \D0\BF\D1\82 \D1\81\D0\B1 \D0\B2\D1\81\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %15, %0
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %21, label %23
15: ; preds = %0, %15
%16 = phi i32 [ %18, %15 ], [ 1, %0 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%18 = add nuw nsw i32 %16, 1
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %15, label %12
21: ; preds = %32, %12
%22 = call i32 @putchar(i32 10)
ret i32 0
23: ; preds = %12, %32
%24 = phi i32 [ %35, %32 ], [ 1, %12 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = srem i32 %26, 7
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = call i32 @putchar(i32 10)
%31 = load i32, i32* %2
br label %32
32: ; preds = %29, %23
%33 = phi i32 [ %31, %29 ], [ %26, %23 ]
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
%35 = add nuw nsw i32 %24, 1
%36 = load i32, i32* %1
%37 = icmp slt i32 %24, %36
br i1 %37, label %23, label %21
}