#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(void) {
  int days_one_month = 30, starting_day = 1;
  printf("enter number of days in month:\n");
  scanf("%d", &days_one_month);
  printf("enter starting day of the week(1 = Sun, 7 = Sat):\n");
  scanf("%d", &starting_day);
  for (int i = 1; i < days_one_month + starting_day; i++) {
    if (i >= starting_day) {
      if (i % 7 == 0) {
        printf("%2d\n", i + 1 - starting_day);
      } else {
        printf("%2d ", i + 1 - starting_day);
      }
    } else {
      printf("   ");
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    120a <main+0xea>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11e9 <main+0xc9>
mov    -0x10(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11cd <main+0xad>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
sub    -0xc(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <main+0xc4>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
sub    -0xc(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <main+0xd7>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <main+0xdc>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1180 <main+0x60>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x1e,0x4(%rsp)
movl   $0x1,(%rsp)
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeb3(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
add    %eax,%ecx
cmp    $0x2,%ecx
jl     1204 <main+0xc4>
mov    $0x1,%ebp
lea    0xe66(%rip),%rbx
lea    0xe55(%rip),%r14
lea    0xe53(%rip),%r15
jmp    11da <main+0x9a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
add    %eax,%ecx
cmp    %ecx,%ebp
jge    1204 <main+0xc4>
cmp    %eax,%ebp
jl     11c0 <main+0x80>
imul   $0xb6db6db7,%ebp,%ecx
add    $0x1,%ebp
mov    %ebp,%esi
sub    %eax,%esi
cmp    $0x24924924,%ecx
jbe    11f8 <main+0xb8>
mov    %r15,%rdi
jmp    11fb <main+0xbb>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11cd <main+0x8d>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"enter number of days in month:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [51 x i8] c"enter starting day of the week(1 = Sun, 7 = Sat):\0A\00"
@.str.3 = [5 x i8] c"%2d\0A\00"
@.str.4 = [5 x i8] c"%2d \00"
@.str.5 = [4 x i8] c" \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 30, i32* %2
store i32 1, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* 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* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 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* %3)
store i32 1, i32* %4
br label %9
9: ; preds = %39, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = add nsw i32 %11, %12
%14 = icmp slt i32 %10, %13
br i1 %14, label %15, label %42
15: ; preds = %9
%16 = load i32, i32* %4
%17 = load i32, i32* %3
%18 = icmp sge i32 %16, %17
br i1 %18, label %19, label %36
19: ; preds = %15
%20 = load i32, i32* %4
%21 = srem i32 %20, 7
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %35
29: ; preds = %19
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %3
%33 = sub nsw i32 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %29, %23
br label %38
36: ; preds = %15
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %36, %35
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %9
42: ; preds = %9
%43 = 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.1 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"%2d\0A\00"
@.str.4 = [5 x i8] c"%2d \00"
@.str.5 = [4 x i8] c" \00"
@str = [31 x i8] c"enter number of days in month:\00"
@str.7 = [50 x i8] c"enter starting day of the week(1 = Sun, 7 = Sat):\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 30, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.7, 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 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = add nsw i32 %10, %9
%12 = icmp sgt i32 %11, 1
br i1 %12, label %15, label %13
13: ; preds = %31, %0
%14 = call i32 @putchar(i32 10)
ret i32 0
15: ; preds = %0, %31
%16 = phi i32 [ %34, %31 ], [ %10, %0 ]
%17 = phi i32 [ %32, %31 ], [ 1, %0 ]
%18 = icmp slt i32 %17, %16
br i1 %18, label %28, label %19
19: ; preds = %15
%20 = urem i32 %17, 7
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i32 %17, 1
%23 = sub i32 %22, %16
br i1 %21, label %24, label %26
24: ; preds = %19
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %31
26: ; preds = %19
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %31
28: ; preds = %15
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%30 = add nuw nsw i32 %17, 1
br label %31
31: ; preds = %28, %26, %24
%32 = phi i32 [ %30, %28 ], [ %22, %26 ], [ %22, %24 ]
%33 = load i32, i32* %1
%34 = load i32, i32* %2
%35 = add nsw i32 %34, %33
%36 = icmp slt i32 %32, %35
br i1 %36, label %15, label %13
}