// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0x67da0
leaq 0x212995(%rip), %r14    # 0x2f7e80
movq (%r14), %rax
testq %rax, %rax
jle 0xe54fc
cmpq $0x61, %rax
jb 0xe550f
pushq $0x2
popq %rbx
movq $0x30, (%r14)
leaq 0x21297e(%rip), %rax    # 0x2f7e88
movl %ebx, (%rax)
pushq $0x30
popq %rax
leaq 0x212962(%rip), %rcx    # 0x2f7e78
movq %rax, (%rcx)
pushq $0x4
popq %rdi
movss 0x11bc4(%rip), %xmm0    # 0xf70e8
movl $0xff, %esi
movaps %xmm0, %xmm1
movaps %xmm0, %xmm2
movaps %xmm0, %xmm3
movl $0xff, %edx
callq 0x55b65
leaq 0x142ed1(%rip), %rax    # 0x228414
cmpb $0x0, (%rax)
je 0xe5575
leaq 0x142e11(%rip), %rax    # 0x228360
cmpq $0x0, (%rax)
je 0xe5575
movq (%r14), %rdx
leaq 0x142401(%rip), %rdi    # 0x227960
leaq 0x39bd4(%rip), %rsi     # 0x11f13a
xorl %eax, %eax
callq 0x9060
pushq $0x1
popq %rdi
callq 0xb25f5
callq 0xe5205
leaq 0x142e1f(%rip), %r12    # 0x2283a0
movq (%r12), %rdi
testq %rdi, %rdi
je 0xe56cc
movq (%r14), %rdx
leaq 0x39bc7(%rip), %rsi     # 0x11f15f
xorl %eax, %eax
callq 0x9560
movq (%r12), %rcx
leaq 0x362e3(%rip), %rdi     # 0x11b88d
pushq $0x2
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bc1(%rip), %rdi     # 0x11f185
pushq $0x1c
popq %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bc8(%rip), %rdi     # 0x11f1a2
pushq $0x1d
popq %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bd0(%rip), %rdi     # 0x11f1c0
pushq $0x19
popq %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bd1(%rip), %rdi     # 0x11f1da
pushq $0x1a
popq %r14
movq %r14, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bd2(%rip), %rdi     # 0x11f1f5
pushq $0x1f
popq %r13
movq %r13, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bd8(%rip), %rdi     # 0x11f215
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bdc(%rip), %rdi     # 0x11f22f
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39be0(%rip), %rdi     # 0x11f249
movq %r14, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39be5(%rip), %rdi     # 0x11f264
pushq $0x1c
popq %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bec(%rip), %rdi     # 0x11f281
pushq $0x21
popq %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x39bf8(%rip), %rdi     # 0x11f2a3
movq %r13, %rsi
movq %r15, %rdx
callq 0x9750
movq (%r12), %rcx
leaq 0x361cc(%rip), %rdi     # 0x11b88d
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x9750
leaq 0x2127c5(%rip), %rax    # 0x2f7e98
movb $0x1, (%rax)
leaq 0x11d1f3(%rip), %rbx    # 0x2028d0
cmpq $0x400, (%rbx)          # imm = 0x400
je 0xe5707
leaq 0x23fbe7(%rip), %rax    # 0x3252d4
movb $0x1, (%rax)
pushq $0x1
popq %rdi
callq 0x377c9
pushq $-0x1
popq %rdi
callq 0xe534c
xorl %edi, %edi
callq 0xe53f2
leaq 0x11fd06(%rip), %rax    # 0x205414
movb $0x1, (%rax)
leaq 0x11d0e8(%rip), %rax    # 0x202800
cmpl $0x68f, (%rax)          # imm = 0x68F
jg 0xe5742
leaq 0x23fcc1(%rip), %rax    # 0x3253e8
movb $0x1, (%rax)
xorl %eax, %eax
cmpq $0x10000, (%rbx)        # imm = 0x10000
sete %al
leal (%rax,%rax,4), %eax
leaq 0x1415fe(%rip), %rcx    # 0x226d3e
movb %al, (%rcx)
pushq $0x29
popq %rdi
callq 0xcc4f
andq $0x0, 0x35717e(%rip)    # 0x43c8d0
andq $0x0, 0x35716e(%rip)    # 0x43c8c8
andq $0x0, 0x35715e(%rip)    # 0x43c8c0
leaq 0x23fb7b(%rip), %rax    # 0x3252e4
andl $0x0, (%rax)
leaq 0x212735(%rip), %rax    # 0x2f7ea8
andq $0x0, (%rax)
andl $0x0, 0x357ab2(%rip)    # 0x43d230
andl $0x0, 0x357aa7(%rip)    # 0x43d22c
andl $0x0, 0x357a9c(%rip)    # 0x43d228
andl $0x0, 0x3583dd(%rip)    # 0x43db70
andl $0x0, 0x3583d2(%rip)    # 0x43db6c
andl $0x0, 0x3583c7(%rip)    # 0x43db68
leaq 0x211f94(%rip), %rax    # 0x2f773c
andl $0x0, 0x3586d9(%rip)    # 0x43de88
movl (%rax), %eax
andl $0x0, 0x27e5cc(%rip)    # 0x363d84
movq %rax, 0x3570c9(%rip)    # 0x43c888
andl $0x0, 0x27e5ba(%rip)    # 0x363d80
leaq 0x3c(%rax), %rcx
andq $0x0, 0x357116(%rip)    # 0x43c8e8
movq %rcx, 0x3570b7(%rip)    # 0x43c890
andq $0x0, 0x3570ff(%rip)    # 0x43c8e0
addq $0xe10, %rax            # imm = 0xE10
andq $0x0, 0x3570e9(%rip)    # 0x43c8d8
movq %rax, 0x3570a2(%rip)    # 0x43c898
andq $0x0, 0x3570f2(%rip)    # 0x43c8f0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc9736