// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: back_filter(long)
struct PLOT_Q back_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;
int j;

   // average the previous "filter_count" queue entries

   if(plot_q_count < filter_count) i = plot_q_count;
   else                            i = disp_filter_size();

   point -= i;
   if(point < 0) point += plot_q_size;
//   if(point >= plot_q_count) point = 0;

   avg = get_plot_q(point);
   filter_jd = avg.q_jd;
   filter_flags = avg.sat_flags;
   count = 1.0F;

   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];
         }
      }
   }

   while(--i > 0) {
      ++point;
      while(point >= plot_q_size) point -= plot_q_size;

      q = get_plot_q(point);
      filter_jd = q.q_jd;
      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 %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %r12
movq %rdi, %rbx
movq 0x1f4450(%rip), %r14    # 0x205338
cmpq 0x1f4581(%rip), %r14    # 0x205470
jl 0x10ef9
callq 0x10e43
movq %rax, %r14
subq %r14, %r12
movq %r12, %r15
sarq $0x3f, %r15
andq 0x1f4416(%rip), %r15    # 0x205320
addq %r12, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf9c7
movsd 0x8(%rbx), %xmm0
movsd %xmm0, 0x31932b(%rip)   # 0x32a250
movzwl (%rbx), %eax
movw %ax, 0x319329(%rip)     # 0x32a258
movl 0x1f4543(%rip), %eax    # 0x205478
cmpl $0x50, %eax
jne 0x10f65
xorl %ecx, %ecx
cmpq $0xe, %rcx
je 0x10f60
cmpq $0x14, %rcx
je 0x10f65
movsd 0x10(%rbx,%rcx,8), %xmm0
movsd %xmm0, -0xd0(%rbp,%rcx,8)
movsd %xmm0, -0x170(%rbp,%rcx,8)
incq %rcx
jmp 0x10f3c
movsd 0xe2103(%rip), %xmm5    # 0xf3070
leaq -0x220(%rbp), %r12
cmpq $0x1, %r14
jle 0x11035
movsd %xmm5, -0x28(%rbp)
decq %r14
movq 0x1f4393(%rip), %rax    # 0x205320
addq %rax, %r15
incq %r15
subq %rax, %r15
cmpq %rax, %r15
jge 0x10f93
movq %r12, %rdi
movq %r15, %rsi
callq 0xf9c7
movzwl -0x220(%rbp), %eax
orw %ax, 0x3192a4(%rip)     # 0x32a258
movsd -0x218(%rbp), %xmm0
movsd %xmm0, 0x31928c(%rip)   # 0x32a250
movl 0x1f44ae(%rip), %eax    # 0x205478
xorl %ecx, %ecx
movsd -0x28(%rbp), %xmm5
cmpq $0xe, %rcx
je 0x11023
cmpq $0x14, %rcx
je 0x11028
movsd -0x210(%rbp,%rcx,8), %xmm0
cmpl $0x50, %eax
jne 0x11017
ucomisd -0x170(%rbp,%rcx,8), %xmm0
jbe 0x10fff
movsd %xmm0, -0x170(%rbp,%rcx,8)
movsd -0xd0(%rbp,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x11017
movsd %xmm0, -0xd0(%rbp,%rcx,8)
addsd 0x10(%rbx,%rcx,8), %xmm0
movsd %xmm0, 0x10(%rbx,%rcx,8)
incq %rcx
jmp 0x10fd1
addsd 0xe2040(%rip), %xmm5    # 0xf3070
jmp 0x10f74
xorl %ecx, %ecx
movapd 0xe2151(%rip), %xmm0    # 0xf3190
cmpq $0xe, %rcx
je 0x11090
cmpq $0x14, %rcx
je 0x11095
cmpl $0x50, %eax
jne 0x11080
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 0x1108a
movsd %xmm2, 0x10(%rbx,%rcx,8)
jmp 0x11090
movsd 0x10(%rbx,%rcx,8), %xmm1
divsd %xmm5, %xmm1
movsd %xmm1, 0x10(%rbx,%rcx,8)
incq %rcx
jmp 0x1103f
movq %rbx, %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq