// File: jkingan[P]ladyheather/heather.cpp
// Function: filter_plot_q(long)
struct PLOT_Q filter_plot_q(long point)
{
long i;
long f_count;
int back_ok, center_ok, fwd_ok;

   if     (disp_filter_type == 'B') return back_filter(point);    // user forced filter type
   else if(disp_filter_type == 'C') return center_filter(point);
   else if(disp_filter_type == 'F') return forward_filter(point);

   f_count = disp_filter_size();

   back_ok = center_ok = fwd_ok = 1;

   i = point - f_count;
   if(i < 0) i += plot_q_size;
   if(i > plot_q_count) {  // too near the start of the plot to do a back filter
      back_ok = 0;
   }

   i = point - (f_count / 2);
   if(i < 0) i += plot_q_size;
   if(i > plot_q_count) {  // too near the start of the plot to do a center filter
      center_ok = 0;
   }

   i = point + f_count;
   if(i > plot_q_size) i -= plot_q_size;
   if(i > plot_q_count) {  // too near the end of the plot to do a forward filter
      fwd_ok = 0;
   }

   if(center_ok) {  // filter points each side of the point
      return center_filter(point);
   }
   else if(fwd_ok) {  // filter points after the point
      return forward_filter(point);
   }
   else if(back_ok) {  // filter points before the point
      return back_filter(point);
   }
   else {  // not enough data to do a proper filter
      return forward_filter(point);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x38(%rbp)
movq %rdi, -0x30(%rbp)
movq %rsi, -0x8(%rbp)
cmpl $0x42, 0x2644dd(%rip)   # 0x27a658
jne 0x1618f
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15550
jmp 0x162f6
cmpl $0x43, 0x2644c2(%rip)   # 0x27a658
jne 0x161aa
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15940
jmp 0x162f6
cmpl $0x46, 0x2644a7(%rip)   # 0x27a658
jne 0x161c5
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15d90
jmp 0x162f6
jmp 0x161c7
jmp 0x161c9
callq 0x15430
movq %rax, -0x18(%rbp)
movl $0x1, -0x24(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rax
subq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jge 0x16209
movq 0x2642ff(%rip), %rax    # 0x27a500
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x264304(%rip), %rax    # 0x27a518
jle 0x1621d
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jge 0x16257
movq 0x2642b1(%rip), %rax    # 0x27a500
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x2642b6(%rip), %rax    # 0x27a518
jle 0x1626b
movl $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x26427e(%rip), %rax    # 0x27a500
jle 0x16296
movq 0x264275(%rip), %rcx    # 0x27a500
movq -0x10(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x264277(%rip), %rax    # 0x27a518
jle 0x162aa
movl $0x0, -0x24(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x162bf
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15940
jmp 0x162f6
cmpl $0x0, -0x24(%rbp)
je 0x162d4
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15d90
jmp 0x162f6
cmpl $0x0, -0x1c(%rbp)
je 0x162e9
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15550
jmp 0x162f6
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x15d90
movq -0x30(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq