#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 scalar_t__ time_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ localtime(scalar_t__ *);
scalar_t__ parsetime(char *);
double potm(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
scalar_t__ time(scalar_t__ *);
int main(int argc, char *argv[]) {
  time_t tmpt, now;
  double days, today, tomorrow;
  char buf[1024];
  if (time(&now) == (time_t)-1)
    err(1, "time");
  if (argc > 1) {
    tmpt = parsetime(argv[1]);
    strftime(buf, sizeof(buf), "%a %Y %b %e %H:%M:%S (%Z)", localtime(&tmpt));
    printf("%s:  ", buf);
  } else {
    tmpt = now;
  }
  days = (tmpt - (20 * 365 + 5 - 1) * 86400) / 86400.0;
  today = potm(days) + .5;
  if (tmpt < now)
    (void)printf("The Moon was ");
  else if (tmpt == now)
    (void)printf("The Moon is ");
  else
    (void)printf("The Moon will be ");
  if ((int)today == 100)
    (void)printf("Full\n");
  else if (!(int)today)
    (void)printf("New\n");
  else {
    tomorrow = potm(days + 1);
    if ((int)today == 50)
      (void)printf("%s\n", tomorrow > today ? "at the First Quarter"
                                            : "at the Last Quarter");
    else {
      today -= 0.5;
      (void)printf("%s ", tomorrow > today ? "Waxing" : "Waning");
      if (today > 50)
        (void)printf("Gibbous (%1.0f%% of Full)\n", today);
      else if (today < 50)
        (void)printf("Crescent (%1.0f%% of Full)\n", today);
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <time@plt>
cmp    $0xffffffffffffffff,%rax
jne    11ad <main+0x3d>
mov    $0x1,%edi
lea    0xe78(%rip),%rsi
call   1070 <err@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1213 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <parsetime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x448(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x448(%rbp),%rdi
mov    %eax,%ecx
mov    $0x400,%esi
lea    0xe31(%rip),%rdx
call   1090 <strftime@plt>
lea    -0x440(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121b <main+0xab>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x259d4c00,%rax
cvtsi2sd %rax,%xmm0
movsd  0xdd6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <potm@plt>
movsd  0xdb3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1277 <main+0x107>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ab <main+0x13b>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1298 <main+0x128>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a6 <main+0x136>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ab <main+0x13b>
cvttsd2si -0x30(%rbp),%eax
cmp    $0x64,%eax
jne    12cc <main+0x15c>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f2 <main+0x282>
cvttsd2si -0x30(%rbp),%eax
cmp    $0x0,%eax
jne    12ed <main+0x17d>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13ed <main+0x27d>
movsd  0xd1b(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1050 <potm@plt>
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x30(%rbp),%eax
cmp    $0x32,%eax
jne    1345 <main+0x1d5>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xd73(%rip),%rsi
lea    0xd57(%rip),%rax
ucomisd %xmm1,%xmm0
cmova  %rax,%rsi
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13e8 <main+0x278>
movsd  -0x30(%rbp),%xmm0
movsd  0xcae(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xd49(%rip),%rsi
lea    0xd3b(%rip),%rax
ucomisd %xmm1,%xmm0
cmova  %rax,%rsi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
movsd  0xc82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    13b8 <main+0x248>
movsd  -0x30(%rbp),%xmm0
lea    0xd10(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13e3 <main+0x273>
movsd  0xc58(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    13de <main+0x26e>
movsd  -0x30(%rbp),%xmm0
lea    0xd00(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    13e3 <main+0x273>
jmp    13e8 <main+0x278>
jmp    13ed <main+0x27d>
jmp    13f2 <main+0x282>
mov    0x2be7(%rip),%rax
mov    (%rax),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x428,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
call   1070 <time@plt>
cmp    $0xffffffffffffffff,%rax
je     11ee <main+0x6e>
cmp    $0x2,%ebp
jl     1204 <main+0x84>
mov    0x8(%rbx),%rdi
call   1090 <parsetime@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe6b(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %eax,%ecx
call   10a0 <strftime@plt>
lea    0xe6a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rax
jmp    120e <main+0x8e>
lea    0xe33(%rip),%rsi
mov    $0x1,%edi
call   1080 <err@plt>
cmp    $0x2,%ebp
jge    11a3 <main+0x23>
mov    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
add    $0xffffffffda62b400,%rax
cvtsi2sd %rax,%xmm0
divsd  0xddf(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1060 <potm@plt>
addsd  0xdd4(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    0x8(%rsp),%rax
cmp    0x10(%rsp),%rax
lea    0xe11(%rip),%rax
lea    0xe17(%rip),%rcx
cmove  %rax,%rcx
lea    0xdf1(%rip),%rdi
cmovge %rcx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
je     128a <main+0x10a>
cmp    $0x64,%ebx
jne    129b <main+0x11b>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
jmp    1343 <main+0x1c3>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
jmp    1343 <main+0x1c3>
movsd  0x18(%rsp),%xmm0
addsd  0xd67(%rip),%xmm0
call   1060 <potm@plt>
cmp    $0x32,%ebx
jne    12d1 <main+0x151>
ucomisd (%rsp),%xmm0
lea    0xdbb(%rip),%rax
lea    0xdc9(%rip),%rdi
cmova  %rax,%rdi
call   1040 <puts@plt>
jmp    1343 <main+0x1c3>
movsd  (%rsp),%xmm1
addsd  0xd3a(%rip),%xmm1
movsd  %xmm1,(%rsp)
ucomisd %xmm1,%xmm0
lea    0xdb9(%rip),%rax
lea    0xdb9(%rip),%rsi
cmova  %rax,%rsi
lea    0xda3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xd0c(%rip),%xmm0
jbe    131f <main+0x19f>
lea    0xd98(%rip),%rdi
jmp    133c <main+0x1bc>
movapd %xmm0,%xmm1
movsd  0xcf5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1343 <main+0x1c3>
movapd %xmm1,%xmm0
lea    0xd94(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%eax
add    $0x428,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"time\00"
@.str.1 = [26 x i8] c"%a %Y %b %e %H:%M:%S (%Z)\00"
@.str.2 = [6 x i8] c"%s: \00"
@.str.3 = [14 x i8] c"The Moon was \00"
@.str.4 = [13 x i8] c"The Moon is \00"
@.str.5 = [18 x i8] c"The Moon will be \00"
@.str.6 = [6 x i8] c"Full\0A\00"
@.str.7 = [5 x i8] c"New\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@.str.9 = [21 x i8] c"at the First Quarter\00"
@.str.10 = [20 x i8] c"at the Last Quarter\00"
@.str.11 = [4 x i8] c"%s \00"
@.str.12 = [7 x i8] c"Waxing\00"
@.str.13 = [7 x i8] c"Waning\00"
@.str.14 = [27 x i8] c"Gibbous (%1.0f%% of Full)\0A\00"
@.str.15 = [28 x i8] c"Crescent (%1.0f%% of Full)\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 i64
%7 = alloca i64
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i64 @time(i64* %7)
%13 = icmp eq i64 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %2
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @parsetime(i8* %22)
store i64 %23, i64* %6
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%25 = call i32 @localtime(i64* %6)
%26 = call i32 @strftime(i8* %24, i32 1024, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %31
29: ; preds = %16
%30 = load i64, i64* %7
store i64 %30, i64* %6
br label %31
31: ; preds = %29, %19
%32 = load i64, i64* %6
%33 = sub nsw i64 %32, 631065600
%34 = sitofp i64 %33 to double
%35 = fdiv double %34, 8.640000e+04
store double %35, double* %8
%36 = load double, double* %8
%37 = call double @potm(double %36)
%38 = fadd double %37, 5.000000e-01
store double %38, double* %9
%39 = load i64, i64* %6
%40 = load i64, i64* %7
%41 = icmp slt i64 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %31
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %53
44: ; preds = %31
%45 = load i64, i64* %6
%46 = load i64, i64* %7
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %52
50: ; preds = %44
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
br label %53
53: ; preds = %52, %42
%54 = load double, double* %9
%55 = fptosi double %54 to i32
%56 = icmp eq i32 %55, 100
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %103
59: ; preds = %53
%60 = load double, double* %9
%61 = fptosi double %60 to i32
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %102
65: ; preds = %59
%66 = load double, double* %8
%67 = fadd double %66, 1.000000e+00
%68 = call double @potm(double %67)
store double %68, double* %10
%69 = load double, double* %9
%70 = fptosi double %69 to i32
%71 = icmp eq i32 %70, 50
br i1 %71, label %72, label %79
72: ; preds = %65
%73 = load double, double* %10
%74 = load double, double* %9
%75 = fcmp ogt double %73, %74
%76 = zext i1 %75 to i64
%77 = select i1 %75, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0)
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %77)
br label %101
79: ; preds = %65
%80 = load double, double* %9
%81 = fsub double %80, 5.000000e-01
store double %81, double* %9
%82 = load double, double* %10
%83 = load double, double* %9
%84 = fcmp ogt double %82, %83
%85 = zext i1 %84 to i64
%86 = select i1 %84, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %86)
%88 = load double, double* %9
%89 = fcmp ogt double %88, 5.000000e+01
br i1 %89, label %90, label %93
90: ; preds = %79
%91 = load double, double* %9
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %91)
br label %100
93: ; preds = %79
%94 = load double, double* %9
%95 = fcmp olt double %94, 5.000000e+01
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load double, double* %9
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), double %97)
br label %99
99: ; preds = %96, %93
br label %100
100: ; preds = %99, %90
br label %101
101: ; preds = %100, %72
br label %102
102: ; preds = %101, %63
br label %103
103: ; preds = %102, %57
%104 = load i32, i32* @EXIT_SUCCESS
ret i32 %104
}

LLVM IR (-O2):
@.str = [5 x i8] c"time\00"
@.str.1 = [26 x i8] c"%a %Y %b %e %H:%M:%S (%Z)\00"
@.str.2 = [6 x i8] c"%s: \00"
@.str.3 = [14 x i8] c"The Moon was \00"
@.str.4 = [13 x i8] c"The Moon is \00"
@.str.5 = [18 x i8] c"The Moon will be \00"
@.str.9 = [21 x i8] c"at the First Quarter\00"
@.str.10 = [20 x i8] c"at the Last Quarter\00"
@.str.11 = [4 x i8] c"%s \00"
@.str.12 = [7 x i8] c"Waxing\00"
@.str.13 = [7 x i8] c"Waning\00"
@.str.14 = [27 x i8] c"Gibbous (%1.0f%% of Full)\0A\00"
@.str.15 = [28 x i8] c"Crescent (%1.0f%% of Full)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [4 x i8] c"New\00"
@str.16 = [5 x i8] c"Full\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca [1024 x i8]
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i64 @time(i64* %4)
%10 = icmp eq i64 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = icmp sgt i32 %0, 1
br i1 %14, label %15, label %23
15: ; preds = %13
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @parsetime(i8* %17)
store i64 %18, i64* %3
%19 = call i32 @localtime(i64* %3)
%20 = call i32 @strftime(i8* %8, i32 1024, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%22 = load i64, i64* %3
br label %25
23: ; preds = %13
%24 = load i64, i64* %4
store i64 %24, i64* %3
br label %25
25: ; preds = %23, %15
%26 = phi i64 [ %24, %23 ], [ %22, %15 ]
%27 = add nsw i64 %26, -631065600
%28 = sitofp i64 %27 to double
%29 = fdiv double %28, 8.640000e+04
%30 = call double @potm(double %29)
%31 = fadd double %30, 5.000000e-01
%32 = load i64, i64* %3
%33 = load i64, i64* %4
%34 = icmp slt i64 %32, %33
%35 = icmp eq i64 %32, %33
%36 = select i1 %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0)
%37 = select i1 %34, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %37)
%39 = fptosi double %31 to i32
switch i32 %39, label %44 [
i32 100, label %40
i32 0, label %42
]
40: ; preds = %25
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.16, i64 0, i64 0))
br label %64
42: ; preds = %25
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %64
44: ; preds = %25
%45 = fadd double %29, 1.000000e+00
%46 = call double @potm(double %45)
%47 = icmp eq i32 %39, 50
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = fcmp ogt double %46, %31
%50 = select i1 %49, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0)
%51 = call i32 @puts(i8* dereferenceable(1) %50)
br label %64
52: ; preds = %44
%53 = fadd double %31, -5.000000e-01
%54 = fcmp ogt double %46, %53
%55 = select i1 %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i8* %55)
%57 = fcmp ogt double %53, 5.000000e+01
br i1 %57, label %58, label %60
58: ; preds = %52
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.14, i64 0, i64 0), double %53)
br label %64
60: ; preds = %52
%61 = fcmp olt double %53, 5.000000e+01
br i1 %61, label %62, label %64
62: ; preds = %60
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), double %53)
br label %64
64: ; preds = %42, %58, %62, %60, %48, %40
%65 = load i32, i32* @EXIT_SUCCESS
ret i32 %65
}