// File: /workspace/github_c_makefile_star2_O1/mmayer[P]pcal/src/moonphas.c
// Function: find_phase
double find_phase (int month, int day, int year, int *pquarter)
{
   static int sv_year = 0, sv_month = 0;
   static double mphase[33];   /* 31 days + 2 dummies */
   double phase;
   
   /* calculate moon phase */

   /* new month?  fill mphase[] with moon phases */
   if (month != sv_month || year != sv_year) {
      gen_phases(mphase, month, year);
      sv_month = month;
      sv_year = year;
   }
   
   phase = mphase[day];
   *pquarter = is_quarter(mphase[day-1], phase, mphase[day+1]);

   return phase;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %r14d
movl %edi, %r15d
cmpl %edi, 0x23b29(%rip)     # 0x2d604
jne 0x9aea
cmpl %r14d, 0x23b1c(%rip)    # 0x2d600
je 0x9c09
movl %esi, 0xc(%rsp)
movq %rcx, 0x10(%rsp)
leaq 0x1c(%rsp), %r12
movl %r15d, (%r12)
movl $0x0, 0x4(%r12)
movl %r14d, 0x8(%r12)
movq %r12, %rdi
callq 0xa1b1
movl (%r12), %edi
movl 0x4(%r12), %esi
movl 0x8(%r12), %edx
callq 0x9590
movsd %xmm0, 0x23ae3(%rip)    # 0x2d610
movslq %r15d, %rdx
leaq 0x1e689(%rip), %rax     # 0x281c0
movsbq -0x1(%rdx,%rax), %rax
xorl $0x2, %edx
movl %r14d, %esi
andl $0x3, %esi
xorl %ecx, %ecx
orl %edx, %esi
jne 0x9b79
imull $0xc28f5c29, %r14d, %edx # imm = 0xC28F5C29
addl $0x51eb850, %edx        # imm = 0x51EB850
movl %edx, %esi
rorl $0x2, %esi
movl $0x1, %ecx
cmpl $0x28f5c28, %esi        # imm = 0x28F5C28
ja 0x9b79
rorl $0x4, %edx
xorl %ecx, %ecx
cmpl $0xa3d70b, %edx         # imm = 0xA3D70B
setb %cl
movl %ecx, %r13d
addq %rax, %r13
testl %r13d, %r13d
jle 0x9bb2
leal 0x1(%r13), %ebx
movl $0x1, %r12d
leaq 0x23a7b(%rip), %rbp     # 0x2d610
movl %r15d, %edi
movl %r12d, %esi
movl %r14d, %edx
callq 0x9590
movsd %xmm0, (%rbp,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x9b95
leaq 0x1c(%rsp), %r12
movl %r15d, (%r12)
leaq 0x1(%r13), %rax
movl %eax, 0x4(%r12)
movl %r14d, 0x8(%r12)
movq %r12, %rdi
callq 0xa1b1
movl (%r12), %edi
movl 0x4(%r12), %esi
movl 0x8(%r12), %edx
callq 0x9590
leaq 0x23a25(%rip), %rax     # 0x2d610
movsd %xmm0, 0x8(%rax,%r13,8)
movl %r15d, 0x23a0b(%rip)    # 0x2d604
movl %r14d, 0x23a00(%rip)    # 0x2d600
movq 0x10(%rsp), %rcx
movl 0xc(%rsp), %esi
movslq %esi, %rax
leaq 0x239fd(%rip), %rdx     # 0x2d610
movsd -0x8(%rdx,%rax,8), %xmm1
movsd (%rdx,%rax,8), %xmm0
movsd 0x8(%rdx,%rax,8), %xmm4
movsd 0xb3dc(%rip), %xmm5     # 0x15008
movapd %xmm0, %xmm3
addsd %xmm5, %xmm3
movapd %xmm0, %xmm2
cmpltsd %xmm1, %xmm2
andpd %xmm2, %xmm3
andnpd %xmm0, %xmm2
orpd %xmm3, %xmm2
addsd %xmm4, %xmm5
movapd %xmm4, %xmm3
cmpltsd %xmm1, %xmm3
andpd %xmm3, %xmm5
andnpd %xmm4, %xmm3
orpd %xmm5, %xmm3
movl $0x1, %eax
movsd 0x14729(%rip), %xmm4    # 0x1e398
movapd 0x14829(%rip), %xmm5    # 0x1e4a0
xorps %xmm6, %xmm6
cvtsi2sd %eax, %xmm6
mulsd %xmm4, %xmm6
ucomisd %xmm1, %xmm6
jbe 0x9cbc
ucomisd %xmm6, %xmm3
jbe 0x9cbc
movapd %xmm2, %xmm7
subsd %xmm6, %xmm7
andpd %xmm5, %xmm7
movapd %xmm6, %xmm8
subsd %xmm1, %xmm8
ucomisd %xmm7, %xmm8
jbe 0x9cbc
movapd %xmm3, %xmm8
subsd %xmm6, %xmm8
ucomisd %xmm7, %xmm8
ja 0x9cca
incl %eax
cmpl $0x5, %eax
jne 0x9c77
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x9ccd
andl $0x3, %eax
movl %eax, (%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop