// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathmsc.cpp
// Function: start_precision_survey(int)
void start_precision_survey(int why)
{
   stop_self_survey(1);  // abort standard survey
   if(do_median_survey <= 0) { 
      do_median_survey = 48; 
      survey_why = 1;
   }
   else if(do_median_survey > SURVEY_BIN_COUNT) { 
      do_median_survey = 48; 
      survey_why = 2;
   }

   do_survey = do_median_survey; // medsurv
   set_rcvr_mode(RCVR_MODE_3D);  // put receiver into 3D mode

   if(log_comments && log_file) {
      sprintf(log_text, "# Precision %ld hour survey started.", do_median_survey);
      write_log_comment(1);
   }

   open_lla_file(2);
   if(lla_file) {
      fprintf(lla_file, "# Precision %ld hour survey started.\n", do_median_survey);
      fprintf(lla_file, "#\n");
      fprintf(lla_file, "#tow  status  lat  lon  alt\n");
      fprintf(lla_file, "#     status  0: doing fixes\n");
      fprintf(lla_file, "#     status  1: no time\n");
      fprintf(lla_file, "#     status  2: no fixes\n");
      fprintf(lla_file, "#     status  3: PDOP too high\n");
      fprintf(lla_file, "#     status  8: no sats\n");
      fprintf(lla_file, "#     status  9: one sat\n");
      fprintf(lla_file, "#     status  A: two sats\n");
      fprintf(lla_file, "#     status  B: three sats\n");
      fprintf(lla_file, "#     status  C: sat unavailable\n");
      fprintf(lla_file, "#     else:      unknown error\n");
      fprintf(lla_file, "#\n");
   }

   precision_survey = 1;   // config screen to show survey map
if(rcvr_type == NO_RCVR) ;
else if(1) {
   show_fixes = 1;
   change_fix_config(show_fixes);
   start_3d_fixes(-1, 555);
   #ifdef BUFFER_LLA
      clear_lla_points(0);
   #endif
}
else {
   show_fixes = 0;   // zzzzzz
   change_fix_config(show_fixes);
   
   plot_lla = 3;
   plot_azel = 1;
}
   update_azel = 1;
   if(WIDE_SCREEN == 0) {
      shared_plot = 1; 
      if(rcvr_type == TICC_RCVR) all_adevs = ALL_CHANS;
      else                       all_adevs = SINGLE_ADEVS;
   }
   config_screen(41);

   start_tow = tow;
//start_tow = survey_tow; //"###
   minute_tow = start_tow + 60L;
   hour_tow = start_tow + 60L*60L;
//if(debug_file) fprintf(debug_file, "surv_tow:%d  start_tow:%d  min_tow:%d  hr_tow:%d  psh:%d\n", survey_tow,start_tow,minute_tow,hour_tow, PRECISE_SURVEY_HOURS); //plugh

   lat_sum = lon_sum = alt_sum = 0.0;
   precision_samples = 0;
   survey_minutes = 0L;

   second_lats = second_lons = second_alts = 0;
   minute_lats = minute_lons = minute_alts = 0;
   hour_lats = hour_lons = hour_alts = 0;

   best_lat = best_lon = best_alt = 0.0;
   best_count = 0.0;

   plot_lla_axes(3);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0x1, %r14d
movl $0x1, %edi
callq 0x715ee
leaq 0x2136cf(%rip), %rbx    # 0x30de80
movq (%rbx), %rax
testq %rax, %rax
jle 0xfa7c5
movl $0x2, %r14d
cmpq $0x61, %rax
jl 0xfa7d6
movq $0x30, (%rbx)
leaq 0x2136b5(%rip), %rax    # 0x30de88
movl %r14d, (%rax)
movq (%rbx), %rax
leaq 0x213698(%rip), %rcx    # 0x30de78
movq %rax, (%rcx)
movss 0x127e5(%rip), %xmm0    # 0x10cfd0
movl $0x4, %edi
movl $0xff, %esi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
callq 0x5d081
leaq 0x143c05(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0xfa843
leaq 0x143b45(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0xfa843
movq (%rbx), %rdx
leaq 0x143135(%rip), %rdi    # 0x23d960
leaq 0x3a8f8(%rip), %rsi     # 0x13512a
xorl %eax, %eax
callq 0x9060
movl $0x1, %edi
callq 0xc3105
callq 0xfa4c6
leaq 0x143b51(%rip), %r14    # 0x23e3a0
movq (%r14), %rdi
testq %rdi, %rdi
je 0xfa9b0
movq (%rbx), %rdx
leaq 0x3a8ea(%rip), %rsi     # 0x13514f
xorl %eax, %eax
callq 0x9560
movq (%r14), %rcx
leaq 0x37007(%rip), %rbx     # 0x13187d
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8e3(%rip), %rdi     # 0x135175
movl $0x1c, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8e7(%rip), %rdi     # 0x135192
movl $0x1d, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8ec(%rip), %rdi     # 0x1351b0
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8ed(%rip), %rdi     # 0x1351ca
movl $0x1a, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8ef(%rip), %rdi     # 0x1351e5
movl $0x1f, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8f6(%rip), %rdi     # 0x135205
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8f7(%rip), %rdi     # 0x13521f
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8f8(%rip), %rdi     # 0x135239
movl $0x1a, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8fa(%rip), %rdi     # 0x135254
movl $0x1c, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a8fe(%rip), %rdi     # 0x135271
movl $0x21, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a907(%rip), %rdi     # 0x135293
movl $0x1f, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9750
leaq 0x2134e1(%rip), %rax    # 0x30de98
movb $0x1, (%rax)
leaq 0x11df0f(%rip), %rbx    # 0x2188d0
cmpq $0x400, (%rbx)          # imm = 0x400
je 0xfa9ef
leaq 0x240903(%rip), %rax    # 0x33b2d4
movb $0x1, (%rax)
movl $0x1, %edi
callq 0x3aabf
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xfa611
xorl %edi, %edi
callq 0xfa6ba
leaq 0x120a1e(%rip), %rax    # 0x21b414
movb $0x1, (%rax)
leaq 0x11de00(%rip), %rax    # 0x218800
cmpl $0x68f, (%rax)          # imm = 0x68F
jg 0xfaa2a
leaq 0x2409d9(%rip), %rax    # 0x33b3e8
movb $0x1, (%rax)
xorl %eax, %eax
cmpq $0x10000, (%rbx)        # imm = 0x10000
sete %al
leal (%rax,%rax,4), %eax
leaq 0x142316(%rip), %rcx    # 0x23cd3e
movb %al, (%rcx)
movl $0x29, %edi
callq 0xcf81
leaq 0x212d01(%rip), %rax    # 0x30d73c
movl (%rax), %eax
movq %rax, 0x357f24(%rip)    # 0x452968
leaq 0x3c(%rax), %rcx
movq %rcx, 0x357f21(%rip)    # 0x452970
addq $0xe10, %rax            # imm = 0xE10
movq %rax, 0x357f1c(%rip)    # 0x452978
xorl %eax, %eax
movq %rax, 0x357f4b(%rip)    # 0x4529b0
movq %rax, 0x357f3c(%rip)    # 0x4529a8
movq %rax, 0x357f2d(%rip)    # 0x4529a0
leaq 0x24086a(%rip), %rcx    # 0x33b2e4
movl %eax, (%rcx)
leaq 0x213425(%rip), %rcx    # 0x30dea8
movq %rax, (%rcx)
movl %eax, 0x358884(%rip)    # 0x453310
movl %eax, 0x35887a(%rip)    # 0x45330c
movl %eax, 0x358870(%rip)    # 0x453308
movl %eax, 0x3591b2(%rip)    # 0x453c50
movl %eax, 0x3591a8(%rip)    # 0x453c4c
movl %eax, 0x35919e(%rip)    # 0x453c48
movl %eax, 0x3594b8(%rip)    # 0x453f68
movl %eax, 0x27f2ce(%rip)    # 0x379d84
movl %eax, 0x27f2c4(%rip)    # 0x379d80
movq %rax, 0x357f05(%rip)    # 0x4529c8
movq %rax, 0x357ef6(%rip)    # 0x4529c0
movq %rax, 0x357ee7(%rip)    # 0x4529b8
movq %rax, 0x357ef8(%rip)    # 0x4529d0
popq %rbx
popq %r14
popq %rbp
jmp 0xdac25