// File: /workspace/github_cpp_makefile_star2_O1/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 0x240086(%rip), %rax    # 0x33b2e0
movl $0x2, %edi
cmpb $0x0, (%rax)
jne 0xfb33a
leaq 0x212c29(%rip), %rax    # 0x30de98
cmpb $0x0, (%rax)
setne %cl
leaq 0x240068(%rip), %rax    # 0x33b2e4
movl (%rax), %eax
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0xfb39d
movl %eax, %eax
cvtsi2sd %rax, %xmm1
movsd 0x357703(%rip), %xmm0   # 0x4529a0
divsd %xmm1, %xmm0
leaq 0x240048(%rip), %rax    # 0x33b2f0
movsd %xmm0, (%rax)
movsd 0x3576f4(%rip), %xmm2   # 0x4529a8
divsd %xmm1, %xmm2
leaq 0x240039(%rip), %rax    # 0x33b2f8
movsd %xmm2, (%rax)
movsd 0x3576e5(%rip), %xmm3   # 0x4529b0
divsd %xmm1, %xmm3
leaq 0x24002a(%rip), %rax    # 0x33b300
movsd %xmm3, (%rax)
leaq 0x240027(%rip), %rax    # 0x33b308
movl $0x1, (%rax)
leaq 0x240022(%rip), %rax    # 0x33b310
movsd %xmm0, (%rax)
leaq 0x24001f(%rip), %rax    # 0x33b318
movsd %xmm2, (%rax)
leaq 0x24001c(%rip), %rax    # 0x33b320
movsd %xmm3, (%rax)
callq 0x9710
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0x1060a(%rip), %xmm2    # 0x10b928
andpd %xmm1, %xmm2
andnpd %xmm0, %xmm1
orpd %xmm1, %xmm2
leaq 0x211c97(%rip), %rax    # 0x30cfc8
movlpd %xmm2, (%rax)
movl $0x3, %edi
leaq 0x23ffaf(%rip), %rax    # 0x33b2f0
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
leaq 0x23ffa9(%rip), %rax    # 0x33b2f8
xorps %xmm1, %xmm1
cvtsd2ss (%rax), %xmm1
leaq 0x23ffa3(%rip), %rax    # 0x33b300
xorps %xmm2, %xmm2
cvtsd2ss (%rax), %xmm2
cvtss2sd %xmm0, %xmm0
leaq 0x211c61(%rip), %rax    # 0x30cfd0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x211c57(%rip), %rax    # 0x30cfd8
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
leaq 0x211c4d(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
popq %rbp
jmp 0xfae54
popq %rbp
retq