// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: log_saved_posn(int)
void log_saved_posn(int type)
{
double d_lat, d_lon, d_alt;
float x;

   if(log_file == 0) return;  
   if(log_comments == 0) return;

   if(type < 0) {  // position saved via repeated single point surveys
      sprintf(log_text, "#Position saved via repeated single point surveys.");
      write_log_comment(1);
   }
   else {  // position saved via TSIP message
      x = (float) precise_lat;   lat = (double) x;
      x = (float) precise_lon;   lon = (double) x;
      x = (float) precise_alt;   alt = (double) x;
      if     (type == 1) sprintf(log_text, "#User stopped precise save of manually entered position.  TSIP message used.");
      else if(type == 2) sprintf(log_text, "#User stopped precise save of surveyed position.  TSIP message used.");
      else if(type == 3) sprintf(log_text, "#User stopped precise survey.  Averaged position saved using TSIP message.");
      else if(type)      sprintf(log_text, "#Precise survey stopped.  Reason=%d.", type);
      else {
         sprintf(log_text, "#Position saved via TSIP message.  Roundoff error is small enough.\n");
      }
      write_log_comment(1);
   }

   // log how and why we saved a receiver position
   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);

   sprintf(log_text, "#DESIRED POSITION: %.9f  %.9f  %.9f",
                        precise_lat*RAD_TO_DEG, precise_lon*RAD_TO_DEG, precise_alt);
   write_log_comment(1);

   sprintf(log_text, "#SAVED POSITION:   %.9f  %.9f  %.9f",
                        lat*RAD_TO_DEG, lon*RAD_TO_DEG, alt);
   write_log_comment(1);

   sprintf(log_text, "#ROUNDOFF ERROR:   lat: %.9f %s   lon: %.9f %s   rms: %.9f %s", 
      d_lat,angle_units,  d_lon,angle_units,  sqrt(d_lat*d_lat + d_lon*d_lon),angle_units);
   write_log_comment(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
leaq 0x17c56e(%rip), %rax    # 0x29d540
cmpq $0x0, (%rax)
jne 0x120fdd
jmp 0x1212e8
leaq 0x17c610(%rip), %rax    # 0x29d5f4
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x120ff1
jmp 0x1212e8
cmpl $0x0, -0x4(%rbp)
jge 0x12101b
leaq 0x17bb42(%rip), %rdi    # 0x29cb40
leaq 0x742b8(%rip), %rsi     # 0x1952bd
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
jmp 0x12112f
leaq 0x2794ae(%rip), %rax    # 0x39a4d0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x24b171(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
leaq 0x27948e(%rip), %rax    # 0x39a4d8
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x24b151(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
leaq 0x27946e(%rip), %rax    # 0x39a4e0
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x24b131(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
cmpl $0x1, -0x4(%rbp)
jne 0x1210b0
leaq 0x17baa0(%rip), %rdi    # 0x29cb40
leaq 0x74249(%rip), %rsi     # 0x1952f0
movb $0x0, %al
callq 0x9060
jmp 0x121125
cmpl $0x2, -0x4(%rbp)
jne 0x1210cd
leaq 0x17ba83(%rip), %rdi    # 0x29cb40
leaq 0x74279(%rip), %rsi     # 0x19533d
movb $0x0, %al
callq 0x9060
jmp 0x121123
cmpl $0x3, -0x4(%rbp)
jne 0x1210ea
leaq 0x17ba66(%rip), %rdi    # 0x29cb40
leaq 0x742a1(%rip), %rsi     # 0x195382
movb $0x0, %al
callq 0x9060
jmp 0x121121
cmpl $0x0, -0x4(%rbp)
je 0x12110a
movl -0x4(%rbp), %edx
leaq 0x17ba46(%rip), %rdi    # 0x29cb40
leaq 0x742cc(%rip), %rsi     # 0x1953cd
movb $0x0, %al
callq 0x9060
jmp 0x12111f
leaq 0x17ba2f(%rip), %rdi    # 0x29cb40
leaq 0x742da(%rip), %rsi     # 0x1953f2
movb $0x0, %al
callq 0x9060
jmp 0x121121
jmp 0x121123
jmp 0x121125
movl $0x1, %edi
callq 0x10cbe0
leaq 0x24b07a(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
leaq 0x27938f(%rip), %rax    # 0x39a4d0
subsd (%rax), %xmm0
movsd 0x4e033(%rip), %xmm1    # 0x16f180
mulsd %xmm1, %xmm0
leaq 0x24b040(%rip), %rax    # 0x36c198
divsd (%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x24b050(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm0
leaq 0x279365(%rip), %rax    # 0x39a4d8
subsd (%rax), %xmm0
movsd 0x4e001(%rip), %xmm1    # 0x16f180
mulsd %xmm1, %xmm0
leaq 0x24b00e(%rip), %rax    # 0x36c198
divsd (%rax), %xmm0
leaq 0x24b013(%rip), %rax    # 0x36c1a8
mulsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x24b01b(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm0
leaq 0x279330(%rip), %rax    # 0x39a4e0
subsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd 0x4dfbf(%rip), %xmm0    # 0x16f180
leaq 0x279308(%rip), %rax    # 0x39a4d0
mulsd (%rax), %xmm0
movsd 0x4dfac(%rip), %xmm1    # 0x16f180
leaq 0x2792fd(%rip), %rax    # 0x39a4d8
mulsd (%rax), %xmm1
leaq 0x2792fa(%rip), %rax    # 0x39a4e0
movsd (%rax), %xmm2
leaq 0x17b94f(%rip), %rdi    # 0x29cb40
leaq 0x7423e(%rip), %rsi     # 0x195436
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movsd 0x4df6f(%rip), %xmm0    # 0x16f180
leaq 0x24af98(%rip), %rax    # 0x36c1b0
mulsd (%rax), %xmm0
movsd 0x4df5c(%rip), %xmm1    # 0x16f180
leaq 0x24af8d(%rip), %rax    # 0x36c1b8
mulsd (%rax), %xmm1
leaq 0x24af8a(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm2
leaq 0x17b8ff(%rip), %rdi    # 0x29cb40
leaq 0x74212(%rip), %rsi     # 0x19545a
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
leaq 0x24af36(%rip), %rax    # 0x36c1a0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq 0x24af1e(%rip), %rax    # 0x36c1a0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
mulsd -0x18(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x9280
movq -0x48(%rbp), %rdx
movsd -0x40(%rbp), %xmm1
movq -0x38(%rbp), %rcx
movaps %xmm0, %xmm2
movsd -0x30(%rbp), %xmm0
leaq 0x24aeda(%rip), %rax    # 0x36c1a0
movq (%rax), %r8
leaq 0x17b870(%rip), %rdi    # 0x29cb40
leaq 0x741a7(%rip), %rsi     # 0x19547e
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
addq $0x50, %rsp
popq %rbp
retq
nop