// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heather.cpp
// Function: reset_queues(int, int)
void reset_queues(int queue_type, int why)
{
#ifdef ADEV_STUFF
int i;
int k;

// sprintf(debug_text2, "reset queue:%04x  why:%d", queue_type, why);

   if(queue_type & RESET_ADEV_Q) { // reset adev queue
      adev_q_in = 0;
      adev_q_out = 0;
      adev_q_count = 0;
      adev_time = 0;
      last_bin_count = 0;

      pps_adev_q_in = 0;
      pps_adev_q_out = 0;
      pps_adev_q_count = 0;
      pps_adev_q_overflow = 0.0;
      pps_adev_disp = 0; // ADEV_DISPLAY_RATE;

      osc_adev_q_in = 0;
      osc_adev_q_out = 0;
      osc_adev_q_count = 0;
      osc_adev_q_overflow = 0.0;
      osc_adev_disp = 0; // ADEV_DISPLAY_RATE;

      chc_adev_q_in = 0;
      chc_adev_q_out = 0;
      chc_adev_q_count = 0;
      chc_adev_q_overflow = 0.0;
      chc_adev_disp = 0; // ADEV_DISPLAY_RATE;

      chd_adev_q_in = 0;
      chd_adev_q_out = 0;
      chd_adev_q_count = 0;
      chd_adev_q_overflow = 0.0;
      chd_adev_disp = 0; // ADEV_DISPLAY_RATE;

      last_pps_bin_count = 0;
      last_osc_bin_count = 0;
      last_chc_bin_count = 0;
      last_chd_bin_count = 0;

      pps_bins.adev_type = 0;
      pps_bins.bin_count = 0;
      pps_bins.adev_min = 0.0;
      pps_bins.adev_max = 0.0;

      osc_bins.adev_type = 0;
      osc_bins.bin_count = 0;
      osc_bins.adev_min = 0.0;
      osc_bins.adev_max = 0.0;

      chc_bins.adev_type = 0;
      chc_bins.bin_count = 0;
      chc_bins.adev_min = 0.0;
      chc_bins.adev_max = 0.0;

      chd_bins.adev_type = 0;
      chd_bins.bin_count = 0;
      chd_bins.adev_min = 0.0;
      chd_bins.adev_max = 0.0;

      for(i=0; i<MAX_ADEV_BINS; i++) {
         pps_bins.adev_on[i] = 0;
         pps_bins.adev_taus[i] = 0.0;
         pps_bins.adev_bins[i] = 0.0;

         osc_bins.adev_on[i] = 0;
         osc_bins.adev_taus[i] = 0.0;
         osc_bins.adev_bins[i] = 0.0;

         chc_bins.adev_on[i] = 0;
         chc_bins.adev_taus[i] = 0.0;
         chc_bins.adev_bins[i] = 0.0;

         chd_bins.adev_on[i] = 0;
         chd_bins.adev_taus[i] = 0.0;
         chd_bins.adev_bins[i] = 0.0;
      }

      global_adev_max = (-(BIG_NUM));
      global_adev_min = (BIG_NUM);

      pps_base_value = 0.0;
      osc_base_value = 0.0;
      chc_base_value = 0.0;
      chd_base_value = 0.0;

      have_pps_base = 0;
      have_osc_base = 0;
      have_chc_base = 0;
      have_chd_base = 0;

      cha_ts_ref = chb_ts_ref = chc_ts_ref = chd_ts_ref = 0.0;
      cha_ts_sum = chb_ts_sum = chc_ts_sum = chd_ts_sum = 0.0;

      pps_phase = osc_phase = cha_phase = chb_phase = chc_phase = chd_phase = 0.0;
      pps_count = osc_count = cha_count = chb_count = chc_count = chd_count = 0.0;
      if(dont_reset_phase == 0) {  // reloaing adev queue from plot queue data
         last_cha_ts = last_chb_ts = last_chc_ts = last_chd_ts = 0.0;
         last_ticc_v1 = last_ticc_v2 = last_ticc_v3 = last_ticc_v4 = 0.0;
      }
      if((dont_reset_phase == 0) || (dont_reset_phase == 2)) {
         cha_phase_wrap_adj = 0.0;
         cha_last_wrap_phase = 0.0;
         chb_phase_wrap_adj = 0.0;
         chb_last_wrap_phase = 0.0;
         chc_phase_wrap_adj = 0.0;
         chc_last_wrap_phase = 0.0;
         chd_phase_wrap_adj = 0.0;
         chd_last_wrap_phase = 0.0;
      }

      cha_time2_sum = chb_time2_sum = 0.0;
      cha_time2_count = chb_time2_count = 0.0;
      msgofs_phase = msgjit_phase = 0.0;


      fudge_sum = fudge_count = 0.0;

      first_show_bin = 0;
      max_adev_width = 0;
      max_bins_shown = 0;

      reset_adev_bins();
      pps_adevs_cleared = 1;
      osc_adevs_cleared = 1;
      chc_adevs_cleared = 1;
      chd_adevs_cleared = 1;

      pps_tie = 0.0;           // Time Interval Errors
      osc_tie = 0.0;
      chc_tie = 0.0;
      chd_tie = 0.0;

      pps_resid = 0.0;         // phase residuals
      osc_resid = 0.0;
      chc_resid = 0.0;
      chd_resid = 0.0;
      last_pps_resid = 0.0;
      last_osc_resid = 0.0;
      last_chc_resid = 0.0;
      last_chd_resid = 0.0;

      for(k=0; k<NUM_PLOTS+DERIVED_PLOTS; k++) {  // reset plot queue residuals
         resid[k].sum_x        = (DATA_SIZE) 0.0;
         resid[k].sum_y        = (DATA_SIZE) 0.0;
         resid[k].sum_xx       = (DATA_SIZE) 0.0;
         resid[k].sum_yy       = (DATA_SIZE) 0.0;
         resid[k].sum_xy       = (DATA_SIZE) 0.0;
         resid[k].a0           = (DATA_SIZE) 0.0;
         resid[k].a1           = (DATA_SIZE) 0.0;
         resid[k].resid_count  = (DATA_SIZE) 0.0;
      }

      if(rcvr_type == TICC_RCVR) {  // aaaacccc
////     dac_voltage = 0.0;
         temperature = 0.0;
         have_osc_offset = 0;
         have_pps_offset = 0;
         have_chc_offset = 0;
         have_chd_offset = 0;
      }
///if(dont_reset_queues == 0) ticc_packets = 0;
      if(screen_active()) {
         force_adev_redraw(666);
         need_redraw = 666;
      }
   }

   if(queue_type & RESET_MTIE_Q) {
      if(TICC_USED || mtie_allocated) alloc_mtie(1);  // reset MTIE data structures by re-allocating them
   }
#endif

   if(queue_type & RESET_PLOT_Q) {  // reset plot queue
      plot_q_in = plot_q_out = 0;
      plot_q_count = 0;
      plot_q_full = 0;
      plot_time = 0;
      plot_start = 0;
      plot_column = 0;
      stat_count = 0.0F;
      clear_plot_entry((long) plot_q_in);

      min_q_lat = 90.0;
      max_q_lat = (-90.0);
      min_q_lon = 180.0;
      max_q_lon = (-180.0);
      have_valid_lla = 0;
      last_lla_span = 1.0;

      if(sim_file == 0) plot_title[0] = 0;  // reset plot title
      title_type = NONE;
      greet_ok = 1;

      reset_marks();
      rebuild_lla_plot(0);
      if(dont_reset_queues == 0) {
         ticc_packets = 0;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
testb $0x1, %bl
je 0x110b1
xorl %r14d, %r14d
movq %r14, 0x22be86(%rip)    # 0x23caf8
movq %r14, 0x22be87(%rip)    # 0x23cb00
movq %r14, 0x22be88(%rip)    # 0x23cb08
movl %r14d, 0x22be8d(%rip)   # 0x23cb14
movl %r14d, 0x22be8a(%rip)   # 0x23cb18
movq %r14, 0x22be93(%rip)    # 0x23cb28
movq %r14, 0x22be94(%rip)    # 0x23cb30
movq %r14, 0x22be95(%rip)    # 0x23cb38
movq %r14, 0x22be96(%rip)    # 0x23cb40
movl %r14d, 0x22be9f(%rip)   # 0x23cb50
movq %r14, 0x22bec0(%rip)    # 0x23cb78
movq %r14, 0x22bec1(%rip)    # 0x23cb80
movq %r14, 0x22bec2(%rip)    # 0x23cb88
movq %r14, 0x22bec3(%rip)    # 0x23cb90
movl %r14d, 0x22becc(%rip)   # 0x23cba0
movq %r14, 0x22beed(%rip)    # 0x23cbc8
movq %r14, 0x22beee(%rip)    # 0x23cbd0
movq %r14, 0x22beef(%rip)    # 0x23cbd8
movq %r14, 0x22bef0(%rip)    # 0x23cbe0
movl %r14d, 0x22bef9(%rip)   # 0x23cbf0
movq %r14, 0x22bf1a(%rip)    # 0x23cc18
movq %r14, 0x22bf1b(%rip)    # 0x23cc20
movq %r14, 0x22bf1c(%rip)    # 0x23cc28
movq %r14, 0x22bf1d(%rip)    # 0x23cc30
movl %r14d, 0x22bf1e(%rip)   # 0x23cc38
movl %r14d, 0x22be33(%rip)   # 0x23cb54
movl %r14d, 0x22be7c(%rip)   # 0x23cba4
movl %r14d, 0x22bec5(%rip)   # 0x23cbf4
movl %r14d, 0x22bf12(%rip)   # 0x23cc48
movb %r14b, 0x2128e3(%rip)   # 0x223620
movl %r14d, 0x212f24(%rip)   # 0x223c68
movq %r14, 0x212f21(%rip)    # 0x223c6c
movb %r14b, 0x212f26(%rip)   # 0x223c78
movl %r14d, 0x213567(%rip)   # 0x2242c0
movq %r14, 0x213564(%rip)    # 0x2242c4
movb %r14b, 0x213569(%rip)   # 0x2242d0
movl %r14d, 0x213baa(%rip)   # 0x224918
movq %r14, 0x213ba7(%rip)    # 0x22491c
movb %r14b, 0x213bac(%rip)   # 0x224928
movl %r14d, 0x2141ed(%rip)   # 0x224f70
movq %r14, 0x2141ea(%rip)    # 0x224f74
leaq 0x212893(%rip), %rdi    # 0x223624
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x91a0
leaq 0x212ed8(%rip), %rdi    # 0x223c7c
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x91a0
leaq 0x21351d(%rip), %rdi    # 0x2242d4
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x91a0
leaq 0x213b62(%rip), %rdi    # 0x22492c
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x91a0
leaq 0x212843(%rip), %rax    # 0x223620
leaq 0x212e94(%rip), %rcx    # 0x223c78
leaq 0x2134e5(%rip), %rdx    # 0x2242d0
leaq 0x213b36(%rip), %rsi    # 0x224928
xorl %edi, %edi
movq %r14, 0x328(%rax,%rdi,8)
movq %r14, 0x328(%rcx,%rdi,8)
movq %r14, 0x328(%rdx,%rdi,8)
movq %r14, 0x328(%rsi,%rdi,8)
incq %rdi
cmpq $0x64, %rdi
jne 0x10df4
movabsq $-0x3a0bce1f051928df, %rax # imm = 0xC5F431E0FAE6D721
movq %rax, 0x22bcba(%rip)    # 0x23cae8
movabsq $0x45f431e0fae6d721, %rax # imm = 0x45F431E0FAE6D721
movq %rax, 0x22bcb1(%rip)    # 0x23caf0
xorl %eax, %eax
movq %rax, 0x212668(%rip)    # 0x2234b0
movq %rax, 0x212669(%rip)    # 0x2234b8
movq %rax, 0x21266a(%rip)    # 0x2234c0
movq %rax, 0x21266b(%rip)    # 0x2234c8
movl %eax, 0x21266d(%rip)    # 0x2234d0
movl %eax, 0x21266b(%rip)    # 0x2234d4
movl %eax, 0x212669(%rip)    # 0x2234d8
movl %eax, 0x212667(%rip)    # 0x2234dc
movq %rax, 0x2fb9c4(%rip)    # 0x30c840
movq %rax, 0x2fb9b5(%rip)    # 0x30c838
movq %rax, 0x2fb9a6(%rip)    # 0x30c830
movq %rax, 0x2fb997(%rip)    # 0x30c828
movq %rax, 0x2fb9c8(%rip)    # 0x30c860
movq %rax, 0x2fb9b9(%rip)    # 0x30c858
movq %rax, 0x2fb9aa(%rip)    # 0x30c850
movq %rax, 0x2fb99b(%rip)    # 0x30c848
movq %rax, 0x2fb96c(%rip)    # 0x30c820
movq %rax, 0x2fb95d(%rip)    # 0x30c818
movq %rax, 0x2fb94e(%rip)    # 0x30c810
movq %rax, 0x2fb93f(%rip)    # 0x30c808
movq %rax, 0x2fb930(%rip)    # 0x30c800
movq %rax, 0x2fb921(%rip)    # 0x30c7f8
movq %rax, 0x2fb9c2(%rip)    # 0x30c8a0
movq %rax, 0x2fb9b3(%rip)    # 0x30c898
movq %rax, 0x2fb9a4(%rip)    # 0x30c890
movq %rax, 0x2fb995(%rip)    # 0x30c888
movq %rax, 0x2fb986(%rip)    # 0x30c880
movq %rax, 0x2fb977(%rip)    # 0x30c878
movl 0x15fd5d(%rip), %eax    # 0x170c64
testl %eax, %eax
jne 0x10f45
xorl %ecx, %ecx
movq %rcx, 0x2fba0c(%rip)    # 0x30c920
movq %rcx, 0x2fb9fd(%rip)    # 0x30c918
movq %rcx, 0x2fb9ee(%rip)    # 0x30c910
movq %rcx, 0x2fb9df(%rip)    # 0x30c908
movq %rcx, 0x2fb9d0(%rip)    # 0x30c900
movq %rcx, 0x2fb9c1(%rip)    # 0x30c8f8
movq %rcx, 0x2fb9b2(%rip)    # 0x30c8f0
movq %rcx, 0x2fb9a3(%rip)    # 0x30c8e8
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0x10f86
xorl %eax, %eax
movq %rax, 0x2fba53(%rip)    # 0x30c9a8
movq %rax, 0x2fba54(%rip)    # 0x30c9b0
movq %rax, 0x2fba55(%rip)    # 0x30c9b8
movq %rax, 0x2fba56(%rip)    # 0x30c9c0
movq %rax, 0x2fba57(%rip)    # 0x30c9c8
movq %rax, 0x2fba58(%rip)    # 0x30c9d0
movq %rax, 0x2fba59(%rip)    # 0x30c9d8
movq %rax, 0x2fba5a(%rip)    # 0x30c9e0
xorl %r14d, %r14d
movq %r14, 0x2fb920(%rip)    # 0x30c8b0
movq %r14, 0x2fb911(%rip)    # 0x30c8a8
movq %r14, 0x2fb92a(%rip)    # 0x30c8c8
movq %r14, 0x2fb91b(%rip)    # 0x30c8c0
movq %r14, 0x2fb8c4(%rip)    # 0x30c870
movq %r14, 0x2fb8b5(%rip)    # 0x30c868
movq %r14, 0x2fb916(%rip)    # 0x30c8d0
movq %r14, 0x2fb8f7(%rip)    # 0x30c8b8
movl %r14d, 0x22bcb8(%rip)   # 0x23cc80
movl %r14d, 0x22bcbd(%rip)   # 0x23cc8c
movl %r14d, 0x22bcba(%rip)   # 0x23cc90
callq 0xfe5a8
movl $0x1, %eax
movl %eax, 0x22bc82(%rip)    # 0x23cc68
movl %eax, 0x22bc80(%rip)    # 0x23cc6c
movl %eax, 0x22bc7e(%rip)    # 0x23cc70
movl %eax, 0x22bc7c(%rip)    # 0x23cc74
movq %r14, 0x22bb69(%rip)    # 0x23cb68
movq %r14, 0x22bbb2(%rip)    # 0x23cbb8
movq %r14, 0x22bbfb(%rip)    # 0x23cc08
movq %r14, 0x22bc4c(%rip)    # 0x23cc60
movq %r14, 0x22bb3d(%rip)    # 0x23cb58
movq %r14, 0x22bb86(%rip)    # 0x23cba8
movq %r14, 0x22bbcf(%rip)    # 0x23cbf8
movq %r14, 0x22bc20(%rip)    # 0x23cc50
movq %r14, 0x22bb29(%rip)    # 0x23cb60
movq %r14, 0x22bb72(%rip)    # 0x23cbb0
movq %r14, 0x22bbbb(%rip)    # 0x23cc00
movq %r14, 0x22bc0c(%rip)    # 0x23cc58
leaq 0x32e7fd(%rip), %rdi    # 0x33f850
movl $0x500, %edx            # imm = 0x500
xorl %esi, %esi
callq 0x91a0
cmpq $0x10000, 0x207866(%rip) # imm = 0x10000
jne 0x11093
movq $0x0, 0x2fb9a1(%rip) # 0x30ca18
movl %r14d, 0x2fc1b6(%rip)   # 0x30d234
movl %r14d, 0x2fc1b3(%rip)   # 0x30d238
movl %r14d, 0x2fc1b0(%rip)   # 0x30d23c
movl %r14d, 0x2fc1ad(%rip)   # 0x30d240
cmpq $0x0, 0x15fe25(%rip)    # 0x170ec0
je 0x110b1
movl $0x29a, %edi            # imm = 0x29A
callq 0xd846f
movl $0x29a, 0x207793(%rip)  # imm = 0x29A
testb $0x4, %bl
je 0x110da
cmpq $0x10000, 0x20780f(%rip) # imm = 0x10000
je 0x110d0
callq 0x701f2
orl 0x22bc16(%rip), %eax    # 0x23cce4
je 0x110da
movl $0x1, %edi
callq 0xd7c2f
testb $0x2, %bl
je 0x111de
xorl %ebx, %ebx
movq %rbx, 0x20a244(%rip)    # 0x21b330
movq %rbx, 0x20a235(%rip)    # 0x21b328
movq %rbx, 0x20a23e(%rip)    # 0x21b338
movb $0x0, 0x20a23f(%rip)    # 0x21b340
movl %ebx, 0x20a285(%rip)    # 0x21b38c
movq %rbx, 0x20a23a(%rip)    # 0x21b348
movl %ebx, 0x20a2b8(%rip)    # 0x21b3cc
movq %rbx, 0x2fbe75(%rip)    # 0x30cf90
xorl %edi, %edi
callq 0x10818
movabsq $0x4056800000000000, %rax # imm = 0x4056800000000000
movq %rax, 0x2fbecd(%rip)    # 0x30d000
movabsq $-0x3fa9800000000000, %rax # imm = 0xC056800000000000
movq %rax, 0x2fbec4(%rip)    # 0x30d008
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
movq %rax, 0x2fbebb(%rip)    # 0x30d010
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
movq %rax, 0x2fbeb2(%rip)    # 0x30d018
movl %ebx, 0x2fc158(%rip)    # 0x30d2c4
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x32a13b(%rip)    # 0x33b2b8
cmpq %rbx, 0x22d23c(%rip)    # 0x23e3c0
jne 0x1118d
movb $0x0, 0x32d6c3(%rip)    # 0x33e850
movl $0x0, 0x32e135(%rip)    # 0x33f2cc
movb $0x1, 0x32e132(%rip)    # 0x33f2d0
xorps %xmm0, %xmm0
movaps %xmm0, 0x20a108(%rip)   # 0x21b2b0
movaps %xmm0, 0x20a111(%rip)   # 0x21b2c0
movaps %xmm0, 0x20a11a(%rip)   # 0x21b2d0
movaps %xmm0, 0x20a123(%rip)   # 0x21b2e0
movaps %xmm0, 0x20a12c(%rip)   # 0x21b2f0
xorl %edi, %edi
callq 0xfbd5d
cmpl $0x0, 0x15fa8e(%rip)    # 0x170c60
jne 0x111de
movl $0x0, 0x22dd9e(%rip)    # 0x23ef7c
popq %rbx
popq %r14
popq %rbp
retq