#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*/ cn_lunarcal(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int start, end;
  if (argc == 2) {
    start = atoi(argv[1]);
    end = start;
  } else if (argc == 3) {
    start = atoi(argv[1]);
    end = atoi(argv[2]);
  } else {
    printf("Usage: lunarcal startyear endyear \n");
    exit(2);
  }
  printf("BEGIN:VCALENDAR\n"
         "PRODID:-//Chen Wei//Chinese Lunar Calendar//EN\n"
         "VERSION:2.0\n"
         "CALSCALE:GREGORIAN\n"
         "METHOD:PUBLISH\n"
         "X-WR-CALNAME:农历\n"
         "X-WR-TIMEZONE:Asia/Shanghai\n"
         "X-WR-CALDESC:中国农历%d-%d, 包括节气.\n",
         start, end);
  while (start <= end) {
    cn_lunarcal(start);
    start++;
  }
  printf("END:VCALENDAR\n");
  return 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   $0x2,-0x8(%rbp)
jne    117b <main+0x3b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11c7 <main+0x87>
cmpl   $0x3,-0x8(%rbp)
jne    11aa <main+0x6a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11c2 <main+0x82>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
jmp    11c7 <main+0x87>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11fd <main+0xbd>
mov    -0x14(%rbp),%edi
call   1030 <cn_lunarcal@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11db <main+0x9b>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1181 <main+0x31>
cmp    $0x2,%edi
jne    11d3 <main+0x83>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    0xe8e(%rip),%rdi
mov    %eax,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%ebp
jmp    11ad <main+0x5d>
mov    0x8(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
lea    0xe62(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebx,%ebp
jg     11be <main+0x6e>
add    $0x1,%ebx
mov    %ebp,%edi
call   1040 <cn_lunarcal@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11b0 <main+0x60>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"Usage: lunarcal startyear endyear \0A\00"
@.str.1 = [204 x i8] c"BEGIN:VCALENDAR\0APRODID:-//Chen Wei//Chinese Lunar Calendar//EN\0AVERSION:2.0\0ACALSCALE:GREGORIAN\0AMETHOD:PUBLISH\0AX-WR-CALNAME:\E5\86\9C\E5\8E\86\0AX-WR-TIMEZONE:Asia/Shanghai\0AX-WR-CALDESC:\E4\B8\AD\E5\9B\BD\E5\86\9C\E5\8E\86%d-%d, \E5\8C\85\E6\8B\AC\E8\8A\82\E6\B0\94.\0A\00"
@.str.2 = [15 x i8] c"END:VCALENDAR\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 eq i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
store i32 %15, i32* %7
br label %32
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %7
br label %31
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %19
br label %32
32: ; preds = %31, %10
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([204 x i8], [204 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %34)
br label %36
36: ; preds = %40, %32
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = icmp sle i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %6
%42 = call i32 @cn_lunarcal(i32 %41)
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %36
45: ; preds = %36
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [204 x i8] c"BEGIN:VCALENDAR\0APRODID:-//Chen Wei//Chinese Lunar Calendar//EN\0AVERSION:2.0\0ACALSCALE:GREGORIAN\0AMETHOD:PUBLISH\0AX-WR-CALNAME:\E5\86\9C\E5\8E\86\0AX-WR-TIMEZONE:Asia/Shanghai\0AX-WR-CALDESC:\E4\B8\AD\E5\9B\BD\E5\86\9C\E5\8E\86%d-%d, \E5\8C\85\E6\8B\AC\E8\8A\82\E6\B0\94.\0A\00"
@str = [35 x i8] c"Usage: lunarcal startyear endyear \00"
@str.3 = [14 x i8] c"END:VCALENDAR\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %8 [
i32 2, label %3
i32 3, label %11
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @atoi(i8* %5)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([204 x i8], [204 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %6)
br label %20
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 2)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([204 x i8], [204 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17)
%19 = icmp sgt i32 %14, %17
br i1 %19, label %28, label %20
20: ; preds = %3, %11
%21 = phi i32 [ %6, %3 ], [ %17, %11 ]
%22 = phi i32 [ %6, %3 ], [ %14, %11 ]
br label %23
23: ; preds = %20, %23
%24 = phi i32 [ %26, %23 ], [ %22, %20 ]
%25 = tail call i32 @cn_lunarcal(i32 %24)
%26 = add i32 %24, 1
%27 = icmp eq i32 %24, %21
br i1 %27, label %28, label %23
28: ; preds = %23, %11
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
ret i32 0
}