// File: /workspace/github_cpp_makefile_star2_O1/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 0x16af4c(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0xd34c9
leaq 0x16afef(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0xd34c9
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %edx
testl %edi, %edi
js 0xd34ca
leaq 0x267ea4(%rip), %rax    # 0x33b2f0
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x267e9d(%rip), %rax    # 0x33b2f8
cvtsd2ss (%rax), %xmm1
leaq 0x239b6a(%rip), %rax    # 0x30cfd0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
leaq 0x239b60(%rip), %rax    # 0x30cfd8
movsd %xmm0, (%rax)
leaq 0x267e7d(%rip), %rax    # 0x33b300
xorps %xmm0, %xmm0
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x239b4b(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
cmpl $0x3, %edx
ja 0xd369d
movl %edx, %eax
leaq 0x57b1d(%rip), %rcx     # 0x12afc8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x16a4a5(%rip), %rdi    # 0x23d960
leaq 0x5f30e(%rip), %rsi     # 0x1327d0
movl $0x44, %edx
jmp 0xd3537
retq
movups 0x5f1ea(%rip), %xmm0    # 0x1326bb
leaq 0x16a488(%rip), %rax    # 0x23d960
movaps %xmm0, 0x20(%rax)
movups 0x5f1c8(%rip), %xmm0    # 0x1326ab
movaps %xmm0, 0x10(%rax)
movups 0x5f1ad(%rip), %xmm0    # 0x13269b
movaps %xmm0, (%rax)
movl $0x2e7379, 0x2f(%rax)   # imm = 0x2E7379
jmp 0xd353c
leaq 0x16a45f(%rip), %rdi    # 0x23d960
leaq 0x5f213(%rip), %rsi     # 0x13271b
movl $0x45, %edx
jmp 0xd3537
leaq 0x16a44a(%rip), %rdi    # 0x23d960
leaq 0x5f243(%rip), %rsi     # 0x132760
movl $0x4b, %edx
jmp 0xd3537
leaq 0x16a435(%rip), %rdi    # 0x23d960
leaq 0x5f19c(%rip), %rsi     # 0x1326ce
movl $0x4d, %edx
callq 0x92b0
movl $0x1, %edi
callq 0xc3105
leaq 0x239a83(%rip), %r14    # 0x30cfd0
movsd (%r14), %xmm1
leaq 0x267d97(%rip), %rax    # 0x33b2f0
movsd (%rax), %xmm0
subsd %xmm0, %xmm1
movsd 0x35bef(%rip), %xmm4    # 0x109158
mulsd %xmm4, %xmm1
leaq 0x239a44(%rip), %rax    # 0x30cfb8
movsd (%rax), %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, -0x28(%rbp)
leaq 0x239a50(%rip), %r15    # 0x30cfd8
movsd (%r15), %xmm3
leaq 0x267d64(%rip), %rax    # 0x33b2f8
movsd (%rax), %xmm1
subsd %xmm1, %xmm3
mulsd %xmm4, %xmm3
divsd %xmm2, %xmm3
leaq 0x239a1d(%rip), %rax    # 0x30cfc8
mulsd (%rax), %xmm3
movsd %xmm3, -0x20(%rbp)
leaq 0x267d45(%rip), %rax    # 0x33b300
movsd (%rax), %xmm2
mulsd %xmm4, %xmm0
mulsd %xmm4, %xmm1
leaq 0x16a392(%rip), %rbx    # 0x23d960
leaq 0x5f23f(%rip), %rsi     # 0x132814
movq %rbx, %rdi
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0xc3105
movsd (%r14), %xmm0
movsd 0x35b62(%rip), %xmm1    # 0x109158
mulsd %xmm1, %xmm0
mulsd (%r15), %xmm1
leaq 0x2399da(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm2
leaq 0x5f227(%rip), %rsi     # 0x132838
movq %rbx, %rdi
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
callq 0xc3105
leaq 0x239994(%rip), %r14    # 0x30cfc0
movq (%r14), %rbx
movsd -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm1
movsd -0x28(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xd3658
xorps %xmm2, %xmm2
sqrtsd %xmm0, %xmm2
jmp 0xd3661
callq 0x9270
movapd %xmm0, %xmm2
movq (%r14), %r8
leaq 0x16a2f5(%rip), %rdi    # 0x23d960
leaq 0x5f1ea(%rip), %rsi     # 0x13285c
movsd -0x28(%rbp), %xmm0
movq %rbx, %rdx
movsd -0x20(%rbp), %xmm1
movq %rbx, %rcx
movb $0x3, %al
callq 0x9060
movl $0x1, %edi
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc3105
leaq 0x16a2bc(%rip), %rdi    # 0x23d960
leaq 0x5f100(%rip), %rsi     # 0x1327ab
xorl %eax, %eax
callq 0x9060
jmp 0xd353c