#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ parse_date(char *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int, int, long);
int /*<<< orphan*/ stderr;
long sun_date2mjulianday(int, int, int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <date>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int year;
  int month;
  int day;
  if (!parse_date(argv[1], &year, &month, &day)) {
    fprintf(stderr, "Cannot parse date: %s\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  long daynum;
  daynum = sun_date2mjulianday(year, month, day);
  printf("%02d.%02d.%04d is %ld (Modified Julian Day)\n", day, month, year,
         daynum);
  exit(EXIT_SUCCESS);
}


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   $0x2,-0x8(%rbp)
je     119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1030 <parse_date@plt>
cmp    $0x0,%eax
jne    11e7 <main+0x97>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <sun_date2mjulianday@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%r8
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    118f <main+0x3f>
mov    0x8(%rbx),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
call   1030 <parse_date@plt>
test   %eax,%eax
jne    11b5 <main+0x65>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe85(%rip),%rsi
jmp    11a2 <main+0x52>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe5e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1060 <sun_date2mjulianday@plt>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe50(%rip),%rdi
mov    %rax,%r8
call   1040 <printf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s <date>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c"Cannot parse date: %s\0A\00"
@.str.2 = [45 x i8] c"%02d.%02d.%04d is %ld (Modified Julian Day)\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
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %20
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @parse_date(i8* %23, i32* %6, i32* %7, i32* %8)
%25 = icmp ne i32 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %20
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call i64 @sun_date2mjulianday(i32 %35, i32 %36, i32 %37)
store i64 %38, i64* %9
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = load i32, i32* %6
%42 = load i64, i64* %9
%43 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40, i32 %41, i64 %42)
%44 = load i32, i32* @EXIT_SUCCESS
%45 = call i32 @exit(i32 %44)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"Usage: %s <date>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [23 x i8] c"Cannot parse date: %s\0A\00"
@.str.2 = [45 x i8] c"%02d.%02d.%04d is %ld (Modified Julian Day)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = icmp eq i32 %0, 2
br i1 %6, label %13, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = bitcast i32* %3 to i8*
%15 = bitcast i32* %4 to i8*
%16 = bitcast i32* %5 to i8*
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @parse_date(i8* %18, i32* %3, i32* %4, i32* %5)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %13
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %13
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i64 @sun_date2mjulianday(i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33, i32 %34, i64 %31)
%36 = load i32, i32* @EXIT_SUCCESS
%37 = call i32 @exit(i32 %36)
unreachable
}