#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 */
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ JDtoDate(double, struct tm *);
double moonphasebylunation(int, int);
int /*<<< orphan*/ print_lunation(int, struct tm *);
int main(void) {
  int lun;
  int phi;
  double JDE;
  struct tm event_date[4];
  for (lun = (-19999); lun <= (19999); lun++) {
    for (phi = 0; phi <= 3; phi++) {
      JDE = moonphasebylunation(lun - 953, phi);
      JDtoDate(JDE, &event_date[phi]);
    }
    print_lunation(lun, event_date);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffb1e1,-0x8(%rbp)
cmpl   $0x4e1f,-0x8(%rbp)
jg     11bb <main+0x8b>
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     11a1 <main+0x71>
mov    -0x8(%rbp),%edi
sub    $0x3b9,%edi
mov    -0xc(%rbp),%esi
call   1030 <moonphasebylunation@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movslq -0xc(%rbp),%rax
lea    -0x30(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <JDtoDate@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <main+0x2a>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1040 <print_lunation@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r15
mov    $0xffffb1e1,%ebx
lea    0xc(%rsp),%r12
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x3b9(%rbx),%ebp
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <moonphasebylunation@plt>
mov    %r13,%rdi
call   1050 <JDtoDate@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <moonphasebylunation@plt>
mov    %r14,%rdi
call   1050 <JDtoDate@plt>
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <moonphasebylunation@plt>
mov    %r15,%rdi
call   1050 <JDtoDate@plt>
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <moonphasebylunation@plt>
mov    %r12,%rdi
call   1050 <JDtoDate@plt>
mov    %ebx,%edi
mov    %r13,%rsi
call   1040 <print_lunation@plt>
add    $0x1,%ebx
cmp    $0x4e20,%ebx
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca [4 x %struct.tm]
store i32 0, i32* %1
store i32 -19999, i32* %2
br label %6
6: ; preds = %30, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 19999
br i1 %8, label %9, label %33
9: ; preds = %6
store i32 0, i32* %3
br label %10
10: ; preds = %23, %9
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 3
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 953
%16 = load i32, i32* %3
%17 = call double @moonphasebylunation(i32 %15, i32 %16)
store double %17, double* %4
%18 = load double, double* %4
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %5, i64 0, i64 %20
%22 = call i32 @JDtoDate(double %18, %struct.tm* %21)
br label %23
23: ; preds = %13
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
%27 = load i32, i32* %2
%28 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %5, i64 0, i64 0
%29 = call i32 @print_lunation(i32 %27, %struct.tm* %28)
br label %30
30: ; preds = %26
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %6
33: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @main() {
%1 = alloca [4 x %struct.tm]
%2 = bitcast [4 x %struct.tm]* %1 to i8*
%3 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %1, i64 0, i64 0
%4 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %1, i64 0, i64 1
%5 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %1, i64 0, i64 2
%6 = getelementptr inbounds [4 x %struct.tm], [4 x %struct.tm]* %1, i64 0, i64 3
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ -19999, %0 ], [ %19, %7 ]
%9 = add nsw i32 %8, -953
%10 = call double @moonphasebylunation(i32 %9, i32 0)
%11 = call i32 @JDtoDate(double %10, %struct.tm* %3)
%12 = call double @moonphasebylunation(i32 %9, i32 1)
%13 = call i32 @JDtoDate(double %12, %struct.tm* %4)
%14 = call double @moonphasebylunation(i32 %9, i32 2)
%15 = call i32 @JDtoDate(double %14, %struct.tm* %5)
%16 = call double @moonphasebylunation(i32 %9, i32 3)
%17 = call i32 @JDtoDate(double %16, %struct.tm* %6)
%18 = call i32 @print_lunation(i32 %8, %struct.tm* %3)
%19 = add nsw i32 %8, 1
%20 = icmp eq i32 %19, 20000
br i1 %20, label %21, label %7
21: ; preds = %7
ret i32 0
}