// File: 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
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movl $0x1, %edi
callq 0x9ae80
leaq 0x213404(%rip), %rax    # 0x36d060
cmpq $0x0, (%rax)
jg 0x159c7f
leaq 0x2133f7(%rip), %rax    # 0x36d060
movq $0x30, (%rax)
leaq 0x2133f1(%rip), %rax    # 0x36d068
movl $0x1, (%rax)
jmp 0x159ca9
leaq 0x2133da(%rip), %rax    # 0x36d060
cmpq $0x60, (%rax)
jle 0x159ca7
leaq 0x2133cd(%rip), %rax    # 0x36d060
movq $0x30, (%rax)
leaq 0x2133c7(%rip), %rax    # 0x36d068
movl $0x2, (%rax)
jmp 0x159ca9
leaq 0x2133b0(%rip), %rax    # 0x36d060
movq (%rax), %rcx
leaq 0x21339e(%rip), %rax    # 0x36d058
movq %rcx, (%rax)
movl $0x4, %edi
movl $0xff, %edx
movss 0x17c69(%rip), %xmm3    # 0x171938
movl %edx, %esi
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0x805d0
leaq 0x14390e(%rip), %rax    # 0x29d5f4
cmpb $0x0, (%rax)
je 0x159d21
leaq 0x14384e(%rip), %rax    # 0x29d540
cmpq $0x0, (%rax)
je 0x159d21
leaq 0x213361(%rip), %rax    # 0x36d060
movq (%rax), %rdx
leaq 0x142e37(%rip), %rdi    # 0x29cb40
leaq 0x3e09c(%rip), %rsi     # 0x197dac
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl $0x2, %edi
callq 0x1598a0
leaq 0x14384e(%rip), %rax    # 0x29d580
cmpq $0x0, (%rax)
je 0x159e96
leaq 0x14383d(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x213313(%rip), %rax    # 0x36d060
movq (%rax), %rdx
leaq 0x3e07a(%rip), %rsi     # 0x197dd1
movb $0x0, %al
callq 0x9550
leaq 0x14381b(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3a6fa(%rip), %rsi     # 0x194469
movb $0x0, %al
callq 0x9550
leaq 0x143803(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e070(%rip), %rsi     # 0x197df7
movb $0x0, %al
callq 0x9550
leaq 0x1437eb(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e075(%rip), %rsi     # 0x197e14
movb $0x0, %al
callq 0x9550
leaq 0x1437d3(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e07b(%rip), %rsi     # 0x197e32
movb $0x0, %al
callq 0x9550
leaq 0x1437bb(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e07d(%rip), %rsi     # 0x197e4c
movb $0x0, %al
callq 0x9550
leaq 0x1437a3(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e080(%rip), %rsi     # 0x197e67
movb $0x0, %al
callq 0x9550
leaq 0x14378b(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e088(%rip), %rsi     # 0x197e87
movb $0x0, %al
callq 0x9550
leaq 0x143773(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e08a(%rip), %rsi     # 0x197ea1
movb $0x0, %al
callq 0x9550
leaq 0x14375b(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e08c(%rip), %rsi     # 0x197ebb
movb $0x0, %al
callq 0x9550
leaq 0x143743(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e08f(%rip), %rsi     # 0x197ed6
movb $0x0, %al
callq 0x9550
leaq 0x14372b(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e094(%rip), %rsi     # 0x197ef3
movb $0x0, %al
callq 0x9550
leaq 0x143713(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3e09e(%rip), %rsi     # 0x197f15
movb $0x0, %al
callq 0x9550
leaq 0x1436fb(%rip), %rax    # 0x29d580
movq (%rax), %rdi
leaq 0x3a5da(%rip), %rsi     # 0x194469
movb $0x0, %al
callq 0x9550
leaq 0x2131db(%rip), %rax    # 0x36d078
movb $0x1, (%rax)
leaq 0x11dc09(%rip), %rax    # 0x277ab0
cmpq $0x400, (%rax)          # imm = 0x400
jne 0x159eb2
jmp 0x159ee1
leaq 0x2405fb(%rip), %rax    # 0x39a4b4
movb $0x1, (%rax)
leaq 0x2405f1(%rip), %rax    # 0x39a4b4
movzbl (%rax), %edi
callq 0x52a70
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x22b, %esi            # imm = 0x22B
callq 0x159a40
xorl %edi, %edi
callq 0x159b10
leaq 0x12070c(%rip), %rax    # 0x27a5f4
movb $0x1, (%rax)
leaq 0x11daee(%rip), %rax    # 0x2779e0
cmpl $0x690, (%rax)          # imm = 0x690
setge %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x159f37
leaq 0x2406bc(%rip), %rax    # 0x39a5c8
movb $0x1, (%rax)
leaq 0x11db9a(%rip), %rax    # 0x277ab0
cmpq $0x10000, (%rax)        # imm = 0x10000
jne 0x159f2b
leaq 0x141ff8(%rip), %rax    # 0x29bf1e
movb $0x5, (%rax)
jmp 0x159f35
leaq 0x141fec(%rip), %rax    # 0x29bf1e
movb $0x0, (%rax)
jmp 0x159f37
movl $0x29, %edi
callq 0xeaf0
leaq 0x2129d4(%rip), %rax    # 0x36c91c
movl (%rax), %eax
movq %rax, 0x357f27(%rip)    # 0x4b1e78
movq 0x357f20(%rip), %rax    # 0x4b1e78
addq $0x3c, %rax
movq %rax, 0x357f1d(%rip)    # 0x4b1e80
movq 0x357f0e(%rip), %rax    # 0x4b1e78
addq $0xe10, %rax            # imm = 0xE10
movq %rax, 0x357f11(%rip)    # 0x4b1e88
xorps %xmm0, %xmm0
movsd %xmm0, 0x357f3e(%rip)   # 0x4b1ec0
xorps %xmm0, %xmm0
movsd %xmm0, 0x357f2b(%rip)   # 0x4b1eb8
xorps %xmm0, %xmm0
movsd %xmm0, 0x357f18(%rip)   # 0x4b1eb0
leaq 0x240525(%rip), %rax    # 0x39a4c4
movl $0x0, (%rax)
leaq 0x2130dc(%rip), %rax    # 0x36d088
movq $0x0, (%rax)
movl $0x0, 0x358863(%rip)    # 0x4b2820
movl $0x0, 0x358855(%rip)    # 0x4b281c
movl $0x0, 0x358847(%rip)    # 0x4b2818
movl $0x0, 0x359185(%rip)    # 0x4b3160
movl $0x0, 0x359177(%rip)    # 0x4b315c
movl $0x0, 0x359169(%rip)    # 0x4b3158
movl $0x0, 0x35947f(%rip)    # 0x4b3478
movl $0x0, 0x27efc1(%rip)    # 0x3d8fc4
movl $0x0, 0x27efb3(%rip)    # 0x3d8fc0
xorps %xmm0, %xmm0
movsd %xmm0, 0x357ec0(%rip)   # 0x4b1ed8
xorps %xmm0, %xmm0
movsd %xmm0, 0x357ead(%rip)   # 0x4b1ed0
xorps %xmm0, %xmm0
movsd %xmm0, 0x357e9a(%rip)   # 0x4b1ec8
xorps %xmm0, %xmm0
movsd %xmm0, 0x357ea7(%rip)   # 0x4b1ee0
movl $0x3, %edi
callq 0x12bcc0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)