#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*/);
char *get_weekday(int, int, int);
int /*<<< orphan*/ printf(char *, int, int, int, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 4) {
    fputs("./a.out <year> <month> <day>\n", stderr);
    exit(0);
  }
  int year, mon, day;
  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);
  }
  if ((day = atoi(argv[3])) < 1 || day > 31) {
    fputs("the day must between 1 and 31\n", stderr);
    exit(0);
  }
  printf("%d-%d-%d is %s\n", year, mon, day, get_weekday(year, mon, day));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-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    0xe67(%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    0xe47(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x1,%eax
jl     1225 <main+0xd5>
cmpl   $0x1f,-0x1c(%rbp)
jle    1241 <main+0xf1>
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
lea    0xe29(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <get_weekday@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    %rax,%r8
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    117e <main+0x2e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
cmp    $0x76b,%eax
jg     119a <main+0x4a>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
jmp    118e <main+0x3e>
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
call   1050 <fputs@plt>
xor    %edi,%edi
call   1070 <exit@plt>
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    0x2e28(%rip),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
jmp    118e <main+0x3e>
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    -0x20(%rbx),%eax
cmp    $0xffffffe0,%eax
ja     11e8 <main+0x98>
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
lea    0xe78(%rip),%rdi
jmp    118e <main+0x3e>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1040 <get_weekday@plt>
lea    0xe82(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %ebx,%ecx
mov    %rax,%r8
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"./a.out <year> <month> <day>\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"
@.str.3 = [31 x i8] c"the day must between 1 and 31\0A\00"
@.str.4 = [16 x i8] c"%d-%d-%d is %s\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = icmp slt i32 %19, 1900
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 0)
unreachable
25: ; preds = %15
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %7
%30 = icmp slt i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %25
%32 = load i32, i32* %7
%33 = icmp sgt i32 %32, 12
br i1 %33, label %34, label %38
34: ; preds = %31, %25
%35 = load i32, i32* @stderr
%36 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = call i32 @exit(i32 0)
unreachable
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @atoi(i8* %41)
store i32 %42, i32* %8
%43 = icmp slt i32 %42, 1
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = load i32, i32* %8
%46 = icmp sgt i32 %45, 31
br i1 %46, label %47, label %51
47: ; preds = %44, %38
%48 = load i32, i32* @stderr
%49 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %44
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = load i32, i32* %6
%56 = load i32, i32* %7
%57 = load i32, i32* %8
%58 = call i8* @get_weekday(i32 %55, i32 %56, i32 %57)
%59 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %53, i32 %54, i8* %58)
%60 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [30 x i8] c"./a.out <year> <month> <day>\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"
@.str.3 = [31 x i8] c"the day must between 1 and 31\0A\00"
@.str.4 = [16 x i8] c"%d-%d-%d is %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([30 x i8], [30 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 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
%31 = add i32 %30, -32
%32 = icmp ult i32 %31, -31
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = load i32, i32* @stderr
%35 = tail call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = tail call i32 @exit(i32 0)
unreachable
37: ; preds = %27
%38 = tail call i8* @get_weekday(i32 %11, i32 %20, i32 %30)
%39 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %11, i32 %20, i32 %30, i8* %38)
%40 = tail call i32 @exit(i32 0)
unreachable
}