#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 CalculateJulianDay(int, int, int, int, int /*<<< orphan*/, double);
scalar_t__ ceil(double);
double GetInitialEstimateSolarTerms(int year, int angle) {
  int STMonth = (int)ceil((double)(angle + 90.0) / 30.0);
  STMonth = STMonth > 12 ? STMonth - 12 : STMonth;
  if ((angle % 15 == 0) && (angle % 30 != 0)) {
    return CalculateJulianDay(year, STMonth, 6, 12, 0, 0.00);
  } else {
    return CalculateJulianDay(year, STMonth, 20, 12, 0, 0.00);
  }
}


x86 assembly (clang, -O0):
<GetInitialEstimateSolarTerms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xecd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jle    116b <GetInitialEstimateSolarTerms+0x4b>
mov    -0x14(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <GetInitialEstimateSolarTerms+0x51>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c4 <GetInitialEstimateSolarTerms+0xa4>
mov    -0x10(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11c4 <GetInitialEstimateSolarTerms+0xa4>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x6,%edx
mov    $0xc,%ecx
xor    %r8d,%r8d
xorps  %xmm0,%xmm0
call   1040 <CalculateJulianDay@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11e4 <GetInitialEstimateSolarTerms+0xc4>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x14,%edx
mov    $0xc,%ecx
xor    %r8d,%r8d
xorps  %xmm0,%xmm0
call   1040 <CalculateJulianDay@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetInitialEstimateSolarTerms>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
cvtsi2sd %esi,%xmm0
addsd  0xecd(%rip),%xmm0
divsd  0xecd(%rip),%xmm0
call   1030 <ceil@plt>
lea    -0xc(%rax),%esi
cmp    $0xd,%eax
cmovl  %eax,%esi
imul   $0xeeeeeeef,%ebp,%eax
add    $0x8888888,%eax
mov    %eax,%ecx
ror    %ecx
cmp    $0x8888889,%ecx
mov    $0x14,%ecx
mov    $0x6,%edx
cmovb  %ecx,%edx
cmp    $0x11111111,%eax
cmovae %ecx,%edx
xorpd  %xmm0,%xmm0
mov    %ebx,%edi
mov    $0xc,%ecx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <CalculateJulianDay@plt>

LLVM IR (-O0):
define double @GetInitialEstimateSolarTerms(i32 %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = sitofp i32 %7 to double
%9 = fadd double %8, 9.000000e+01
%10 = fdiv double %9, 3.000000e+01
%11 = call i64 @ceil(double %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, 12
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 12
br label %20
18: ; preds = %2
%19 = load i32, i32* %6
br label %20
20: ; preds = %18, %15
%21 = phi i32 [ %17, %15 ], [ %19, %18 ]
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = srem i32 %22, 15
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load i32, i32* %5
%27 = srem i32 %26, 30
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i32, i32* %4
%31 = load i32, i32* %6
%32 = call double @CalculateJulianDay(i32 %30, i32 %31, i32 6, i32 12, i32 0, double 0.000000e+00)
store double %32, double* %3
br label %37
33: ; preds = %25, %20
%34 = load i32, i32* %4
%35 = load i32, i32* %6
%36 = call double @CalculateJulianDay(i32 %34, i32 %35, i32 20, i32 12, i32 0, double 0.000000e+00)
store double %36, double* %3
br label %37
37: ; preds = %33, %29
%38 = load double, double* %3
ret double %38
}

LLVM IR (-O2):
define double @GetInitialEstimateSolarTerms(i32 %0, i32 %1) {
%3 = sitofp i32 %1 to double
%4 = fadd double %3, 9.000000e+01
%5 = fdiv double %4, 3.000000e+01
%6 = tail call i64 @ceil(double %5)
%7 = trunc i64 %6 to i32
%8 = icmp sgt i32 %7, 12
%9 = add nsw i32 %7, -12
%10 = select i1 %8, i32 %9, i32 %7
%11 = srem i32 %1, 15
%12 = icmp ne i32 %11, 0
%13 = srem i32 %1, 30
%14 = icmp eq i32 %13, 0
%15 = or i1 %12, %14
%16 = select i1 %15, i32 20, i32 6
%17 = tail call double @CalculateJulianDay(i32 %0, i32 %10, i32 %16, i32 12, i32 0, double 0.000000e+00)
ret double %17
}