// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
leaq 0x2132c1(%rip), %rax    # 0x30dea1
cmpb $0x0, (%rax)
jne 0xfac02
leaq 0x2406f4(%rip), %rbx    # 0x33b2e0
cmpb $0x0, (%rbx)
je 0xfac02
leaq 0x2406e9(%rip), %rax    # 0x33b2e1
movb (%rax), %cl
testb %cl, %cl
je 0xfac09
decb %cl
movb %cl, (%rax)
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2123c0(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
leaq 0x2406d5(%rip), %rax    # 0x33b2f0
subsd (%rax), %xmm0
movsd 0xe531(%rip), %xmm1     # 0x109158
mulsd %xmm1, %xmm0
leaq 0x212386(%rip), %rax    # 0x30cfb8
movsd (%rax), %xmm2
leaq 0x21239b(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm3
leaq 0x2406b0(%rip), %rax    # 0x33b2f8
subsd (%rax), %xmm3
divsd %xmm2, %xmm0
mulsd %xmm1, %xmm3
divsd %xmm2, %xmm3
leaq 0x212369(%rip), %rax    # 0x30cfc8
mulsd (%rax), %xmm3
leaq 0x212376(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm4
leaq 0x24068b(%rip), %rax    # 0x33b300
movsd (%rax), %xmm2
mulsd %xmm3, %xmm3
mulsd %xmm0, %xmm0
addsd %xmm3, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xfac95
sqrtsd %xmm0, %xmm0
jmp 0xfacae
movapd %xmm4, -0x20(%rbp)
movsd %xmm2, -0x10(%rbp)
callq 0x9270
movsd -0x10(%rbp), %xmm2
movapd -0x20(%rbp), %xmm4
movsd 0xe3ba(%rip), %xmm1     # 0x109070
ucomisd %xmm0, %xmm1
jb 0xfad87
subsd %xmm2, %xmm4
xorpd %xmm0, %xmm0
movapd %xmm4, %xmm2
cmpltsd %xmm0, %xmm2
subsd %xmm4, %xmm0
andpd %xmm2, %xmm0
andnpd %xmm4, %xmm2
orpd %xmm0, %xmm2
ucomisd %xmm2, %xmm1
jbe 0xfad87
movl $0x7, %edi
movl $0xa, %esi
callq 0x6a306
movb $0x0, (%rbx)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0xd340d
leaq 0x11daf2(%rip), %rax    # 0x218800
leaq 0x12882f(%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 0x3a5d2(%rip), %rax     # 0x13530d
leaq 0x3a5e7(%rip), %rdi     # 0x135329
cmovgq %rax, %rdi
movl $0xf, %esi
callq 0xfad99
leaq 0x143649(%rip), %rbx    # 0x23e3a0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0xfad6b
callq 0x9370
movq $0x0, (%rbx)
leaq 0x213128(%rip), %rax    # 0x30de9a
movb $0x1, (%rax)
leaq 0x213120(%rip), %rax    # 0x30de9c
movl $0x0, (%rax)
jmp 0xfac02
xorl %edi, %edi
movl $0x2, %esi
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0x6c67b