#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char *argv[]) {
  int month, year;
  month = atoi(argv[1]);
  year = atoi(argv[2]);
  if (month == 1 || month == 2)
    year = year + 1;
  int days;
  if (month <= 7)
    if (month % 2 == 0)
      days = 30;
    else
      days = 31;
  else if (month % 2 == 0)
    days = 31;
  else
    days = 30;
  if (month == 2)
    if ((year - 1) % 4 == 0)
      days = 29;
    else
      days = 28;
  printf("Su Mo Tu We Th Fr Sa\n");
  int i;
  int isFirst = 1;
  for (i = 1; i <= days; i++) {
    int weekday = (i + (((month + 1) * 26) / 10) + year + (year / 4) +
                   (6 * (year / 100)) + (year / 400)) %
                  7;
    if (month == 2)
      if (weekday == 6)
        weekday = 0;
      else
        weekday = weekday + 1;
    if (isFirst == 1) {
      if (weekday == 0) {
        printf("                  ");
      } else {
        int j;
        for (j = 0; j < (weekday - 1); j++)
          printf("   ");
        isFirst = 0;
      }
    }
    if (weekday == 0)
      printf("%2d\n", i);
    else
      printf("%2d ", i);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     116a <main+0x4a>
cmpl   $0x2,-0x14(%rbp)
jne    1173 <main+0x53>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x7,-0x14(%rbp)
jg     11a9 <main+0x89>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    119d <main+0x7d>
movl   $0x1e,-0x1c(%rbp)
jmp    11a4 <main+0x84>
movl   $0x1f,-0x1c(%rbp)
jmp    11d5 <main+0xb5>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c9 <main+0xa9>
movl   $0x1f,-0x1c(%rbp)
jmp    11d0 <main+0xb0>
movl   $0x1e,-0x1c(%rbp)
jmp    11d5 <main+0xb5>
cmpl   $0x2,-0x14(%rbp)
jne    120e <main+0xee>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1202 <main+0xe2>
movl   $0x1d,-0x1c(%rbp)
jmp    1209 <main+0xe9>
movl   $0x1c,-0x1c(%rbp)
jmp    120e <main+0xee>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     137d <main+0x25d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
imul   $0x1a,%eax,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   $0x6,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
cmpl   $0x2,-0x14(%rbp)
jne    12d2 <main+0x1b2>
cmpl   $0x6,-0x28(%rbp)
jne    12c4 <main+0x1a4>
movl   $0x0,-0x28(%rbp)
jmp    12cd <main+0x1ad>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12d2 <main+0x1b2>
cmpl   $0x1,-0x24(%rbp)
jne    1339 <main+0x219>
cmpl   $0x0,-0x28(%rbp)
jne    12f9 <main+0x1d9>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1334 <main+0x214>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    132d <main+0x20d>
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1300 <main+0x1e0>
movl   $0x0,-0x24(%rbp)
jmp    1339 <main+0x219>
cmpl   $0x0,-0x28(%rbp)
jne    1359 <main+0x239>
mov    -0x20(%rbp),%esi
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    136a <main+0x24a>
mov    -0x20(%rbp),%esi
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    136f <main+0x24f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122a <main+0x10a>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
lea    -0x1(%rbx),%eax
cmp    $0x2,%eax
adc    $0x0,%r14d
mov    %ebx,%ebp
and    $0x1,%ebp
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
lea    0x3(%r14),%eax
xor    %ecx,%ecx
test   $0x3,%al
sete   %cl
or     $0x1c,%ecx
lea    0x1e(%rbp),%edx
xor    $0x1f,%ebp
cmp    $0x8,%ebx
cmovl  %edx,%ebp
cmp    $0x2,%ebx
cmove  %ecx,%ebp
mov    %rbp,0x8(%rsp)
lea    (%rbx,%rbx,4),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %rbx,0x10(%rsp)
add    %ebx,%ecx
add    $0x1a,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
test   %r14d,%r14d
cmovns %r14d,%eax
sar    $0x2,%eax
movslq %r14d,%rdx
imul   $0x51eb851f,%rdx,%rsi
mov    %rsi,%rdi
sar    $0x25,%rdi
mov    %rsi,%rbp
shr    $0x3f,%rbp
add    %ebp,%edi
lea    (%rdi,%rdi,2),%edi
sar    $0x27,%rsi
add    %ebp,%esi
add    %ecx,%edx
add    %eax,%edx
add    %esi,%edx
lea    (%rdx,%rdi,2),%r13d
mov    $0x1,%r14d
lea    0xdfc(%rip),%r12
mov    $0x1,%ebx
jmp    1250 <main+0x110>
nopw   0x0(%rax,%rax,1)
test   %r15d,%r15d
lea    0xdee(%rip),%rdi
lea    0xde2(%rip),%rax
cmove  %rax,%rdi
xor    %r14d,%r14d
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x1(%rbx),%eax
cmp    0x8(%rsp),%ebx
mov    %eax,%ebx
je     12e4 <main+0x1a4>
lea    (%rbx,%r13,1),%eax
cltq
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
lea    (%rax,%rcx,1),%edx
cmp    $0x6,%edx
lea    0x1(%rcx,%rax,1),%r15d
mov    $0x0,%eax
cmove  %eax,%r15d
cmpl   $0x2,0x10(%rsp)
cmovne %edx,%r15d
cmp    $0x1,%r14d
jne    1220 <main+0xe0>
test   %r15d,%r15d
je     12c4 <main+0x184>
cmp    $0x2,%r15d
jl     1220 <main+0xe0>
lea    -0x1(%r15),%ebp
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebp
jne    12b0 <main+0x170>
jmp    1220 <main+0xe0>
lea    0xd35(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
lea    0xd34(%rip),%rdi
jmp    1238 <main+0xf8>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Su Mo Tu We Th Fr Sa\0A\00"
@.str.1 = [19 x i8] c" \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [5 x i8] c"%2d\0A\00"
@.str.4 = [5 x i8] c"%2d \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 1
br i1 %22, label %26, label %23
23: ; preds = %2
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %29
26: ; preds = %23, %2
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26, %23
%30 = load i32, i32* %6
%31 = icmp sle i32 %30, 7
br i1 %31, label %32, label %39
32: ; preds = %29
%33 = load i32, i32* %6
%34 = srem i32 %33, 2
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 30, i32* %8
br label %38
37: ; preds = %32
store i32 31, i32* %8
br label %38
38: ; preds = %37, %36
br label %46
39: ; preds = %29
%40 = load i32, i32* %6
%41 = srem i32 %40, 2
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 31, i32* %8
br label %45
44: ; preds = %39
store i32 30, i32* %8
br label %45
45: ; preds = %44, %43
br label %46
46: ; preds = %45, %38
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 2
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i32, i32* %7
%51 = sub nsw i32 %50, 1
%52 = srem i32 %51, 4
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %49
store i32 29, i32* %8
br label %56
55: ; preds = %49
store i32 28, i32* %8
br label %56
56: ; preds = %55, %54
br label %57
57: ; preds = %56, %46
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %10
store i32 1, i32* %9
br label %59
59: ; preds = %124, %57
%60 = load i32, i32* %9
%61 = load i32, i32* %8
%62 = icmp sle i32 %60, %61
br i1 %62, label %63, label %127
63: ; preds = %59
%64 = load i32, i32* %9
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
%67 = mul nsw i32 %66, 26
%68 = sdiv i32 %67, 10
%69 = add nsw i32 %64, %68
%70 = load i32, i32* %7
%71 = add nsw i32 %69, %70
%72 = load i32, i32* %7
%73 = sdiv i32 %72, 4
%74 = add nsw i32 %71, %73
%75 = load i32, i32* %7
%76 = sdiv i32 %75, 100
%77 = mul nsw i32 6, %76
%78 = add nsw i32 %74, %77
%79 = load i32, i32* %7
%80 = sdiv i32 %79, 400
%81 = add nsw i32 %78, %80
%82 = srem i32 %81, 7
store i32 %82, i32* %11
%83 = load i32, i32* %6
%84 = icmp eq i32 %83, 2
br i1 %84, label %85, label %93
85: ; preds = %63
%86 = load i32, i32* %11
%87 = icmp eq i32 %86, 6
br i1 %87, label %88, label %89
88: ; preds = %85
store i32 0, i32* %11
br label %92
89: ; preds = %85
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 1
store i32 %91, i32* %11
br label %92
92: ; preds = %89, %88
br label %93
93: ; preds = %92, %63
%94 = load i32, i32* %10
%95 = icmp eq i32 %94, 1
br i1 %95, label %96, label %114
96: ; preds = %93
%97 = load i32, i32* %11
%98 = icmp eq i32 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %96
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %113
101: ; preds = %96
store i32 0, i32* %12
br label %102
102: ; preds = %109, %101
%103 = load i32, i32* %12
%104 = load i32, i32* %11
%105 = sub nsw i32 %104, 1
%106 = icmp slt i32 %103, %105
br i1 %106, label %107, label %112
107: ; preds = %102
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %109
109: ; preds = %107
%110 = load i32, i32* %12
%111 = add nsw i32 %110, 1
store i32 %111, i32* %12
br label %102
112: ; preds = %102
store i32 0, i32* %10
br label %113
113: ; preds = %112, %99
br label %114
114: ; preds = %113, %93
%115 = load i32, i32* %11
%116 = icmp eq i32 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %114
%118 = load i32, i32* %9
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %118)
br label %123
120: ; preds = %114
%121 = load i32, i32* %9
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %121)
br label %123
123: ; preds = %120, %117
br label %124
124: ; preds = %123
%125 = load i32, i32* %9
%126 = add nsw i32 %125, 1
store i32 %126, i32* %9
br label %59
127: ; preds = %59
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%129 = load i32, i32* %3
ret i32 %129
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c" \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [5 x i8] c"%2d\0A\00"
@.str.4 = [5 x i8] c"%2d \00"
@str = [21 x i8] c"Su Mo Tu We Th Fr Sa\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = icmp eq i32 %5, 2
%10 = add i32 %5, -1
%11 = icmp ult i32 %10, 2
%12 = zext i1 %11 to i32
%13 = add nsw i32 %8, %12
%14 = and i32 %5, 1
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%16 = add i32 %13, 3
%17 = and i32 %16, 3
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 29, i32 28
%20 = icmp slt i32 %5, 8
%21 = or i32 %14, 30
%22 = xor i32 %14, 31
%23 = select i1 %20, i32 %21, i32 %22
%24 = select i1 %9, i32 %19, i32 %23
%25 = mul i32 %5, 26
%26 = add i32 %25, 26
%27 = sdiv i32 %26, 10
%28 = sdiv i32 %13, 4
%29 = sdiv i32 %13, 100
%30 = mul nsw i32 %29, 6
%31 = sdiv i32 %13, 400
%32 = add i32 %13, %27
%33 = add i32 %32, %28
%34 = add i32 %33, %31
%35 = add i32 %34, %30
br label %36
36: ; preds = %2, %61
%37 = phi i32 [ 1, %2 ], [ %63, %61 ]
%38 = phi i32 [ 1, %2 ], [ %65, %61 ]
%39 = add i32 %35, %38
%40 = srem i32 %39, 7
%41 = icmp eq i32 %40, 6
%42 = add nsw i32 %40, 1
%43 = select i1 %41, i32 0, i32 %42
%44 = select i1 %9, i32 %43, i32 %40
%45 = icmp eq i32 %37, 1
br i1 %45, label %46, label %58
46: ; preds = %36
%47 = icmp eq i32 %44, 0
br i1 %47, label %51, label %48
48: ; preds = %46
%49 = add nsw i32 %44, -1
%50 = icmp sgt i32 %44, 1
br i1 %50, label %53, label %58
51: ; preds = %46
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %61
53: ; preds = %48, %53
%54 = phi i32 [ %56, %53 ], [ 0, %48 ]
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%56 = add nuw nsw i32 %54, 1
%57 = icmp eq i32 %56, %49
br i1 %57, label %58, label %53
58: ; preds = %53, %48, %36
%59 = icmp eq i32 %44, 0
%60 = select i1 %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
br label %61
61: ; preds = %58, %51
%62 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %51 ], [ %60, %58 ]
%63 = phi i32 [ 1, %51 ], [ 0, %58 ]
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %62, i32 %38)
%65 = add nuw nsw i32 %38, 1
%66 = icmp eq i32 %38, %24
br i1 %66, label %67, label %36
67: ; preds = %61
%68 = tail call i32 @putchar(i32 10)
ret i32 0
}