// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: abort_precise_survey(int)
void abort_precise_survey(int why)
{
float flat, flon, falt;

   if(check_precise_posn) {  // precise position found
      flat = (float) precise_lat;
      flon = (float) precise_lon;
      falt = (float) precise_alt;

      lat = (double) flat;
      lon = (double) flon;
      alt = (double) falt;
      save_precise_posn(2);  // save it using low res TSIP message
   }
   else if(precision_survey) {  // precise survey is incomplete
      if(precision_samples) {   // so save the average position
         precise_lat = lat_sum / (double)precision_samples;
         precise_lon = lon_sum / (double)precision_samples;
         precise_alt = alt_sum / (double)precision_samples;
         have_precise_lla = 1;
         ref_lat = precise_lat;
         ref_lon = precise_lon;
         ref_alt = precise_alt;
         cos_factor = cos(ref_lat);
         if(cos_factor == 0.0) cos_factor = 0.001;

         flat = (float) precise_lat;
         flon = (float) precise_lon;
         falt = (float) precise_alt;

         lat = (double) flat;
         lon = (double) flon;
         alt = (double) falt;
         save_precise_posn(3);
      }
   }
//if(lla_file) {
//   fprintf(lla_file, "### abort_precise_survey(%d): cpp:%d  ps:%d  samples:%d\n", why, check_precise_posn, precision_survey, precision_samples);
//   fprintf(lla_file, "### lla:%.9f %.9f %.9f\n", lat*180.0/PI,lon*180.0/PI,alt);
//}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x23f90b(%rip), %rax    # 0x33b2e0
movl $0x2, %edi
cmpb $0x0, (%rax)
jne 0xfbab5
leaq 0x2124ae(%rip), %rax    # 0x30de98
cmpb $0x0, (%rax)
setne %cl
leaq 0x23f8ed(%rip), %rax    # 0x33b2e4
movl (%rax), %eax
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xfbb18
movl %eax, %eax
cvtsi2sd %rax, %xmm1
movsd 0x356ea8(%rip), %xmm0   # 0x4528c0
divsd %xmm1, %xmm0
leaq 0x23f8cd(%rip), %rax    # 0x33b2f0
movsd %xmm0, (%rax)
movsd 0x356e99(%rip), %xmm2   # 0x4528c8
divsd %xmm1, %xmm2
leaq 0x23f8be(%rip), %rax    # 0x33b2f8
movsd %xmm2, (%rax)
movsd 0x356e8a(%rip), %xmm3   # 0x4528d0
divsd %xmm1, %xmm3
leaq 0x23f8af(%rip), %rax    # 0x33b300
movsd %xmm3, (%rax)
leaq 0x23f8ac(%rip), %rax    # 0x33b308
movl $0x1, (%rax)
leaq 0x23f8a7(%rip), %rax    # 0x33b310
movsd %xmm0, (%rax)
leaq 0x23f8a4(%rip), %rax    # 0x33b318
movsd %xmm2, (%rax)
leaq 0x23f8a1(%rip), %rax    # 0x33b320
movsd %xmm3, (%rax)
callq 0x9710
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0xfe97(%rip), %xmm2     # 0x10b930
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm1, %xmm2
leaq 0x21151c(%rip), %rax    # 0x30cfc8
movlpd %xmm2, (%rax)
movl $0x3, %edi
leaq 0x23f834(%rip), %rax    # 0x33b2f0
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
leaq 0x23f82e(%rip), %rax    # 0x33b2f8
xorps %xmm1, %xmm1
cvtsd2ss (%rax), %xmm1
leaq 0x23f828(%rip), %rax    # 0x33b300
xorps %xmm2, %xmm2
cvtsd2ss (%rax), %xmm2
cvtss2sd %xmm0, %xmm0
leaq 0x2114e6(%rip), %rax    # 0x30cfd0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x2114dc(%rip), %rax    # 0x30cfd8
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
leaq 0x2114d2(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
popq %rbp
jmp 0xfb5cf
popq %rbp
retq