#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 */
char *int2week(int /*<<< orphan*/);
int /*<<< orphan*/ month2int(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, int *, int *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strstr(char *, char *);
int /*<<< orphan*/ usage();
int /*<<< orphan*/ zeller(int, int /*<<< orphan*/, int, int);
int main(int argc, char *argv[]) {
  char *date, *pattern, month[10];
  int day, year, julian = 0;
  if (argc < 2) {
    usage();
  }
  if (strcmp(argv[1], "-j") == 0) {
    if (argc == 3) {
      date = argv[2];
      julian = 1;
    } else {
      usage();
    }
  } else {
    date = argv[1];
  }
  pattern = strstr(date, ",") ? "%s %d, %d" : "%s %d %d";
  sscanf(date, pattern, month, &day, &year);
  printf("%s\n", int2week(zeller(day, month2int(month), year, julian)));
  return 0;
}


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)
movl   $0x0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ae <main+0x2e>
mov    $0x0,%al
call   1080 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fa <main+0x7a>
cmpl   $0x3,-0x8(%rbp)
jne    11ee <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    11f5 <main+0x75>
mov    $0x0,%al
call   1080 <usage@plt>
jmp    1206 <main+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,%rdx
lea    0xdef(%rip),%rax
lea    0xdde(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2a(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1060 <sscanf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x2a(%rbp),%rdi
call   1050 <month2int@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
call   1090 <zeller@plt>
mov    %eax,%edi
call   1070 <int2week@plt>
mov    %rax,%rsi
lea    0xd9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x1,%edi
jg     1199 <main+0x19>
xor    %eax,%eax
call   1080 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b7 <main+0x37>
mov    0x8(%rbx),%rbx
xor    %r14d,%r14d
jmp    11d2 <main+0x52>
cmp    $0x3,%ebp
jne    11c8 <main+0x48>
mov    0x10(%rbx),%rbx
mov    $0x1,%r14d
jmp    11d2 <main+0x52>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <usage@plt>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strstr@plt>
test   %rax,%rax
lea    0xe24(%rip),%rax
lea    0xe13(%rip),%rsi
cmove  %rax,%rsi
lea    0x16(%rsp),%rbp
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1060 <sscanf@plt>
mov    0x10(%rsp),%ebx
mov    %rbp,%rdi
call   1050 <month2int@plt>
mov    0xc(%rsp),%edx
mov    %ebx,%edi
mov    %eax,%esi
mov    %r14d,%ecx
call   1090 <zeller@plt>
mov    %eax,%edi
call   1070 <int2week@plt>
lea    0xdde(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-j\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [10 x i8] c"%s %d, %d\00"
@.str.3 = [9 x i8] c"%s %d %d\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [10 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
br label %16
16: ; preds = %14, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %16
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 3
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
store i8* %28, i8** %6
store i32 1, i32* %11
br label %31
29: ; preds = %22
%30 = call i32 (...) @usage()
br label %31
31: ; preds = %29, %25
br label %36
32: ; preds = %16
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
store i8* %35, i8** %6
br label %36
36: ; preds = %32, %31
%37 = load i8*, i8** %6
%38 = call i64 @strstr(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = icmp ne i64 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0)
store i8* %41, i8** %7
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%45 = call i32 @sscanf(i8* %42, i8* %43, i8* %44, i32* %9, i32* %10)
%46 = load i32, i32* %9
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%48 = call i32 @month2int(i8* %47)
%49 = load i32, i32* %10
%50 = load i32, i32* %11
%51 = call i32 @zeller(i32 %46, i32 %48, i32 %49, i32 %50)
%52 = call i8* @int2week(i32 %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"-j\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [10 x i8] c"%s %d, %d\00"
@.str.3 = [9 x i8] c"%s %d %d\00"
@.str.4 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @usage()
br label %12
12: ; preds = %10, %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, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = icmp eq i32 %0, 3
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
br label %26
22: ; preds = %17
%23 = tail call i32 (...) @usage()
br label %26
24: ; preds = %12
%25 = load i8*, i8** %13
br label %26
26: ; preds = %19, %22, %24
%27 = phi i8* [ %21, %19 ], [ undef, %22 ], [ %25, %24 ]
%28 = phi i32 [ 1, %19 ], [ 0, %22 ], [ 0, %24 ]
%29 = tail call i64 @strstr(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%32 = call i32 @sscanf(i8* %27, i8* %31, i8* %6, i32* %4, i32* %5)
%33 = load i32, i32* %4
%34 = call i32 @month2int(i8* %6)
%35 = load i32, i32* %5
%36 = call i32 @zeller(i32 %33, i32 %34, i32 %35, i32 %28)
%37 = call i8* @int2week(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %37)
ret i32 0
}