// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rbx
pushq %rax
leaq 0x212b20(%rip), %rax    # 0x30dea1
cmpb $0x0, (%rax)
jne 0xfb3a3
leaq 0x23ff53(%rip), %rbx    # 0x33b2e0
cmpb $0x0, (%rbx)
je 0xfb3a3
leaq 0x23ff48(%rip), %rax    # 0x33b2e1
movb (%rax), %cl
testb %cl, %cl
je 0xfb3aa
decb %cl
movb %cl, (%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x211c1f(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
leaq 0x23ff34(%rip), %rax    # 0x33b2f0
subsd (%rax), %xmm0
movsd 0xdd98(%rip), %xmm1     # 0x109160
mulsd %xmm1, %xmm0
leaq 0x211be5(%rip), %rax    # 0x30cfb8
movsd (%rax), %xmm2
leaq 0x211bfa(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm3
leaq 0x23ff0f(%rip), %rax    # 0x33b2f8
subsd (%rax), %xmm3
mulsd %xmm1, %xmm3
divsd %xmm2, %xmm3
leaq 0x211bcc(%rip), %rax    # 0x30cfc8
mulsd (%rax), %xmm3
divsd %xmm2, %xmm0
mulsd %xmm3, %xmm3
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
movsd 0xdc51(%rip), %xmm0     # 0x109070
ucomisd %xmm1, %xmm0
jb 0xfb502
leaq 0x23fed0(%rip), %rax    # 0x33b300
leaq 0x211ba9(%rip), %rcx    # 0x30cfe0
movsd (%rcx), %xmm1
subsd (%rax), %xmm1
xorpd %xmm2, %xmm2
movapd %xmm1, %xmm3
cmpltsd %xmm2, %xmm3
subsd %xmm1, %xmm2
andpd %xmm3, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
ucomisd %xmm3, %xmm0
jbe 0xfb502
movl $0x7, %edi
movl $0xa, %esi
callq 0x6a4ce
movb $0x0, (%rbx)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xd3b42
leaq 0x11d377(%rip), %rax    # 0x218800
leaq 0x1280b4(%rip), %rcx    # 0x223544
imull $0x31a, (%rcx), %ecx    # imm = 0x31A
movslq %ecx, %rcx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x25, %rcx
addl %edx, %ecx
cmpl %ecx, (%rax)
leaq 0x39f47(%rip), %rax     # 0x1353fd
leaq 0x39f5c(%rip), %rdi     # 0x135419
cmovgq %rax, %rdi
movl $0xf, %esi
callq 0xfb514
leaq 0x142ece(%rip), %rbx    # 0x23e3a0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xfb4e6
callq 0x9370
movq $0x0, (%rbx)
leaq 0x2129ad(%rip), %rax    # 0x30de9a
movb $0x1, (%rax)
leaq 0x2129a5(%rip), %rax    # 0x30de9c
movl $0x0, (%rax)
jmp 0xfb3a3
xorl %edi, %edi
movl $0x2, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x6c6a4