// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: precise_check()
void precise_check()
{
double d_lat, d_lon, d_alt;

   if(surveying) return;
   if(check_precise_posn == 0) return;
   if(check_delay) {  // ignore first few survey points - they could be bogus filter remnants
      --check_delay;
      return;
   }

   d_lat = (lat-precise_lat)*RAD_TO_DEG/ANGLE_SCALE;
   d_lon = (lon-precise_lon)*RAD_TO_DEG/ANGLE_SCALE*cos_factor;
   d_alt = (alt-precise_alt);
// if((DABS(lat-precise_lat) < LAT_THRESH) && (DABS(lon-precise_lon) < LON_THRESH) && (DABS(alt-precise_alt) < ALT_THRESH)) {

   // see if surveyed position error is small enough
   if((sqrt(d_lat*d_lat + d_lon*d_lon) <= 1.0) && (DABS(d_alt) < ALT_THRESH)) {
      save_segment(7, 10);      // yes,  save the position in EEPROM
      check_precise_posn = 0;   // we are done
      log_saved_posn(-1);
      if(SCREEN_WIDTH > NARROW_SCREEN) lla_header("Precise survey complete    ", WHITE);
      else                             lla_header("Survey complete            ", WHITE);
      close_lla_file(1);
      precise_survey_done = 1;
      trimble_save = 0;
   }
   else { // try single point survey again
      start_self_survey(0x00, 2);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x212f12(%rip), %rax    # 0x36d081
cmpb $0x0, (%rax)
je 0x15a179
jmp 0x15a34d
leaq 0x240340(%rip), %rax    # 0x39a4c0
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x15a18d
jmp 0x15a34d
leaq 0x24032d(%rip), %rax    # 0x39a4c1
cmpb $0x0, (%rax)
je 0x15a1b3
leaq 0x240321(%rip), %rax    # 0x39a4c1
movb (%rax), %cl
addb $-0x1, %cl
leaq 0x240315(%rip), %rax    # 0x39a4c1
movb %cl, (%rax)
jmp 0x15a34d
leaq 0x211ff6(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
leaq 0x24030b(%rip), %rax    # 0x39a4d0
subsd (%rax), %xmm0
movsd 0x14faf(%rip), %xmm1    # 0x16f180
mulsd %xmm1, %xmm0
leaq 0x211fbc(%rip), %rax    # 0x36c198
divsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x211fcc(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm0
leaq 0x2402e1(%rip), %rax    # 0x39a4d8
subsd (%rax), %xmm0
movsd 0x14f7d(%rip), %xmm1    # 0x16f180
mulsd %xmm1, %xmm0
leaq 0x211f8a(%rip), %rax    # 0x36c198
divsd (%rax), %xmm0
leaq 0x211f8f(%rip), %rax    # 0x36c1a8
mulsd (%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x211f97(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm0
leaq 0x2402ac(%rip), %rax    # 0x39a4e0
subsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x8(%rbp), %xmm2
movsd -0x10(%rbp), %xmm1
mulsd -0x10(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x9280
movaps %xmm0, %xmm1
movsd 0x14dff(%rip), %xmm0    # 0x16f068
ucomisd %xmm1, %xmm0
jb 0x15a341
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0x15a28c
xorps %xmm0, %xmm0
subsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x15a296
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm1
movsd 0x14dc5(%rip), %xmm0    # 0x16f068
ucomisd %xmm1, %xmm0
jbe 0x15a341
movl $0x7, %edi
movl $0xa, %esi
callq 0x90d70
leaq 0x2401fd(%rip), %rax    # 0x39a4c0
movb $0x0, (%rax)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x120fc0
leaq 0x11d709(%rip), %rax    # 0x2779e0
movl (%rax), %eax
movl %eax, -0x24(%rbp)
leaq 0x128441(%rip), %rax    # 0x282724
imull $0x31a, (%rax), %eax    # imm = 0x31A
movl $0x64, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x24(%rbp), %eax
cmpl %ecx, %eax
jle 0x15a30d
leaq 0x3dc8e(%rip), %rdi     # 0x197f8f
movl $0xf, %esi
callq 0x15a360
jmp 0x15a31e
leaq 0x3dc97(%rip), %rdi     # 0x197fab
movl $0xf, %esi
callq 0x15a360
movl $0x1, %edi
callq 0x159a00
leaq 0x212d4b(%rip), %rax    # 0x36d07a
movb $0x1, (%rax)
leaq 0x212d43(%rip), %rax    # 0x36d07c
movl $0x0, (%rax)
jmp 0x15a34d
xorl %edi, %edi
movl $0x2, %esi
callq 0x93b60
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)