#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ domonth(int, int);
int /*<<< orphan*/ doyear(int);
struct tm *localtime(int /*<<< orphan*/ *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int arg1val;
  int arg1len;
  int arg2val;
  struct tm *tm;
  time_t now;
  if (argc <= 1) {
    now = time(NULL);
    tm = localtime(&now);
    domonth(tm->tm_year, tm->tm_mon);
  } else {
    arg1val = atoi(argv[1]);
    arg1len = strlen(argv[1]);
    if (argc == 2) {
      if (arg1len <= 2 && arg1val <= 12) {
        now = time(NULL);
        tm = localtime(&now);
        domonth(tm->tm_year, arg1val);
      } else
        doyear(arg1val);
    } else {
      arg2val = atoi(argv[2]);
      if (arg1len > 2)
        domonth(arg1val, arg2val);
      else
        domonth(arg2val, arg1val);
    }
  }
  return (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   $0x1,-0x8(%rbp)
jg     11b0 <main+0x50>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
call   1060 <domonth@plt>
jmp    1266 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1227 <main+0xc7>
cmpl   $0x2,-0x18(%rbp)
jg     121a <main+0xba>
cmpl   $0xc,-0x14(%rbp)
jg     121a <main+0xba>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1060 <domonth@plt>
jmp    1222 <main+0xc2>
mov    -0x14(%rbp),%edi
call   1070 <doyear@plt>
jmp    1261 <main+0x101>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x18(%rbp)
jle    1251 <main+0xf1>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <domonth@plt>
jmp    125c <main+0xfc>
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <domonth@plt>
jmp    1261 <main+0x101>
jmp    1266 <main+0x106>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     118d <main+0x2d>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edi
mov    0x4(%rax),%esi
jmp    11fc <main+0x9c>
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
cmp    $0x2,%ebp
jne    11d6 <main+0x76>
cmp    $0x2,%r15d
jg     11ed <main+0x8d>
cmp    $0xc,%r14d
jg     11ed <main+0x8d>
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%edi
jmp    11f9 <main+0x99>
mov    0x10(%r12),%rdi
call   1080 <atoi@plt>
cmp    $0x3,%r15d
jl     11f7 <main+0x97>
mov    %r14d,%edi
mov    %eax,%esi
jmp    11fc <main+0x9c>
mov    %r14d,%edi
call   1070 <doyear@plt>
jmp    1201 <main+0xa1>
mov    %eax,%edi
mov    %r14d,%esi
call   1060 <domonth@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
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 %struct.tm*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sle i32 %11, 1
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = call i32 @time(i32* null)
store i32 %14, i32* %10
%15 = call %struct.tm* @localtime(i32* %10)
store %struct.tm* %15, %struct.tm** %9
%16 = load %struct.tm*, %struct.tm** %9
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load %struct.tm*, %struct.tm** %9
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @domonth(i32 %18, i32 %21)
br label %69
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %52
34: ; preds = %23
%35 = load i32, i32* %7
%36 = icmp sle i32 %35, 2
br i1 %36, label %37, label %48
37: ; preds = %34
%38 = load i32, i32* %6
%39 = icmp sle i32 %38, 12
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = call i32 @time(i32* null)
store i32 %41, i32* %10
%42 = call %struct.tm* @localtime(i32* %10)
store %struct.tm* %42, %struct.tm** %9
%43 = load %struct.tm*, %struct.tm** %9
%44 = getelementptr inbounds %struct.tm, %struct.tm* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = load i32, i32* %6
%47 = call i32 @domonth(i32 %45, i32 %46)
br label %51
48: ; preds = %37, %34
%49 = load i32, i32* %6
%50 = call i32 @doyear(i32 %49)
br label %51
51: ; preds = %48, %40
br label %68
52: ; preds = %23
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @atoi(i8* %55)
store i32 %56, i32* %8
%57 = load i32, i32* %7
%58 = icmp sgt i32 %57, 2
br i1 %58, label %59, label %63
59: ; preds = %52
%60 = load i32, i32* %6
%61 = load i32, i32* %8
%62 = call i32 @domonth(i32 %60, i32 %61)
br label %67
63: ; preds = %52
%64 = load i32, i32* %8
%65 = load i32, i32* %6
%66 = call i32 @domonth(i32 %64, i32 %65)
br label %67
67: ; preds = %63, %59
br label %68
68: ; preds = %67, %51
br label %69
69: ; preds = %68, %13
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = call %struct.tm* @localtime(i32* %3)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %8, i64 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 @domonth(i32 %10, i32 %12)
br label %41
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i32 @strlen(i8* %16)
%19 = icmp eq i32 %0, 2
br i1 %19, label %20, label %32
20: ; preds = %14
%21 = icmp slt i32 %18, 3
%22 = icmp slt i32 %17, 13
%23 = select i1 %21, i1 %22, i1 false
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = tail call i32 @time(i32* null)
store i32 %25, i32* %3
%26 = call %struct.tm* @localtime(i32* %3)
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i64 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @domonth(i32 %28, i32 %17)
br label %41
30: ; preds = %20
%31 = tail call i32 @doyear(i32 %17)
br label %41
32: ; preds = %14
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = tail call i32 @atoi(i8* %34)
%36 = icmp sgt i32 %18, 2
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = tail call i32 @domonth(i32 %17, i32 %35)
br label %41
39: ; preds = %32
%40 = tail call i32 @domonth(i32 %35, i32 %17)
br label %41
41: ; preds = %30, %24, %39, %37, %6
ret i32 0
}