// File: /workspace/github_cpp_makefile_star2_O3/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 0x71618
leaq 0x212f7a(%rip), %rbx    # 0x30de80
movq (%rbx), %rax
testq %rax, %rax
jle 0xfaf1a
movl $0x2, %r14d
cmpq $0x61, %rax
jb 0xfaf30
movq $0x30, (%rbx)
leaq 0x212f60(%rip), %rax    # 0x30de88
movl %r14d, (%rax)
movl $0x30, %eax
leaq 0x212f41(%rip), %rcx    # 0x30de78
movq %rax, (%rcx)
movss 0x12126(%rip), %xmm0    # 0x10d068
movl $0x4, %edi
movl $0xff, %esi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
callq 0x5cf59
leaq 0x1434ae(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0xfaf9a
leaq 0x1433ee(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0xfaf9a
movq (%rbx), %rdx
leaq 0x1429de(%rip), %rdi    # 0x23d960
leaq 0x3a291(%rip), %rsi     # 0x13521a
xorl %eax, %eax
callq 0x9060
movl $0x1, %edi
callq 0xc36e2
callq 0xfac1a
leaq 0x1433fa(%rip), %r14    # 0x23e3a0
movq (%r14), %rdi
testq %rdi, %rdi
je 0xfb107
movq (%rbx), %rdx
leaq 0x3a283(%rip), %rsi     # 0x13523f
xorl %eax, %eax
callq 0x9560
movq (%r14), %rcx
leaq 0x369a0(%rip), %rbx     # 0x13196d
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9750
movq (%r14), %rcx
leaq 0x3a27c(%rip), %rdi     # 0x135265
movl $0x1c, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a280(%rip), %rdi     # 0x135282
movl $0x1d, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a285(%rip), %rdi     # 0x1352a0
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a286(%rip), %rdi     # 0x1352ba
movl $0x1a, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a288(%rip), %rdi     # 0x1352d5
movl $0x1f, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a28f(%rip), %rdi     # 0x1352f5
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a290(%rip), %rdi     # 0x13530f
movl $0x19, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a291(%rip), %rdi     # 0x135329
movl $0x1a, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a293(%rip), %rdi     # 0x135344
movl $0x1c, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a297(%rip), %rdi     # 0x135361
movl $0x21, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
leaq 0x3a2a0(%rip), %rdi     # 0x135383
movl $0x1f, %esi
movl $0x1, %edx
callq 0x9750
movq (%r14), %rcx
movl $0x2, %esi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x9750
leaq 0x212d8a(%rip), %rax    # 0x30de98
movb $0x1, (%rax)
leaq 0x11d7b8(%rip), %rbx    # 0x2188d0
cmpq $0x400, (%rbx)          # imm = 0x400
je 0xfb193
leaq 0x2401ac(%rip), %rax    # 0x33b2d4
movb $0x1, %r14b
movb %r14b, (%rax)
movl $0x1, %edi
callq 0x3ab43
callq 0x6649d
leaq 0x24016c(%rip), %rax    # 0x33b2b0
movb $0x2, (%rax)
leaq 0x1202c5(%rip), %rax    # 0x21b413
movb %r14b, (%rax)
leaq 0x1202bc(%rip), %rax    # 0x21b414
movb %r14b, (%rax)
leaq 0x11d69e(%rip), %rax    # 0x218800
cmpl $0x68f, (%rax)          # imm = 0x68F
jg 0xfb18c
leaq 0x240277(%rip), %rax    # 0x33b3e8
movb $0x1, (%rax)
xorl %eax, %eax
cmpq $0x10000, (%rbx)        # imm = 0x10000
sete %al
leal (%rax,%rax,4), %eax
leaq 0x141bb4(%rip), %rcx    # 0x23cd3e
movb %al, (%rcx)
xorl %edi, %edi
callq 0xfae0d
leaq 0x12027a(%rip), %rax    # 0x21b414
movb $0x1, (%rax)
leaq 0x11d65c(%rip), %rax    # 0x218800
cmpl $0x68f, (%rax)          # imm = 0x68F
jg 0xfb1ce
leaq 0x240235(%rip), %rax    # 0x33b3e8
movb $0x1, (%rax)
xorl %eax, %eax
cmpq $0x10000, (%rbx)        # imm = 0x10000
sete %al
leal (%rax,%rax,4), %eax
leaq 0x141b72(%rip), %rcx    # 0x23cd3e
movb %al, (%rcx)
movl $0x29, %edi
callq 0xcf89
leaq 0x21255d(%rip), %rax    # 0x30d73c
movl (%rax), %eax
movq %rax, 0x3576a0(%rip)    # 0x452888
leaq 0x3c(%rax), %rcx
movq %rcx, 0x35769d(%rip)    # 0x452890
addq $0xe10, %rax            # imm = 0xE10
movq %rax, 0x357698(%rip)    # 0x452898
xorl %eax, %eax
movq %rax, 0x3576c7(%rip)    # 0x4528d0
movq %rax, 0x3576b8(%rip)    # 0x4528c8
movq %rax, 0x3576a9(%rip)    # 0x4528c0
leaq 0x2400c6(%rip), %rcx    # 0x33b2e4
movl %eax, (%rcx)
leaq 0x212c81(%rip), %rcx    # 0x30dea8
movq %rax, (%rcx)
movl %eax, 0x358000(%rip)    # 0x453230
movl %eax, 0x357ff6(%rip)    # 0x45322c
movl %eax, 0x357fec(%rip)    # 0x453228
movl %eax, 0x35892e(%rip)    # 0x453b70
movl %eax, 0x358924(%rip)    # 0x453b6c
movl %eax, 0x35891a(%rip)    # 0x453b68
movl %eax, 0x358c34(%rip)    # 0x453e88
movl %eax, 0x27eb2a(%rip)    # 0x379d84
movl %eax, 0x27eb20(%rip)    # 0x379d80
movq %rax, 0x357681(%rip)    # 0x4528e8
movq %rax, 0x357672(%rip)    # 0x4528e0
movq %rax, 0x357663(%rip)    # 0x4528d8
movq %rax, 0x357674(%rip)    # 0x4528f0
popq %rbx
popq %r14
popq %rbp
jmp 0xdb2e0