// File: 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
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
leaq 0x23fbfe(%rip), %rax    # 0x39a4c0
cmpb $0x0, (%rax)
je 0x15a952
leaq 0x23fbfe(%rip), %rax    # 0x39a4d0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8(%rbp)
leaq 0x23fbf2(%rip), %rax    # 0x39a4d8
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
leaq 0x23fbe6(%rip), %rax    # 0x39a4e0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x10(%rbp)
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x211899(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x21188d(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x211881(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
movl $0x2, %edi
callq 0x15a450
jmp 0x15aaec
leaq 0x21271f(%rip), %rax    # 0x36d078
cmpb $0x0, (%rax)
je 0x15aaea
leaq 0x23fb5b(%rip), %rax    # 0x39a4c4
cmpl $0x0, (%rax)
je 0x15aae8
movsd 0x357536(%rip), %xmm0   # 0x4b1eb0
leaq 0x23fb43(%rip), %rax    # 0x39a4c4
movl (%rax), %ecx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
leaq 0x23fb3d(%rip), %rcx    # 0x39a4d0
movsd %xmm0, (%rcx)
movsd 0x357519(%rip), %xmm0   # 0x4b1eb8
movl (%rax), %ecx
cvtsi2sd %rcx, %xmm1
divsd %xmm1, %xmm0
leaq 0x23fb27(%rip), %rcx    # 0x39a4d8
movsd %xmm0, (%rcx)
movsd 0x357503(%rip), %xmm0   # 0x4b1ec0
movl (%rax), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0x23fb11(%rip), %rax    # 0x39a4e0
movsd %xmm0, (%rax)
leaq 0x23fb0e(%rip), %rax    # 0x39a4e8
movl $0x1, (%rax)
leaq 0x23fae9(%rip), %rax    # 0x39a4d0
movsd (%rax), %xmm0
leaq 0x23fafe(%rip), %rax    # 0x39a4f0
movsd %xmm0, (%rax)
leaq 0x23fadb(%rip), %rax    # 0x39a4d8
movsd (%rax), %xmm0
leaq 0x23faf0(%rip), %rax    # 0x39a4f8
movsd %xmm0, (%rax)
leaq 0x23facd(%rip), %rax    # 0x39a4e0
movsd (%rax), %xmm0
leaq 0x23fae2(%rip), %rax    # 0x39a500
movsd %xmm0, (%rax)
leaq 0x23fac7(%rip), %rax    # 0x39a4f0
movsd (%rax), %xmm0
callq 0x96f0
leaq 0x21176f(%rip), %rax    # 0x36c1a8
movsd %xmm0, (%rax)
leaq 0x211764(%rip), %rax    # 0x36c1a8
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x15aa66
jp 0x15aa66
leaq 0x21174e(%rip), %rax    # 0x36c1a8
movsd 0x1472e(%rip), %xmm0    # 0x16f190
movsd %xmm0, (%rax)
leaq 0x23fa63(%rip), %rax    # 0x39a4d0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8(%rbp)
leaq 0x23fa57(%rip), %rax    # 0x39a4d8
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
leaq 0x23fa4b(%rip), %rax    # 0x39a4e0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x10(%rbp)
movss -0x8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2116fe(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2116f2(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movss -0x10(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2116e6(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
movl $0x3, %edi
callq 0x15a450
jmp 0x15aaea
jmp 0x15aaec
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)