#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_mday;
  int tm_mon;
  int tm_year;
};

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ date_to_mjd(int, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ mjd_to_date(int);
int /*<<< orphan*/ mjd_to_yday(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int day, month, year;
  int mjd;
  time_t tnow;
  struct tm *gmt;
  if (argc == 1) {
    scanf("%d %d %d", &day, &month, &year);
    date_to_mjd(day, month, year);
    exit(EXIT_SUCCESS);
  }
  if (argc == 5 && strcmp(argv[1], "-d") == 0) {
    day = atoi(argv[2]);
    month = atoi(argv[3]);
    year = atoi(argv[4]);
    date_to_mjd(day, month, year);
    printf("\n");
    exit(EXIT_SUCCESS);
  }
  if (argc == 3 && strcmp(argv[1], "-m") == 0) {
    mjd = atoi(argv[2]);
    mjd_to_date(mjd);
    printf("\n");
    exit(EXIT_SUCCESS);
  }
  if (argc == 3 && strcmp(argv[1], "-y") == 0) {
    mjd = atoi(argv[2]);
    mjd_to_yday(mjd);
    printf("\n");
    exit(EXIT_SUCCESS);
  }
  if (argc == 2 && strcmp(argv[1], "-h") == 0) {
    printf("\nmjd version %s\n\n", "1.7");
    printf("usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-h] [-v]\n\n");
    printf("Options:-\n\n");
    printf("\t-d\t: convert date to MJD\n");
    printf("\t-m\t: convert MJD to date\n");
    printf("\t-y\t: convert MJD to DOY year\n");
    printf("\t-t\t: show today's MJD\n");
    printf("\t-h\t: show this help\n");
    printf("\t-v\t: show version\n\n");
    printf("See also the man page for 'mjd'\n\n");
    exit(EXIT_SUCCESS);
  }
  if (argc == 2 && strcmp(argv[1], "-v") == 0) {
    printf("\nversion %s\n\n", "1.7");
    exit(EXIT_SUCCESS);
  }
  if (argc == 2 && strcmp(argv[1], "-t") == 0) {
    tnow = time(NULL);
    if (!(gmt = gmtime(&tnow))) {
      fprintf(stderr, "gmtime() failed!\n");
      return EXIT_FAILURE;
    }
    date_to_mjd(gmt->tm_mday, gmt->tm_mon + 1, gmt->tm_year + 1900);
    printf("\n");
    exit(EXIT_SUCCESS);
  }
  printf("mjd: invalid option or wrong number of parameters\n");
  printf("usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-t] [-h] [-v]\n");
  return EXIT_FAILURE;
}


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)
jne    1204 <main+0x54>
lea    0xe29(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1090 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <date_to_mjd@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1286 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdec(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1286 <main+0xd6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <date_to_mjd@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    12e2 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd6d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12e2 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1030 <mjd_to_date@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cf5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jne    133e <main+0x18e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd14(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    133e <main+0x18e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   10d0 <mjd_to_yday@plt>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1407 <main+0x257>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcbb(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1407 <main+0x257>
lea    0xca8(%rip),%rdi
lea    0xcb3(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1452 <main+0x2a2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd0a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1452 <main+0x2a2>
lea    0xcf7(%rip),%rdi
lea    0xbea(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1501 <main+0x351>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcd0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1501 <main+0x351>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rdi
call   10a0 <gmtime@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    14c3 <main+0x313>
mov    0x2b3c(%rip),%rax
mov    (%rax),%edi
lea    0xc91(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2b1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1529 <main+0x379>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%edx
add    $0x76c,%edx
call   1050 <date_to_mjd@plt>
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ad6(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ab4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
add    $0xffffffff,%edi
cmp    $0x4,%edi
ja     12d3 <main+0x103>
mov    %rsi,%rbx
lea    0xe12(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x8(%rbx),%rdi
lea    0xe24(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     132e <main+0x15e>
mov    0x8(%rbx),%rdi
lea    0xe24(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13b1 <main+0x1e1>
mov    0x8(%rbx),%rdi
lea    0xe1c(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12d3 <main+0x103>
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   10c0 <gmtime@plt>
test   %rax,%rax
jne    1403 <main+0x233>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
call   1090 <fprintf@plt>
jmp    12eb <main+0x11b>
mov    0x8(%rbx),%rdi
lea    0xd9e(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13c8 <main+0x1f8>
mov    0x8(%rbx),%rdi
lea    0xd88(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    12d3 <main+0x103>
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   10f0 <mjd_to_yday@plt>
jmp    1418 <main+0x248>
mov    0x8(%rbx),%rdi
lea    0xd58(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13da <main+0x20a>
lea    0xd8b(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb1(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ce6(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd10(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   10b0 <scanf@plt>
mov    0x4(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
call   1070 <date_to_mjd@plt>
jmp    1422 <main+0x252>
lea    0xcf4(%rip),%rdi
lea    0xcff(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd89(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc2(%rip),%rdi
call   1040 <puts@plt>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
lea    0xde2(%rip),%rdi
call   1040 <puts@plt>
lea    0xded(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf6(%rip),%rdi
call   1040 <puts@plt>
lea    0xdfe(%rip),%rdi
call   1040 <puts@plt>
jmp    1422 <main+0x252>
lea    0xc8a(%rip),%rdi
lea    0xc7c(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1422 <main+0x252>
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1050 <mjd_to_date@plt>
jmp    1418 <main+0x248>
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %eax,%edx
jmp    1413 <main+0x243>
mov    (%rax),%edi
mov    0x4(%rax),%esi
add    $0x1,%esi
mov    $0x76c,%edx
add    0x8(%rax),%edx
call   1070 <date_to_mjd@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%d %d %d\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c"-m\00"
@.str.4 = [3 x i8] c"-y\00"
@.str.5 = [3 x i8] c"-h\00"
@.str.6 = [18 x i8] c"\0Amjd version %s\0A\0A\00"
@.str.7 = [4 x i8] c"1.7\00"
@.str.8 = [57 x i8] c"usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-h] [-v]\0A\0A\00"
@.str.9 = [12 x i8] c"Options:-\0A\0A\00"
@.str.10 = [27 x i8] c"\09-d\09: convert date to MJD\0A\00"
@.str.11 = [27 x i8] c"\09-m\09: convert MJD to date\0A\00"
@.str.12 = [31 x i8] c"\09-y\09: convert MJD to DOY year\0A\00"
@.str.13 = [24 x i8] c"\09-t\09: show today's MJD\0A\00"
@.str.14 = [22 x i8] c"\09-h\09: show this help\0A\00"
@.str.15 = [21 x i8] c"\09-v\09: show version\0A\0A\00"
@.str.16 = [34 x i8] c"See also the man page for 'mjd'\0A\0A\00"
@.str.17 = [3 x i8] c"-v\00"
@.str.18 = [14 x i8] c"\0Aversion %s\0A\0A\00"
@.str.19 = [3 x i8] c"-t\00"
@stderr = global i32 0
@.str.20 = [18 x i8] c"gmtime() failed!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.21 = [51 x i8] c"mjd: invalid option or wrong number of parameters\0A\00"
@.str.22 = [61 x i8] c"usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-t] [-h] [-v]\0A\00"
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 i32
%10 = alloca i32
%11 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 @date_to_mjd(i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* @EXIT_SUCCESS
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 5
br i1 %24, label %25, label %51
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 %51
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* %6
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %7
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 4
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %8
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = call i32 @date_to_mjd(i32 %44, i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* @EXIT_SUCCESS
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %25, %22
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %70
54: ; preds = %51
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %70
60: ; preds = %54
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i32 @atoi(i8* %63)
store i32 %64, i32* %9
%65 = load i32, i32* %9
%66 = call i32 @mjd_to_date(i32 %65)
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%68 = load i32, i32* @EXIT_SUCCESS
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %54, %51
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 3
br i1 %72, label %73, label %89
73: ; preds = %70
%74 = load i8**, i8*** %5
%75 = getelementptr inbounds i8*, i8** %74, i64 1
%76 = load i8*, i8** %75
%77 = call i64 @strcmp(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%78 = icmp eq i64 %77, 0
br i1 %78, label %79, label %89
79: ; preds = %73
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 2
%82 = load i8*, i8** %81
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %9
%84 = load i32, i32* %9
%85 = call i32 @mjd_to_yday(i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%87 = load i32, i32* @EXIT_SUCCESS
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %73, %70
%90 = load i32, i32* %4
%91 = icmp eq i32 %90, 2
br i1 %91, label %92, label %111
92: ; preds = %89
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i64 @strcmp(i8* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %111
98: ; preds = %92
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.8, i64 0, i64 0))
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0))
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0))
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.15, i64 0, i64 0))
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.16, i64 0, i64 0))
%109 = load i32, i32* @EXIT_SUCCESS
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %92, %89
%112 = load i32, i32* %4
%113 = icmp eq i32 %112, 2
br i1 %113, label %114, label %124
114: ; preds = %111
%115 = load i8**, i8*** %5
%116 = getelementptr inbounds i8*, i8** %115, i64 1
%117 = load i8*, i8** %116
%118 = call i64 @strcmp(i8* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%119 = icmp eq i64 %118, 0
br i1 %119, label %120, label %124
120: ; preds = %114
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%122 = load i32, i32* @EXIT_SUCCESS
%123 = call i32 @exit(i32 %122)
unreachable
124: ; preds = %114, %111
%125 = load i32, i32* %4
%126 = icmp eq i32 %125, 2
br i1 %126, label %127, label %157
127: ; preds = %124
%128 = load i8**, i8*** %5
%129 = getelementptr inbounds i8*, i8** %128, i64 1
%130 = load i8*, i8** %129
%131 = call i64 @strcmp(i8* %130, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0))
%132 = icmp eq i64 %131, 0
br i1 %132, label %133, label %157
133: ; preds = %127
%134 = call i32 @time(i32* null)
store i32 %134, i32* %10
%135 = call %struct.tm* @gmtime(i32* %10)
store %struct.tm* %135, %struct.tm** %11
%136 = icmp ne %struct.tm* %135, null
br i1 %136, label %141, label %137
137: ; preds = %133
%138 = load i32, i32* @stderr
%139 = call i32 @fprintf(i32 %138, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.20, i64 0, i64 0))
%140 = load i32, i32* @EXIT_FAILURE
store i32 %140, i32* %3
br label %161
141: ; preds = %133
%142 = load %struct.tm*, %struct.tm** %11
%143 = getelementptr inbounds %struct.tm, %struct.tm* %142, i32 0, i32 0
%144 = load i32, i32* %143
%145 = load %struct.tm*, %struct.tm** %11
%146 = getelementptr inbounds %struct.tm, %struct.tm* %145, i32 0, i32 1
%147 = load i32, i32* %146
%148 = add nsw i32 %147, 1
%149 = load %struct.tm*, %struct.tm** %11
%150 = getelementptr inbounds %struct.tm, %struct.tm* %149, i32 0, i32 2
%151 = load i32, i32* %150
%152 = add nsw i32 %151, 1900
%153 = call i32 @date_to_mjd(i32 %144, i32 %148, i32 %152)
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%155 = load i32, i32* @EXIT_SUCCESS
%156 = call i32 @exit(i32 %155)
unreachable
157: ; preds = %127, %124
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.21, i64 0, i64 0))
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.22, i64 0, i64 0))
%160 = load i32, i32* @EXIT_FAILURE
store i32 %160, i32* %3
br label %161
161: ; preds = %157, %137
%162 = load i32, i32* %3
ret i32 %162
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [9 x i8] c"%d %d %d\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [3 x i8] c"-d\00"
@.str.3 = [3 x i8] c"-m\00"
@.str.4 = [3 x i8] c"-y\00"
@.str.5 = [3 x i8] c"-h\00"
@.str.6 = [18 x i8] c"\0Amjd version %s\0A\0A\00"
@.str.7 = [4 x i8] c"1.7\00"
@.str.17 = [3 x i8] c"-v\00"
@.str.18 = [14 x i8] c"\0Aversion %s\0A\0A\00"
@.str.19 = [3 x i8] c"-t\00"
@stderr = global i32 0
@.str.20 = [18 x i8] c"gmtime() failed!\0A\00"
@EXIT_FAILURE = global i32 0
@str = [50 x i8] c"mjd: invalid option or wrong number of parameters\00"
@str.23 = [60 x i8] c"usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-t] [-h] [-v]\00"
@str.24 = [56 x i8] c"usage: mjd [-d DD MM YYYY] [-m MJD] [-y MJD] [-h] [-v]\0A\00"
@str.25 = [11 x i8] c"Options:-\0A\00"
@str.26 = [26 x i8] c"\09-d\09: convert date to MJD\00"
@str.27 = [26 x i8] c"\09-m\09: convert MJD to date\00"
@str.28 = [30 x i8] c"\09-y\09: convert MJD to DOY year\00"
@str.29 = [23 x i8] c"\09-t\09: show today's MJD\00"
@str.30 = [21 x i8] c"\09-h\09: show this help\00"
@str.31 = [20 x i8] c"\09-v\09: show version\0A\00"
@str.32 = [33 x i8] c"See also the man page for 'mjd'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
switch i32 %0, label %113 [
i32 1, label %11
i32 5, label %19
i32 3, label %38
i32 2, label %63
]
11: ; preds = %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 @date_to_mjd(i32 %13, i32 %14, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %113
24: ; preds = %19
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
%31 = getelementptr inbounds i8*, i8** %1, i64 4
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
%34 = tail call i32 @date_to_mjd(i32 %27, i32 %30, i32 %33)
%35 = tail call i32 @putchar(i32 10)
%36 = load i32, i32* @EXIT_SUCCESS
%37 = tail call i32 @exit(i32 %36)
unreachable
38: ; preds = %2
%39 = getelementptr inbounds i8*, i8** %1, i64 1
%40 = load i8*, i8** %39
%41 = tail call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %38
%44 = getelementptr inbounds i8*, i8** %1, i64 2
%45 = load i8*, i8** %44
%46 = tail call i32 @atoi(i8* %45)
%47 = tail call i32 @mjd_to_date(i32 %46)
%48 = tail call i32 @putchar(i32 10)
%49 = load i32, i32* @EXIT_SUCCESS
%50 = tail call i32 @exit(i32 %49)
unreachable
51: ; preds = %38
%52 = load i8*, i8** %39
%53 = tail call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %113
55: ; preds = %51
%56 = getelementptr inbounds i8*, i8** %1, i64 2
%57 = load i8*, i8** %56
%58 = tail call i32 @atoi(i8* %57)
%59 = tail call i32 @mjd_to_yday(i32 %58)
%60 = tail call i32 @putchar(i32 10)
%61 = load i32, i32* @EXIT_SUCCESS
%62 = tail call i32 @exit(i32 %61)
unreachable
63: ; preds = %2
%64 = getelementptr inbounds i8*, i8** %1, i64 1
%65 = load i8*, i8** %64
%66 = tail call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %81
68: ; preds = %63
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%70 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.24, i64 0, i64 0))
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.25, i64 0, i64 0))
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.26, i64 0, i64 0))
%73 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.27, i64 0, i64 0))
%74 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.28, i64 0, i64 0))
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.29, i64 0, i64 0))
%76 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.30, i64 0, i64 0))
%77 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.31, i64 0, i64 0))
%78 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.32, i64 0, i64 0))
%79 = load i32, i32* @EXIT_SUCCESS
%80 = tail call i32 @exit(i32 %79)
unreachable
81: ; preds = %63
%82 = load i8*, i8** %64
%83 = tail call i64 @strcmp(i8* %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%84 = icmp eq i64 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %81
%86 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%87 = load i32, i32* @EXIT_SUCCESS
%88 = tail call i32 @exit(i32 %87)
unreachable
89: ; preds = %81
%90 = load i8*, i8** %64
%91 = tail call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.19, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %113
93: ; preds = %89
%94 = tail call i32 @time(i32* null)
store i32 %94, i32* %6
%95 = call %struct.tm* @gmtime(i32* %6)
%96 = icmp eq %struct.tm* %95, null
br i1 %96, label %97, label %100
97: ; preds = %93
%98 = load i32, i32* @stderr
%99 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.20, i64 0, i64 0))
br label %116
100: ; preds = %93
%101 = getelementptr inbounds %struct.tm, %struct.tm* %95, i64 0, i32 0
%102 = load i32, i32* %101
%103 = getelementptr inbounds %struct.tm, %struct.tm* %95, i64 0, i32 1
%104 = load i32, i32* %103
%105 = add nsw i32 %104, 1
%106 = getelementptr inbounds %struct.tm, %struct.tm* %95, i64 0, i32 2
%107 = load i32, i32* %106
%108 = add nsw i32 %107, 1900
%109 = call i32 @date_to_mjd(i32 %102, i32 %105, i32 %108)
%110 = call i32 @putchar(i32 10)
%111 = load i32, i32* @EXIT_SUCCESS
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %2, %19, %51, %89
%114 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%115 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.23, i64 0, i64 0))
br label %116
116: ; preds = %113, %97
%117 = load i32, i32* @EXIT_FAILURE
ret i32 %117
}