// File: /workspace/github_c_makefile_star2_O3/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, 0x24551(%rip)     # 0x2e604
jne 0xa0c2
cmpl %r14d, 0x24544(%rip)    # 0x2e600
je 0xa1e8
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 0xa792
movl (%r12), %edi
movl 0x4(%r12), %esi
movl 0x8(%r12), %edx
callq 0x9b68
movsd %xmm0, 0x2450b(%rip)    # 0x2e610
movslq %r15d, %rdx
leaq 0x1f0b1(%rip), %rax     # 0x291c0
movsbq -0x1(%rdx,%rax), %rax
xorl $0x2, %edx
movl %r14d, %esi
andl $0x3, %esi
xorl %ecx, %ecx
orl %edx, %esi
jne 0xa151
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 0xa151
rorl $0x4, %edx
xorl %ecx, %ecx
cmpl $0xa3d70b, %edx         # imm = 0xA3D70B
setb %cl
movl %ecx, %r13d
addq %rax, %r13
leal 0x1(%r13), %eax
movl %eax, 0x8(%rsp)
testl %r13d, %r13d
jle 0xa191
movl 0x8(%rsp), %ebp
movl $0x1, %r12d
leaq 0x2449b(%rip), %rbx     # 0x2e610
movl %r15d, %edi
movl %r12d, %esi
movl %r14d, %edx
callq 0x9b68
movsd %xmm0, (%rbx,%r12,8)
incq %r12
cmpq %r12, %rbp
jne 0xa175
leaq 0x1c(%rsp), %r12
movl %r15d, (%r12)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%r12)
movl %r14d, 0x8(%r12)
movq %r12, %rdi
callq 0xa792
movl (%r12), %edi
movl 0x4(%r12), %esi
movl 0x8(%r12), %edx
callq 0x9b68
leaq 0x24446(%rip), %rax     # 0x2e610
movsd %xmm0, 0x8(%rax,%r13,8)
movl %r15d, 0x2442c(%rip)    # 0x2e604
movl %r14d, 0x24421(%rip)    # 0x2e600
movq 0x10(%rsp), %rcx
movl 0xc(%rsp), %esi
movslq %esi, %rax
leaq 0x2441e(%rip), %rdx     # 0x2e610
movsd -0x8(%rdx,%rax,8), %xmm1
movsd (%rdx,%rax,8), %xmm0
movsd 0x8(%rdx,%rax,8), %xmm4
movsd 0xbe55(%rip), %xmm5     # 0x16060
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 0x151a2(%rip), %xmm4    # 0x1f3f0
movapd 0x1529a(%rip), %xmm5    # 0x1f4f0
xorps %xmm6, %xmm6
cvtsi2sd %eax, %xmm6
mulsd %xmm4, %xmm6
ucomisd %xmm1, %xmm6
jbe 0xa29b
ucomisd %xmm6, %xmm3
jbe 0xa29b
movapd %xmm2, %xmm7
subsd %xmm6, %xmm7
andpd %xmm5, %xmm7
movapd %xmm6, %xmm8
subsd %xmm1, %xmm8
ucomisd %xmm7, %xmm8
jbe 0xa29b
movapd %xmm3, %xmm8
subsd %xmm6, %xmm8
ucomisd %xmm7, %xmm8
ja 0xa2a9
incl %eax
cmpl $0x5, %eax
jne 0xa256
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0xa2ac
andl $0x3, %eax
movl %eax, (%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)