#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 */
double atof(char *);
int /*<<< orphan*/ calendar2stardate(char *, double *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stardate2calendar(double, char **);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ time2stardate(int /*<<< orphan*/, double *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  int rc = 0;
  double stardate = 0.0;
  char *action = NULL, *calendar = NULL;
  if (argc > 1) {
    action = argv[1];
    if (strcmp(action, "-h") == 0 || strcmp(action, "--help") == 0) {
      usage(argv[0]);
      rc = 1;
      goto cleanup;
    }
    if (argc > 2) {
      if (strcmp(action, "-s") == 0 || strcmp(action, "--stardate") == 0) {
        stardate = atof(argv[2]);
        stardate2calendar(stardate, &calendar);
        printf("%s\n", calendar);
      } else if (strcmp(action, "-c") == 0 ||
                 strcmp(action, "--calendar") == 0) {
        calendar = malloc(sizeof(char) * strlen(argv[2]) + 1);
        strcpy(calendar, argv[2]);
        calendar2stardate(calendar, &stardate);
        printf("%.2f\n", stardate);
      } else {
        printf("Unknown action %s\n", action);
        rc = 1;
        goto cleanup;
      }
    } else {
      printf("Unknown action %s\n", action);
      rc = 1;
      goto cleanup;
    }
  } else {
    time2stardate(time(0), &stardate);
    printf("%.2f\n", stardate);
  }
cleanup:
  if (calendar) {
    free(calendar);
  }
  return rc;
}


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)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    13a3 <main+0x1e3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     123f <main+0x7f>
mov    -0x28(%rbp),%rdi
lea    0xdd3(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1257 <main+0x97>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10d0 <usage@plt>
movl   $0x1,-0x14(%rbp)
jmp    13cd <main+0x20d>
cmpl   $0x2,-0x8(%rbp)
jle    1380 <main+0x1c0>
mov    -0x28(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1295 <main+0xd5>
mov    -0x28(%rbp),%rdi
lea    0xd87(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12cc <main+0x10c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
call   10e0 <stardate2calendar@plt>
mov    -0x30(%rbp),%rsi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    137b <main+0x1bb>
mov    -0x28(%rbp),%rdi
lea    0xd41(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1300 <main+0x140>
mov    -0x28(%rbp),%rdi
lea    0xd2a(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1358 <main+0x198>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <strlen@plt>
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1050 <strcpy@plt>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <calendar2stardate@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xcda(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
jmp    1376 <main+0x1b6>
mov    -0x28(%rbp),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    13cd <main+0x20d>
jmp    137b <main+0x1bb>
jmp    139e <main+0x1de>
mov    -0x28(%rbp),%rsi
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    13cd <main+0x20d>
jmp    13c8 <main+0x208>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1070 <time2stardate@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xc65(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
jmp    13cd <main+0x20d>
cmpq   $0x0,-0x30(%rbp)
je     13e1 <main+0x221>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jl     129b <main+0xcb>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%r14
lea    0xdfe(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12c3 <main+0xf3>
lea    0xde9(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12c3 <main+0xf3>
cmp    $0x3,%ebp
jb     1288 <main+0xb8>
lea    0xdd3(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12db <main+0x10b>
lea    0xdbe(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     12db <main+0x10b>
lea    0xdb5(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1304 <main+0x134>
lea    0xda0(%rip),%rsi
mov    %r14,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1304 <main+0x134>
lea    0xd9d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    12cb <main+0xfb>
xor    %ebx,%ebx
xor    %edi,%edi
call   10c0 <time@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1080 <time2stardate@plt>
movsd  (%rsp),%xmm0
lea    0xd6c(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
jmp    12d0 <main+0x100>
mov    (%rbx),%rdi
call   10e0 <usage@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x10(%rbx),%rdi
call   1070 <atof@plt>
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rdi
call   10f0 <stardate2calendar@plt>
mov    0x8(%rsp),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%r14
jmp    1347 <main+0x177>
mov    0x10(%rbx),%rdi
call   1090 <strlen@plt>
lea    0x1(%rax),%edi
call   10d0 <malloc@plt>
mov    %rax,%r14
mov    %rax,0x8(%rsp)
mov    0x10(%rbx),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <calendar2stardate@plt>
movsd  (%rsp),%xmm0
lea    0xce6(%rip),%rdi
mov    $0x1,%al
call   10a0 <printf@plt>
xor    %ebx,%ebx
test   %r14,%r14
je     12d0 <main+0x100>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    12d0 <main+0x100>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [11 x i8] c"--stardate\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [11 x i8] c"--calendar\00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [19 x i8] c"Unknown action %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store double 0.000000e+00, double* %7
store i8* null, i8** %8
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %84
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %12
%20 = load i8*, i8** %8
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19, %12
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @usage(i8* %26)
store i32 1, i32* %6
br label %90
28: ; preds = %19
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %80
31: ; preds = %28
%32 = load i8*, i8** %8
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %35, %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call double @atof(i8* %42)
store double %43, double* %7
%44 = load double, double* %7
%45 = call i32 @stardate2calendar(double %44, i8** %9)
%46 = load i8*, i8** %9
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %46)
br label %79
48: ; preds = %35
%49 = load i8*, i8** %8
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i8*, i8** %8
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %75
56: ; preds = %52, %48
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = sext i32 %60 to i64
%62 = mul i64 1, %61
%63 = add i64 %62, 1
%64 = trunc i64 %63 to i32
%65 = call i8* @malloc(i32 %64)
store i8* %65, i8** %9
%66 = load i8*, i8** %9
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i32 @strcpy(i8* %66, i8* %69)
%71 = load i8*, i8** %9
%72 = call i32 @calendar2stardate(i8* %71, double* %7)
%73 = load double, double* %7
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %73)
br label %78
75: ; preds = %52
%76 = load i8*, i8** %8
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %76)
store i32 1, i32* %6
br label %90
78: ; preds = %56
br label %79
79: ; preds = %78, %39
br label %83
80: ; preds = %28
%81 = load i8*, i8** %8
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %81)
store i32 1, i32* %6
br label %90
83: ; preds = %79
br label %89
84: ; preds = %2
%85 = call i32 @time(i32 0)
%86 = call i32 @time2stardate(i32 %85, double* %7)
%87 = load double, double* %7
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %87)
br label %89
89: ; preds = %84, %83
br label %90
90: ; preds = %89, %80, %75, %23
%91 = load i8*, i8** %9
%92 = icmp ne i8* %91, null
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i8*, i8** %9
%95 = call i32 @free(i8* %94)
br label %96
96: ; preds = %93, %90
%97 = load i32, i32* %6
ret i32 %97
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [3 x i8] c"-s\00"
@.str.3 = [11 x i8] c"--stardate\00"
@.str.5 = [3 x i8] c"-c\00"
@.str.6 = [11 x i8] c"--calendar\00"
@.str.7 = [6 x i8] c"%.2f\0A\00"
@.str.8 = [19 x i8] c"Unknown action %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca i8*
%5 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %56
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13, %8
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %66
19: ; preds = %13
%20 = icmp ugt i32 %0, 2
br i1 %20, label %21, label %54
21: ; preds = %19
%22 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %24, %21
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call double @atof(i8* %29)
store double %30, double* %3
%31 = call i32 @stardate2calendar(double %30, i8** %4)
%32 = load i8*, i8** %4
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = load i8*, i8** %4
br label %61
35: ; preds = %24
%36 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %52
41: ; preds = %38, %35
%42 = getelementptr inbounds i8*, i8** %1, i64 2
%43 = load i8*, i8** %42
%44 = tail call i32 @strlen(i8* %43)
%45 = add i32 %44, 1
%46 = tail call i8* @malloc(i32 %45)
store i8* %46, i8** %4
%47 = load i8*, i8** %42
%48 = tail call i32 @strcpy(i8* %46, i8* %47)
%49 = call i32 @calendar2stardate(i8* %46, double* %3)
%50 = load double, double* %3
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %50)
br label %61
52: ; preds = %38
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %66
54: ; preds = %19
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %66
56: ; preds = %2
%57 = tail call i32 @time(i32 0)
%58 = call i32 @time2stardate(i32 %57, double* %3)
%59 = load double, double* %3
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), double %59)
br label %66
61: ; preds = %27, %41
%62 = phi i8* [ %34, %27 ], [ %46, %41 ]
%63 = icmp eq i8* %62, null
br i1 %63, label %66, label %64
64: ; preds = %61
%65 = call i32 @free(i8* %62)
br label %66
66: ; preds = %56, %54, %52, %16, %64, %61
%67 = phi i32 [ 0, %64 ], [ 0, %61 ], [ 0, %56 ], [ 1, %54 ], [ 1, %52 ], [ 1, %16 ]
ret i32 %67
}