// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
pushq %rax
movl %edi, %ebx
testb $0x1, %bl
je 0x10966
andq $0x0, 0x216626(%rip)    # 0x226af8
andq $0x0, 0x216626(%rip)    # 0x226b00
andq $0x0, 0x216626(%rip)    # 0x226b08
andl $0x0, 0x21662b(%rip)    # 0x226b14
andl $0x0, 0x216628(%rip)    # 0x226b18
andq $0x0, 0x216630(%rip)    # 0x226b28
andq $0x0, 0x216630(%rip)    # 0x226b30
andq $0x0, 0x216630(%rip)    # 0x226b38
andq $0x0, 0x216630(%rip)    # 0x226b40
andl $0x0, 0x216639(%rip)    # 0x226b50
andq $0x0, 0x216659(%rip)    # 0x226b78
andq $0x0, 0x216659(%rip)    # 0x226b80
andq $0x0, 0x216659(%rip)    # 0x226b88
andq $0x0, 0x216659(%rip)    # 0x226b90
andl $0x0, 0x216662(%rip)    # 0x226ba0
andq $0x0, 0x216682(%rip)    # 0x226bc8
andq $0x0, 0x216682(%rip)    # 0x226bd0
andq $0x0, 0x216682(%rip)    # 0x226bd8
andq $0x0, 0x216682(%rip)    # 0x226be0
andl $0x0, 0x21668b(%rip)    # 0x226bf0
andq $0x0, 0x2166ab(%rip)    # 0x226c18
andq $0x0, 0x2166ab(%rip)    # 0x226c20
andq $0x0, 0x2166ab(%rip)    # 0x226c28
andq $0x0, 0x2166ab(%rip)    # 0x226c30
andl $0x0, 0x2166ac(%rip)    # 0x226c38
andl $0x0, 0x2165c1(%rip)    # 0x226b54
andl $0x0, 0x21660a(%rip)    # 0x226ba4
andl $0x0, 0x216653(%rip)    # 0x226bf4
andl $0x0, 0x2166a0(%rip)    # 0x226c48
xorl %eax, %eax
movb %al, 0x1fd070(%rip)     # 0x20d620
andl $0x0, 0x1fd6b1(%rip)    # 0x20dc68
andq $0x0, 0x1fd6ad(%rip)    # 0x20dc6c
movb %al, 0x1fd6b3(%rip)     # 0x20dc78
andl $0x0, 0x1fdcf4(%rip)    # 0x20e2c0
andq $0x0, 0x1fdcf0(%rip)    # 0x20e2c4
movb %al, 0x1fdcf6(%rip)     # 0x20e2d0
andl $0x0, 0x1fe337(%rip)    # 0x20e918
andq $0x0, 0x1fe333(%rip)    # 0x20e91c
movb %al, 0x1fe339(%rip)     # 0x20e928
andl $0x0, 0x1fe97a(%rip)    # 0x20ef70
andq $0x0, 0x1fe976(%rip)    # 0x20ef74
leaq 0x1fd01b(%rip), %rcx    # 0x20d620
leaq 0x1fd66c(%rip), %rdx    # 0x20dc78
leaq 0x1fdcbd(%rip), %rsi    # 0x20e2d0
leaq 0x1fe30e(%rip), %rdi    # 0x20e928
cmpq $0x190, %rax            # imm = 0x190
je 0x10680
andq $0x0, 0x328(%rcx,%rax,2)
andl $0x0, 0x4(%rax,%rcx)
andl $0x0, 0x194(%rax,%rcx)
andq $0x0, 0x328(%rdx,%rax,2)
andl $0x0, 0x4(%rax,%rdx)
andl $0x0, 0x194(%rax,%rdx)
andq $0x0, 0x328(%rsi,%rax,2)
andl $0x0, 0x4(%rax,%rsi)
andl $0x0, 0x194(%rax,%rsi)
andq $0x0, 0x328(%rdi,%rax,2)
andl $0x0, 0x4(%rax,%rdi)
andl $0x0, 0x194(%rax,%rdi)
addq $0x4, %rax
jmp 0x1061a
andq $0x0, 0x1fce28(%rip)    # 0x20d4b0
andq $0x0, 0x1fce28(%rip)    # 0x20d4b8
andq $0x0, 0x1fce28(%rip)    # 0x20d4c0
andq $0x0, 0x1fce28(%rip)    # 0x20d4c8
andl $0x0, 0x1fce29(%rip)    # 0x20d4d0
andl $0x0, 0x1fce26(%rip)    # 0x20d4d4
andl $0x0, 0x1fce23(%rip)    # 0x20d4d8
andl $0x0, 0x1fce20(%rip)    # 0x20d4dc
andq $0x0, 0x2e617c(%rip)    # 0x2f6840
andq $0x0, 0x2e616c(%rip)    # 0x2f6838
andq $0x0, 0x2e615c(%rip)    # 0x2f6830
andq $0x0, 0x2e614c(%rip)    # 0x2f6828
andq $0x0, 0x2e617c(%rip)    # 0x2f6860
andq $0x0, 0x2e616c(%rip)    # 0x2f6858
andq $0x0, 0x2e615c(%rip)    # 0x2f6850
andq $0x0, 0x2e614c(%rip)    # 0x2f6848
andq $0x0, 0x2e611c(%rip)    # 0x2f6820
andq $0x0, 0x2e610c(%rip)    # 0x2f6818
andq $0x0, 0x2e60fc(%rip)    # 0x2f6810
andq $0x0, 0x2e60ec(%rip)    # 0x2f6808
andq $0x0, 0x2e60dc(%rip)    # 0x2f6800
andq $0x0, 0x2e60cc(%rip)    # 0x2f67f8
andq $0x0, 0x2e616c(%rip)    # 0x2f68a0
andq $0x0, 0x2e615c(%rip)    # 0x2f6898
andq $0x0, 0x2e614c(%rip)    # 0x2f6890
andq $0x0, 0x2e613c(%rip)    # 0x2f6888
movabsq $-0x3a0bce1f051928df, %rax # imm = 0xC5F431E0FAE6D721
andq $0x0, 0x2e6122(%rip)    # 0x2f6880
movq %rax, 0x216383(%rip)    # 0x226ae8
andq $0x0, 0x2e610b(%rip)    # 0x2f6878
movabsq $0x45f431e0fae6d721, %rax # imm = 0x45F431E0FAE6D721
movq %rax, 0x216372(%rip)    # 0x226af0
movl 0x14a4e0(%rip), %eax    # 0x15ac64
testl %eax, %eax
je 0x10795
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0x10815
jmp 0x107d5
andq $0x0, 0x2e6183(%rip)    # 0x2f6920
andq $0x0, 0x2e6173(%rip)    # 0x2f6918
andq $0x0, 0x2e6163(%rip)    # 0x2f6910
andq $0x0, 0x2e6153(%rip)    # 0x2f6908
andq $0x0, 0x2e6143(%rip)    # 0x2f6900
andq $0x0, 0x2e6133(%rip)    # 0x2f68f8
andq $0x0, 0x2e6123(%rip)    # 0x2f68f0
andq $0x0, 0x2e6113(%rip)    # 0x2f68e8
andq $0x0, 0x2e61cb(%rip)    # 0x2f69a8
andq $0x0, 0x2e61cb(%rip)    # 0x2f69b0
andq $0x0, 0x2e61cb(%rip)    # 0x2f69b8
andq $0x0, 0x2e61cb(%rip)    # 0x2f69c0
andq $0x0, 0x2e61cb(%rip)    # 0x2f69c8
andq $0x0, 0x2e61cb(%rip)    # 0x2f69d0
andq $0x0, 0x2e61cb(%rip)    # 0x2f69d8
andq $0x0, 0x2e61cb(%rip)    # 0x2f69e0
andq $0x0, 0x2e6093(%rip)    # 0x2f68b0
andq $0x0, 0x2e6083(%rip)    # 0x2f68a8
andq $0x0, 0x2e609b(%rip)    # 0x2f68c8
andq $0x0, 0x2e608b(%rip)    # 0x2f68c0
andq $0x0, 0x2e6033(%rip)    # 0x2f6870
andq $0x0, 0x2e6023(%rip)    # 0x2f6868
andq $0x0, 0x2e6083(%rip)    # 0x2f68d0
andq $0x0, 0x2e6063(%rip)    # 0x2f68b8
andl $0x0, 0x216424(%rip)    # 0x226c80
andl $0x0, 0x216429(%rip)    # 0x226c8c
andl $0x0, 0x216426(%rip)    # 0x226c90
callq 0xe8c79
andq $0x0, 0x2162f1(%rip)    # 0x226b68
andq $0x0, 0x216339(%rip)    # 0x226bb8
andq $0x0, 0x216381(%rip)    # 0x226c08
andq $0x0, 0x2163d1(%rip)    # 0x226c60
andq $0x0, 0x2162c1(%rip)    # 0x226b58
andq $0x0, 0x216309(%rip)    # 0x226ba8
andq $0x0, 0x216351(%rip)    # 0x226bf8
andq $0x0, 0x2163a1(%rip)    # 0x226c50
pushq $0x1
popq %rax
andq $0x0, 0x2162a6(%rip)    # 0x226b60
movl %eax, 0x2163a8(%rip)    # 0x226c68
andq $0x0, 0x2162e8(%rip)    # 0x226bb0
movl %eax, 0x21639e(%rip)    # 0x226c6c
andq $0x0, 0x21632a(%rip)    # 0x226c00
movl %eax, 0x216394(%rip)    # 0x226c70
andq $0x0, 0x216374(%rip)    # 0x226c58
movl %eax, 0x21638a(%rip)    # 0x226c74
xorl %eax, %eax
leaq 0x318f5d(%rip), %rcx    # 0x329850
xorps %xmm0, %xmm0
cmpq $0x500, %rax            # imm = 0x500
je 0x10917
movaps %xmm0, 0x30(%rax,%rcx)
movaps %xmm0, 0x20(%rax,%rcx)
movaps %xmm0, 0x10(%rax,%rcx)
movaps %xmm0, (%rax,%rcx)
addq $0x40, %rax
jmp 0x108f6
cmpq $0x10000, 0x1f1fae(%rip) # imm = 0x10000
jne 0x10948
andq $0x0, 0x2e60ec(%rip)    # 0x2f6a18
andl $0x0, 0x2e6901(%rip)    # 0x2f7234
andl $0x0, 0x2e68fe(%rip)    # 0x2f7238
andl $0x0, 0x2e68fb(%rip)    # 0x2f723c
andl $0x0, 0x2e68f8(%rip)    # 0x2f7240
cmpq $0x0, 0x14a570(%rip)    # 0x15aec0
je 0x10966
movl $0x29a, %edi            # imm = 0x29A
callq 0xc7144
movl $0x29a, 0x1f1ede(%rip)  # imm = 0x29A
testb $0x4, %bl
je 0x1098d
cmpq $0x10000, 0x1f1f5a(%rip) # imm = 0x10000
je 0x10985
callq 0x66b41
orl 0x216361(%rip), %eax    # 0x226ce4
je 0x1098d
pushq $0x1
popq %rdi
callq 0xc6922
testb $0x2, %bl
je 0x10a72
andq $0x0, 0x1f4992(%rip)    # 0x205330
andq $0x0, 0x1f4982(%rip)    # 0x205328
andq $0x0, 0x1f498a(%rip)    # 0x205338
andl $0x0, 0x1f49d7(%rip)    # 0x20538c
andq $0x0, 0x1f498b(%rip)    # 0x205348
andl $0x0, 0x1f4a08(%rip)    # 0x2053cc
movb $0x0, 0x1f4975(%rip)    # 0x205340
andq $0x0, 0x2e65bd(%rip)    # 0x2f6f90
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x10086
movabsq $0x4056800000000000, %rax # imm = 0x4056800000000000
movq %rax, 0x2e6613(%rip)    # 0x2f7000
movabsq $-0x3fa9800000000000, %rax # imm = 0xC056800000000000
movq %rax, 0x2e660a(%rip)    # 0x2f7008
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
movq %rax, 0x2e6601(%rip)    # 0x2f7010
movabsq $-0x3f99800000000000, %rax # imm = 0xC066800000000000
movq %rax, 0x2e65f8(%rip)    # 0x2f7018
andl $0x0, 0x2e689d(%rip)    # 0x2f72c4
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x314880(%rip)    # 0x3252b8
cmpq %rbx, 0x217981(%rip)    # 0x2283c0
jne 0x10a48
movb $0x0, 0x317e08(%rip)    # 0x328850
andl $0x0, 0x31887d(%rip)    # 0x3292cc
movb $0x1, 0x31887a(%rip)    # 0x3292d0
callq 0x10a79
xorl %edi, %edi
callq 0xe6975
cmpl $0x0, 0x14a1f7(%rip)    # 0x15ac60
jne 0x10a72
andl $0x0, 0x21850a(%rip)    # 0x228f7c
addq $0x8, %rsp
popq %rbx
popq %rbp
retq