// File: jkingan[P]ladyheather/heather.cpp
// Function: trim_plot_queue(int)
void trim_plot_queue(int trim)
{
long count;

   // trim leading (the entries before the first displayed point)
   // entries from the plot queue

   if(trim & TRIM_Q_START) {
      count = plot_q_col0 - plot_q_out;
      if(count < 0) count += plot_q_size;  // number of entries to remove

      if(count > plot_q_size) ;   // can't trim the start
      else if(count > plot_q_count) ;
      else {
         plot_q_out = plot_q_col0;
         plot_q_count -= count;

         if(trim & TRIM_Q_END) {  //trimming both ends from the queue
            count = plot_q_in - plot_q_last_col;
            if(count < 0) count += plot_q_size;  // number of entries to remove
            plot_q_col0 = plot_q_in - count;
            if(plot_q_col0 < 0) plot_q_col0 += plot_q_size;
            goto both_ends;
         }
      }
   }

   if(trim & TRIM_Q_END) {
      count = plot_q_last_col - plot_q_col0;
      if(count < 0) count += plot_q_size;  // number of entries to remove

      both_ends:
      if(count > plot_q_size) ;
      else if(count > plot_q_count) ;
      else if(count < 0) ;
      else {
         plot_q_in = plot_q_col0;
         plot_q_count -= count;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x13ea1
movq 0x26667b(%rip), %rax    # 0x27a448
subq 0x26673c(%rip), %rax    # 0x27a510
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jge 0x13dee
movq 0x26671a(%rip), %rax    # 0x27a500
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0x266707(%rip), %rax    # 0x27a500
jle 0x13e00
jmp 0x13e9f
movq -0x10(%rbp), %rax
cmpq 0x26670d(%rip), %rax    # 0x27a518
jle 0x13e12
jmp 0x13e9d
movq 0x26662f(%rip), %rax    # 0x27a448
movq %rax, 0x2666f0(%rip)    # 0x27a510
movq -0x10(%rbp), %rcx
movq 0x2666ed(%rip), %rax    # 0x27a518
subq %rcx, %rax
movq %rax, 0x2666e3(%rip)    # 0x27a518
movl -0x4(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13e9b
movq 0x2666c1(%rip), %rax    # 0x27a508
subq 0x266602(%rip), %rax    # 0x27a450
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jge 0x13e68
movq 0x2666a0(%rip), %rax    # 0x27a500
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq 0x266699(%rip), %rax    # 0x27a508
subq -0x10(%rbp), %rax
movq %rax, 0x2665ce(%rip)    # 0x27a448
cmpq $0x0, 0x2665c6(%rip)    # 0x27a448
jge 0x13e99
movq 0x266675(%rip), %rax    # 0x27a500
addq 0x2665b6(%rip), %rax    # 0x27a448
movq %rax, 0x2665af(%rip)    # 0x27a448
jmp 0x13ed6
jmp 0x13e9d
jmp 0x13e9f
jmp 0x13ea1
movl -0x4(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13f26
movq 0x26659d(%rip), %rax    # 0x27a450
subq 0x26658e(%rip), %rax    # 0x27a448
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jge 0x13ed4
movq 0x266634(%rip), %rax    # 0x27a500
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
jmp 0x13ed6
movq -0x10(%rbp), %rax
cmpq 0x26661f(%rip), %rax    # 0x27a500
jle 0x13ee5
jmp 0x13f24
movq -0x10(%rbp), %rax
cmpq 0x266628(%rip), %rax    # 0x27a518
jle 0x13ef4
jmp 0x13f22
cmpq $0x0, -0x10(%rbp)
jge 0x13efd
jmp 0x13f20
movq 0x266544(%rip), %rax    # 0x27a448
movq %rax, 0x2665fd(%rip)    # 0x27a508
movq -0x10(%rbp), %rcx
movq 0x266602(%rip), %rax    # 0x27a518
subq %rcx, %rax
movq %rax, 0x2665f8(%rip)    # 0x27a518
jmp 0x13f22
jmp 0x13f24
jmp 0x13f26
popq %rbp
retq
nopl (%rax,%rax)