#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ get_weekday(int, int, int);
int /*<<< orphan*/ show_cal(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fputs("./a.out <year> <mon>\n", stderr);
    exit(0);
  }
  int year, mon;
  if ((year = atoi(argv[1])) < 1900) {
    fputs("the year must great than 1900\n", stderr);
    exit(0);
  }
  if ((mon = atoi(argv[2])) < 1 || mon > 12) {
    fputs("the month must between 1 and 12\n", stderr);
    exit(0);
  }
  show_cal(year, mon, get_weekday(year, mon, 1));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118c <main+0x3c>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x76c,%eax
jge    11c3 <main+0x73>
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x1,%eax
jl     11e6 <main+0x96>
cmpl   $0xc,-0x18(%rbp)
jle    1202 <main+0xb2>
mov    0x2df3(%rip),%rax
mov    (%rax),%esi
lea    0xe3f(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1040 <get_weekday@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
call   1030 <show_cal@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    117e <main+0x2e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
cmp    $0x76b,%eax
jg     1190 <main+0x40>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
jmp    11b7 <main+0x67>
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
jmp    11b7 <main+0x67>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
lea    -0xd(%r14),%eax
cmp    $0xfffffff3,%eax
ja     11c3 <main+0x73>
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
lea    0xe7e(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x1,%edx
call   1040 <get_weekday@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   1030 <show_cal@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"./a.out <year> <mon>\0A\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"the year must great than 1900\0A\00"
@.str.2 = [33 x i8] c"the month must between 1 and 12\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
%19 = icmp slt i32 %18, 1900
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %14
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = icmp slt i32 %28, 1
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* %7
%32 = icmp sgt i32 %31, 12
br i1 %32, label %33, label %37
33: ; preds = %30, %24
%34 = load i32, i32* @stderr
%35 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %30
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @get_weekday(i32 %40, i32 %41, i32 1)
%43 = call i32 @show_cal(i32 %38, i32 %39, i32 %42)
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"./a.out <year> <mon>\0A\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"the year must great than 1900\0A\00"
@.str.2 = [33 x i8] c"the month must between 1 and 12\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 1900
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %8
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = add i32 %20, -13
%22 = icmp ult i32 %21, -12
br i1 %22, label %23, label %27
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = tail call i32 @exit(i32 0)
unreachable
27: ; preds = %17
%28 = tail call i32 @get_weekday(i32 %11, i32 %20, i32 1)
%29 = tail call i32 @show_cal(i32 %11, i32 %20, i32 %28)
%30 = tail call i32 @exit(i32 0)
unreachable
}