// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heather.cpp
// Function: forward_filter(long)
struct PLOT_Q forward_filter(long point)
{
struct PLOT_Q avg;
struct PLOT_Q q;
DATA_SIZE count;
DATA_SIZE max[NUM_PLOTS+DERIVED_PLOTS];
DATA_SIZE min[NUM_PLOTS+DERIVED_PLOTS];
long i;
long f_count;
int j;

   // average the next "filter_count" queue entries
   avg = get_plot_q(point);
   filter_jd = avg.q_jd;
   filter_flags = avg.sat_flags;
   count = 1.0F;

   if(point == plot_q_in) return avg;

   if(disp_filter_type == 'P') {  // min/max filter
      for(j=0; j<NUM_PLOTS+DERIVED_PLOTS; j++) {
         if(j != FFT) {
            max[j] = min[j] = avg.data[j];
         }
      }
   }

   f_count = disp_filter_size();
   for(i=1; i<f_count; i++) {
      if(++point == plot_q_in) {  // at the end of the plot data
         break;
      }
      while(point >= plot_q_size) point -= plot_q_size;

      q = get_plot_q(point);
      filter_flags |= q.sat_flags;
      count += (DATA_SIZE) 1.0;

      for(j=0; j<NUM_PLOTS+DERIVED_PLOTS; j++) {
         if(j != FFT) {
            if(disp_filter_type == 'P') {
               if(q.data[j] > max[j]) max[j] = q.data[j];
               if(q.data[j] < min[j]) min[j] = q.data[j];
            }

            avg.data[j] += q.data[j];
         }
      }
   }

   for(j=0; j<NUM_PLOTS+DERIVED_PLOTS; j++) {  // derived_plots OK
      if(j != FFT) {
         if(disp_filter_type == 'P') {
            if(fabs(max[j]) >= fabs(min[j])) avg.data[j] = max[j];
            else                             avg.data[j] = min[j];
         }
         else {
            avg.data[j] /= count;
         }
      }
   }

   return avg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, %r14
movq %rdi, %rbx
callq 0x10141
movsd 0x8(%rbx), %xmm0
movsd %xmm0, 0x32e7c6(%rip)   # 0x340250
movzwl (%rbx), %eax
movw %ax, 0x32e7c4(%rip)     # 0x340258
cmpq %r14, 0x20988d(%rip)    # 0x21b328
je 0x11c2f
cmpl $0x50, 0x2099d0(%rip)   # 0x21b478
jne 0x11ad3
xorl %eax, %eax
cmpq $0xe, %rax
je 0x11aca
movsd 0x10(%rbx,%rax,8), %xmm0
movsd %xmm0, -0xd0(%rbp,%rax,8)
movsd %xmm0, -0x170(%rbp,%rax,8)
incq %rax
cmpq $0x14, %rax
jne 0x11aac
callq 0x115ca
cmpq $0x2, %rax
jl 0x11bc3
movq %rax, %r15
movsd 0xf7583(%rip), %xmm5    # 0x109070
movl $0x1, %r13d
leaq -0x220(%rbp), %r12
leaq 0x1(%r14), %rax
cmpq 0x209823(%rip), %rax    # 0x21b328
je 0x11bcb
movsd %xmm5, -0x30(%rbp)
movq 0x209809(%rip), %rax    # 0x21b320
addq %rax, %r14
incq %r14
subq %rax, %r14
cmpq %rax, %r14
jge 0x11b1d
movq %r12, %rdi
movq %r14, %rsi
callq 0x10141
movzwl -0x220(%rbp), %eax
orw %ax, 0x32e71a(%rip)     # 0x340258
movl 0x209934(%rip), %eax    # 0x21b478
xorl %ecx, %ecx
movsd -0x30(%rbp), %xmm5
cmpq $0x70, %rcx
je 0x11ba0
cmpl $0x50, %eax
jne 0x11b8b
movsd -0x210(%rbp,%rcx), %xmm0
ucomisd -0x170(%rbp,%rcx), %xmm0
jbe 0x11b73
movsd %xmm0, -0x170(%rbp,%rcx)
movsd -0xd0(%rbp,%rcx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x11b8b
movsd %xmm0, -0xd0(%rbp,%rcx)
movsd -0x210(%rbp,%rcx), %xmm0
addsd 0x10(%rbx,%rcx), %xmm0
movsd %xmm0, 0x10(%rbx,%rcx)
addq $0x8, %rcx
cmpq $0xa0, %rcx
jne 0x11b4b
addsd 0xf74bb(%rip), %xmm5    # 0x109070
incq %r13
cmpq %r15, %r13
jne 0x11afa
jmp 0x11bcb
movsd 0xf74a5(%rip), %xmm5    # 0x109070
movl 0x2098a7(%rip), %eax    # 0x21b478
xorl %ecx, %ecx
movapd 0xf75a5(%rip), %xmm0    # 0x109180
cmpq $0xe, %rcx
je 0x11c26
cmpl $0x50, %eax
jne 0x11c16
movsd -0x170(%rbp,%rcx,8), %xmm1
movapd %xmm1, %xmm3
andpd %xmm0, %xmm3
movsd -0xd0(%rbp,%rcx,8), %xmm2
movapd %xmm2, %xmm4
andpd %xmm0, %xmm4
ucomisd %xmm4, %xmm3
jae 0x11c20
movsd %xmm2, 0x10(%rbx,%rcx,8)
jmp 0x11c26
movsd 0x10(%rbx,%rcx,8), %xmm1
divsd %xmm5, %xmm1
movsd %xmm1, 0x10(%rbx,%rcx,8)
incq %rcx
cmpq $0x14, %rcx
jne 0x11bdb
movq %rbx, %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq