// File: /workspace/github_cpp_makefile_star2_O3/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:
leaq 0x16a817(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0xd3bfe
leaq 0x16a8ba(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0xd3bfe
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %edx
testl %edi, %edi
js 0xd3bff
leaq 0x26776f(%rip), %rax    # 0x33b2f0
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x267768(%rip), %rax    # 0x33b2f8
cvtsd2ss (%rax), %xmm1
leaq 0x239435(%rip), %rax    # 0x30cfd0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x23942b(%rip), %rax    # 0x30cfd8
movsd %xmm0, (%rax)
leaq 0x267748(%rip), %rax    # 0x33b300
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x239416(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
cmpl $0x3, %edx
ja 0xd3db4
movl %edx, %eax
leaq 0x574b8(%rip), %rcx     # 0x12b098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x169d70(%rip), %rdi    # 0x23d960
leaq 0x5ecc9(%rip), %rsi     # 0x1328c0
movl $0x44, %edx
jmp 0xd3c6c
retq
movups 0x5eba5(%rip), %xmm0    # 0x1327ab
leaq 0x169d53(%rip), %rax    # 0x23d960
movaps %xmm0, 0x20(%rax)
movups 0x5eb83(%rip), %xmm0    # 0x13279b
movaps %xmm0, 0x10(%rax)
movups 0x5eb68(%rip), %xmm0    # 0x13278b
movaps %xmm0, (%rax)
movl $0x2e7379, 0x2f(%rax)   # imm = 0x2E7379
jmp 0xd3c71
leaq 0x169d2a(%rip), %rdi    # 0x23d960
leaq 0x5ebce(%rip), %rsi     # 0x13280b
movl $0x45, %edx
jmp 0xd3c6c
leaq 0x169d15(%rip), %rdi    # 0x23d960
leaq 0x5ebfe(%rip), %rsi     # 0x132850
movl $0x4b, %edx
jmp 0xd3c6c
leaq 0x169d00(%rip), %rdi    # 0x23d960
leaq 0x5eb57(%rip), %rsi     # 0x1327be
movl $0x4d, %edx
callq 0x92b0
movl $0x1, %edi
callq 0xc36e2
leaq 0x23934e(%rip), %r14    # 0x30cfd0
movsd (%r14), %xmm1
leaq 0x267662(%rip), %rax    # 0x33b2f0
movsd (%rax), %xmm0
subsd %xmm0, %xmm1
movsd 0x354c2(%rip), %xmm4    # 0x109160
mulsd %xmm4, %xmm1
leaq 0x23930f(%rip), %rax    # 0x30cfb8
movsd (%rax), %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, -0x28(%rbp)
leaq 0x23931b(%rip), %r15    # 0x30cfd8
movsd (%r15), %xmm3
leaq 0x26762f(%rip), %rax    # 0x33b2f8
movsd (%rax), %xmm1
subsd %xmm1, %xmm3
mulsd %xmm4, %xmm3
divsd %xmm2, %xmm3
leaq 0x2392e8(%rip), %rax    # 0x30cfc8
mulsd (%rax), %xmm3
movsd %xmm3, -0x20(%rbp)
leaq 0x267610(%rip), %rax    # 0x33b300
movsd (%rax), %xmm2
mulsd %xmm4, %xmm0
mulsd %xmm4, %xmm1
leaq 0x169c5d(%rip), %rbx    # 0x23d960
leaq 0x5ebfa(%rip), %rsi     # 0x132904
movq %rbx, %rdi
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0xc36e2
movsd (%r14), %xmm0
movsd 0x35435(%rip), %xmm1    # 0x109160
mulsd %xmm1, %xmm0
mulsd (%r15), %xmm1
leaq 0x2392a5(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm2
leaq 0x5ebe2(%rip), %rsi     # 0x132928
movq %rbx, %rdi
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0xc36e2
leaq 0x23925f(%rip), %rax    # 0x30cfc0
movq (%rax), %rcx
movsd -0x20(%rbp), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd -0x28(%rbp), %xmm0
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
xorps %xmm2, %xmm2
sqrtsd %xmm3, %xmm2
leaq 0x5ebbc(%rip), %rsi     # 0x13294c
movq %rbx, %rdi
movq %rcx, %rdx
movq %rcx, %r8
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc36e2
leaq 0x169ba5(%rip), %rdi    # 0x23d960
leaq 0x5ead9(%rip), %rsi     # 0x13289b
xorl %eax, %eax
callq 0x9060
jmp 0xd3c71