#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*/ findnewmoons(double *, int, double);
double g2jd(int, int, double);
int /*<<< orphan*/ jdftime(char *, double, char *, double, int);
int /*<<< orphan*/ printf(char *, ...);
double solarterm(int, double);
void testnewmoon_solarterm(void) {
  double newmoons[15];
  double jd;
  int year = 2000;
  int n;
  char isodt[30];
  int i;
  for (n = 0; n < 50; n++) {
    jd = g2jd(year, 1, 1.0);
    findnewmoons(newmoons, 15, jd);
    year += 1;
    for (i = 0; i < 15; i++) {
      jdftime(isodt, newmoons[i], "%y-%m-%d %H:%M:%S", 8.0, 1);
      printf("found newmoon: %s %.8f\n", isodt, newmoons[i]);
    }
  }
  double angle;
  for (angle = -90; angle < 285; angle += 15) {
    jd = solarterm(2014, angle);
    jdftime(isodt, jd, "%y-%m-%d %H:%M:%S", 8.0, 1);
    printf("solar term: %3.0f %s\n", angle, isodt);
  }
  return;
}


x86 assembly (clang, -O0):
<testnewmoon_solarterm>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x7d0,-0x8c(%rbp)
movl   $0x0,-0x90(%rbp)
cmpl   $0x32,-0x90(%rbp)
jge    1254 <testnewmoon_solarterm+0x104>
mov    -0x8c(%rbp),%edi
mov    $0x1,%esi
movsd  0xe91(%rip),%xmm0
call   1040 <g2jd@plt>
movsd  %xmm0,-0x88(%rbp)
ff
lea    -0x80(%rbp),%rdi
movsd  -0x88(%rbp),%xmm0
ff
mov    $0xf,%esi
call   1070 <findnewmoons@plt>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0xf,-0xb4(%rbp)
jge    123b <testnewmoon_solarterm+0xeb>
lea    -0xb0(%rbp),%rdi
movslq -0xb4(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
lea    0xe35(%rip),%rsi
movsd  0xe15(%rip),%xmm1
mov    $0x1,%edx
call   1060 <jdftime@plt>
lea    -0xb0(%rbp),%rsi
movslq -0xb4(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
lea    0xe1a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    11cb <testnewmoon_solarterm+0x7b>
jmp    1240 <testnewmoon_solarterm+0xf0>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    116f <testnewmoon_solarterm+0x1f>
movsd  0xda4(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xd9c(%rip),%xmm0
ucomisd -0xc0(%rbp),%xmm0
ff
jbe    12f6 <testnewmoon_solarterm+0x1a6>
movsd  -0xc0(%rbp),%xmm0
ff
mov    $0x7de,%edi
call   1050 <solarterm@plt>
movsd  %xmm0,-0x88(%rbp)
ff
lea    -0xb0(%rbp),%rdi
movsd  -0x88(%rbp),%xmm0
ff
lea    0xd7e(%rip),%rsi
movsd  0xd5e(%rip),%xmm1
mov    $0x1,%edx
call   1060 <jdftime@plt>
movsd  -0xc0(%rbp),%xmm0
ff
lea    -0xb0(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xd37(%rip),%xmm0
addsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    1264 <testnewmoon_solarterm+0x114>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testnewmoon_solarterm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    $0x7d0,%r15d
lea    0x30(%rsp),%r14
lea    0xead(%rip),%r12
lea    0x10(%rsp),%rbp
lea    0xeb3(%rip),%r13
nop
mov    %r15d,%edi
mov    $0x1,%esi
movsd  0xe70(%rip),%xmm0
call   1040 <g2jd@plt>
mov    %r14,%rdi
mov    $0xf,%esi
call   1070 <findnewmoons@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x30(%rsp,%rbx,8),%xmm0
mov    %rbp,%rdi
mov    %r12,%rsi
movsd  0xe44(%rip),%xmm1
mov    $0x1,%edx
call   1060 <jdftime@plt>
movsd  0x30(%rsp,%rbx,8),%xmm0
mov    %r13,%rdi
mov    %rbp,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0xf,%rbx
jne    11b0 <testnewmoon_solarterm+0x60>
add    $0x1,%r15d
cmp    $0x802,%r15d
jne    1180 <testnewmoon_solarterm+0x30>
movsd  0xe10(%rip),%xmm0
mov    $0xffffff97,%ebx
lea    0xe14(%rip),%r14
lea    0x10(%rsp),%rbp
lea    0xe32(%rip),%r15
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
mov    $0x7de,%edi
movsd  0x8(%rsp),%xmm0
call   1050 <solarterm@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
movsd  0xdc4(%rip),%xmm1
mov    $0x1,%edx
call   1060 <jdftime@plt>
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
mov    %rbp,%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xda9(%rip),%xmm0
add    $0xf,%ebx
cmp    $0x10e,%ebx
jl     1220 <testnewmoon_solarterm+0xd0>
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%y-%m-%d %H:%M:%S\00"
@.str.1 = [24 x i8] c"found newmoon: %s %.8f\0A\00"
@.str.2 = [22 x i8] c"solar term: %3.0f %s\0A\00"
define void @testnewmoon_solarterm() {
%1 = alloca [15 x double]
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca [30 x i8]
%6 = alloca i32
%7 = alloca double
store i32 2000, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %39, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 50
br i1 %10, label %11, label %42
11: ; preds = %8
%12 = load i32, i32* %3
%13 = call double @g2jd(i32 %12, i32 1, double 1.000000e+00)
store double %13, double* %2
%14 = getelementptr inbounds [15 x double], [15 x double]* %1, i64 0, i64 0
%15 = load double, double* %2
%16 = call i32 @findnewmoons(double* %14, i32 15, double %15)
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
store i32 0, i32* %6
br label %19
19: ; preds = %35, %11
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 15
br i1 %21, label %22, label %38
22: ; preds = %19
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [15 x double], [15 x double]* %1, i64 0, i64 %25
%27 = load double, double* %26
%28 = call i32 @jdftime(i8* %23, double %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double 8.000000e+00, i32 1)
%29 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [15 x double], [15 x double]* %1, i64 0, i64 %31
%33 = load double, double* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %29, double %33)
br label %35
35: ; preds = %22
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %19
38: ; preds = %19
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %8
42: ; preds = %8
store double -9.000000e+01, double* %7
br label %43
43: ; preds = %55, %42
%44 = load double, double* %7
%45 = fcmp olt double %44, 2.850000e+02
br i1 %45, label %46, label %58
46: ; preds = %43
%47 = load double, double* %7
%48 = call double @solarterm(i32 2014, double %47)
store double %48, double* %2
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%50 = load double, double* %2
%51 = call i32 @jdftime(i8* %49, double %50, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double 8.000000e+00, i32 1)
%52 = load double, double* %7
%53 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %52, i8* %53)
br label %55
55: ; preds = %46
%56 = load double, double* %7
%57 = fadd double %56, 1.500000e+01
store double %57, double* %7
br label %43
58: ; preds = %43
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%y-%m-%d %H:%M:%S\00"
@.str.1 = [24 x i8] c"found newmoon: %s %.8f\0A\00"
@.str.2 = [22 x i8] c"solar term: %3.0f %s\0A\00"
define void @testnewmoon_solarterm() {
%1 = alloca [15 x double]
%2 = alloca [30 x i8]
%3 = bitcast [15 x double]* %1 to i8*
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [15 x double], [15 x double]* %1, i64 0, i64 0
br label %6
6: ; preds = %0, %19
%7 = phi i32 [ 2000, %0 ], [ %20, %19 ]
%8 = call double @g2jd(i32 %7, i32 1, double 1.000000e+00)
%9 = call i32 @findnewmoons(double* %5, i32 15, double %8)
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %17, %10 ]
%12 = getelementptr inbounds [15 x double], [15 x double]* %1, i64 0, i64 %11
%13 = load double, double* %12
%14 = call i32 @jdftime(i8* %4, double %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double 8.000000e+00, i32 1)
%15 = load double, double* %12
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %4, double %15)
%17 = add nuw nsw i64 %11, 1
%18 = icmp eq i64 %17, 15
br i1 %18, label %19, label %10
19: ; preds = %10
%20 = add nuw nsw i32 %7, 1
%21 = icmp eq i32 %20, 2050
br i1 %21, label %22, label %6
22: ; preds = %19, %22
%23 = phi i32 [ %28, %22 ], [ -90, %19 ]
%24 = sitofp i32 %23 to double
%25 = call double @solarterm(i32 2014, double %24)
%26 = call i32 @jdftime(i8* %4, double %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double 8.000000e+00, i32 1)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), double %24, i8* %4)
%28 = add nsw i32 %23, 15
%29 = icmp slt i32 %23, 270
br i1 %29, label %22, label %30
30: ; preds = %22
ret void
}