#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 EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ displayUsage();
char *getDayName(int /*<<< orphan*/);
int /*<<< orphan*/ getDayOfWeek(int, int, int);
int /*<<< orphan*/ getDoomsday(int);
int /*<<< orphan*/ isLeapYear(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ runTests();
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int day = 0;
  int month = 0;
  int year = 0;
  if (argc == 2) {
    if (strcmp(argv[1], "-t") == 0) {
      runTests();
    } else {
      displayUsage();
    }
  } else if (argc == 3) {
    if (strcmp(argv[1], "-l") == 0) {
      year = atoi(argv[2]);
      printf("%d is ", year);
      if (!isLeapYear(year))
        printf("not ");
      printf("a leap year.\n");
    } else if (strcmp(argv[1], "-d") == 0) {
      year = atoi(argv[2]);
      printf("The doomsday for %d is %s.\n", year,
             getDayName(getDoomsday(year)));
    } else {
      displayUsage();
    }
  } else if (argc == 4) {
    day = atoi(argv[1]);
    month = atoi(argv[2]);
    year = atoi(argv[3]);
    printf("%d %d %d\n", day, month, year);
    printf("%s\n", getDayName(getDayOfWeek(day, month, year)));
  } else {
    displayUsage();
  }
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11fb <main+0x6b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <main+0x5f>
mov    $0x0,%al
call   1070 <runTests@plt>
jmp    11f6 <main+0x66>
mov    $0x0,%al
call   1080 <displayUsage@plt>
jmp    1370 <main+0x1e0>
cmpl   $0x3,-0x8(%rbp)
jne    12e3 <main+0x153>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdef(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1276 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1090 <isLeapYear@plt>
cmp    $0x0,%eax
jne    1263 <main+0xd3>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12de <main+0x14e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12d2 <main+0x142>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <getDoomsday@plt>
mov    %eax,%edi
call   10a0 <getDayName@plt>
mov    -0x20(%rbp),%esi
mov    %rax,%rdx
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d9 <main+0x149>
mov    $0x0,%al
call   1080 <displayUsage@plt>
jmp    12de <main+0x14e>
jmp    136b <main+0x1db>
cmpl   $0x4,-0x8(%rbp)
jne    135f <main+0x1cf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <getDayOfWeek@plt>
mov    %eax,%edi
call   10a0 <getDayName@plt>
mov    %rax,%rsi
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1366 <main+0x1d6>
mov    $0x0,%al
call   1080 <displayUsage@plt>
jmp    136b <main+0x1db>
jmp    1370 <main+0x1e0>
mov    0x2c69(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
je     11e3 <main+0x43>
cmp    $0x3,%edi
je     1237 <main+0x97>
cmp    $0x2,%edi
jne    1261 <main+0xc1>
mov    0x8(%rbx),%rdi
lea    0xe37(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1261 <main+0xc1>
xor    %eax,%eax
call   1080 <runTests@plt>
jmp    1268 <main+0xc8>
mov    0x8(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
lea    0xe25(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <getDayOfWeek@plt>
mov    %eax,%edi
call   10b0 <getDayName@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
jmp    1268 <main+0xc8>
mov    0x8(%rbx),%rdi
lea    0xdc1(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1276 <main+0xd6>
mov    0x8(%rbx),%rdi
lea    0xdbb(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12b8 <main+0x118>
xor    %eax,%eax
call   1090 <displayUsage@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
lea    0xd7e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   10a0 <isLeapYear@plt>
test   %eax,%eax
jne    12aa <main+0x10a>
lea    0xd6a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd8a(%rip),%rdi
call   1030 <puts@plt>
jmp    1268 <main+0xc8>
mov    0x10(%rbx),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <getDoomsday@plt>
mov    %eax,%edi
call   10b0 <getDayName@plt>
lea    0xd3d(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1268 <main+0xc8>

LLVM IR (-O0):
@.str = [3 x i8] c"-t\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [7 x i8] c"%d is \00"
@.str.3 = [5 x i8] c"not \00"
@.str.4 = [14 x i8] c"a leap year.\0A\00"
@.str.5 = [3 x i8] c"-d\00"
@.str.6 = [28 x i8] c"The doomsday for %d is %s.\0A\00"
@.str.7 = [10 x i8] c"%d %d %d\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@EXIT_SUCCESS = global i32 0
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
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 (...) @runTests()
br label %21
19: ; preds = %11
%20 = call i32 (...) @displayUsage()
br label %21
21: ; preds = %19, %17
br label %95
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %65
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %45
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %8
%39 = call i32 @isLeapYear(i32 %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %31
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %31
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %64
45: ; preds = %25
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i64 @strcmp(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %61
51: ; preds = %45
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %8
%56 = load i32, i32* %8
%57 = load i32, i32* %8
%58 = call i32 @getDoomsday(i32 %57)
%59 = call i8* @getDayName(i32 %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %56, i8* %59)
br label %63
61: ; preds = %45
%62 = call i32 (...) @displayUsage()
br label %63
63: ; preds = %61, %51
br label %64
64: ; preds = %63, %43
br label %94
65: ; preds = %22
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 4
br i1 %67, label %68, label %91
68: ; preds = %65
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 1
%71 = load i8*, i8** %70
%72 = call i32 @atoi(i8* %71)
store i32 %72, i32* %6
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i32 @atoi(i8* %75)
store i32 %76, i32* %7
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 3
%79 = load i8*, i8** %78
%80 = call i32 @atoi(i8* %79)
store i32 %80, i32* %8
%81 = load i32, i32* %6
%82 = load i32, i32* %7
%83 = load i32, i32* %8
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %81, i32 %82, i32 %83)
%85 = load i32, i32* %6
%86 = load i32, i32* %7
%87 = load i32, i32* %8
%88 = call i32 @getDayOfWeek(i32 %85, i32 %86, i32 %87)
%89 = call i8* @getDayName(i32 %88)
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %89)
br label %93
91: ; preds = %65
%92 = call i32 (...) @displayUsage()
br label %93
93: ; preds = %91, %68
br label %94
94: ; preds = %93, %64
br label %95
95: ; preds = %94, %21
%96 = load i32, i32* @EXIT_SUCCESS
ret i32 %96
}

LLVM IR (-O2):
@.str = [3 x i8] c"-t\00"
@.str.1 = [3 x i8] c"-l\00"
@.str.2 = [7 x i8] c"%d is \00"
@.str.3 = [5 x i8] c"not \00"
@.str.5 = [3 x i8] c"-d\00"
@.str.6 = [28 x i8] c"The doomsday for %d is %s.\0A\00"
@.str.7 = [10 x i8] c"%d %d %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [13 x i8] c"a leap year.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %55 [
i32 2, label %3
i32 3, label %12
i32 4, label %41
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (...) @runTests()
br label %57
10: ; preds = %3
%11 = tail call i32 (...) @displayUsage()
br label %57
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = tail call i32 @isLeapYear(i32 %20)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %17
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %17
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %57
28: ; preds = %12
%29 = load i8*, i8** %13
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = tail call i32 @atoi(i8* %34)
%36 = tail call i32 @getDoomsday(i32 %35)
%37 = tail call i8* @getDayName(i32 %36)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %35, i8* %37)
br label %57
39: ; preds = %28
%40 = tail call i32 (...) @displayUsage()
br label %57
41: ; preds = %2
%42 = getelementptr inbounds i8*, i8** %1, i64 1
%43 = load i8*, i8** %42
%44 = tail call i32 @atoi(i8* %43)
%45 = getelementptr inbounds i8*, i8** %1, i64 2
%46 = load i8*, i8** %45
%47 = tail call i32 @atoi(i8* %46)
%48 = getelementptr inbounds i8*, i8** %1, i64 3
%49 = load i8*, i8** %48
%50 = tail call i32 @atoi(i8* %49)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %44, i32 %47, i32 %50)
%52 = tail call i32 @getDayOfWeek(i32 %44, i32 %47, i32 %50)
%53 = tail call i8* @getDayName(i32 %52)
%54 = tail call i32 @puts(i8* dereferenceable(1) %53)
br label %57
55: ; preds = %2
%56 = tail call i32 (...) @displayUsage()
br label %57
57: ; preds = %32, %39, %26, %55, %41, %8, %10
%58 = load i32, i32* @EXIT_SUCCESS
ret i32 %58
}