// File: /workspace/github_cpp_makefile_star2_O2/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 0x166128(%rip), %rax    # 0x228360
cmpq $0x0, (%rax)
je 0xc22e2
leaq 0x1661cb(%rip), %rax    # 0x228414
cmpb $0x0, (%rax)
je 0xc22e2
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %edx
testl %edi, %edi
js 0xc22e3
leaq 0x263082(%rip), %rax    # 0x3252f0
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x26307b(%rip), %rax    # 0x3252f8
cvtsd2ss (%rax), %xmm1
leaq 0x234d48(%rip), %rax    # 0x2f6fd0
movsd %xmm0, (%rax)
cvtss2sd %xmm1, %xmm0
leaq 0x234d41(%rip), %rax    # 0x2f6fd8
movsd %xmm0, (%rax)
leaq 0x26305e(%rip), %rax    # 0x325300
cvtsd2ss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x234d2f(%rip), %rax    # 0x2f6fe0
movsd %xmm0, (%rax)
cmpl $0x3, %edx
ja 0xc2488
movl %edx, %eax
leaq 0x52d11(%rip), %rcx     # 0x114fd8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x165689(%rip), %rdi    # 0x227960
leaq 0x5a502(%rip), %rsi     # 0x11c7e0
pushq $0x44
jmp 0xc2347
retq
movups 0x5a3e1(%rip), %xmm0    # 0x11c6cb
leaq 0x16566f(%rip), %rax    # 0x227960
movaps %xmm0, 0x20(%rax)
movups 0x5a3bf(%rip), %xmm0    # 0x11c6bb
movaps %xmm0, 0x10(%rax)
movups 0x5a3a4(%rip), %xmm0    # 0x11c6ab
movaps %xmm0, (%rax)
movl $0x2e7379, 0x2f(%rax)   # imm = 0x2E7379
jmp 0xc234d
leaq 0x165646(%rip), %rdi    # 0x227960
leaq 0x5a40a(%rip), %rsi     # 0x11c72b
pushq $0x45
jmp 0xc2347
leaq 0x165634(%rip), %rdi    # 0x227960
leaq 0x5a43d(%rip), %rsi     # 0x11c770
pushq $0x4b
jmp 0xc2347
leaq 0x165622(%rip), %rdi    # 0x227960
leaq 0x5a399(%rip), %rsi     # 0x11c6de
pushq $0x4d
popq %rdx
callq 0x92a0
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0xb25f5
leaq 0x234c72(%rip), %r15    # 0x2f6fd0
movsd (%r15), %xmm1
leaq 0x262f86(%rip), %rax    # 0x3252f0
movsd (%rax), %xmm0
subsd %xmm0, %xmm1
movsd 0x30de6(%rip), %xmm4    # 0xf3160
mulsd %xmm4, %xmm1
leaq 0x234c33(%rip), %rax    # 0x2f6fb8
movsd (%rax), %xmm2
divsd %xmm2, %xmm1
movsd %xmm1, -0x30(%rbp)
leaq 0x234c3f(%rip), %r12    # 0x2f6fd8
movsd (%r12), %xmm3
leaq 0x262f52(%rip), %rax    # 0x3252f8
movsd (%rax), %xmm1
subsd %xmm1, %xmm3
mulsd %xmm4, %xmm3
divsd %xmm2, %xmm3
leaq 0x234c0b(%rip), %rax    # 0x2f6fc8
mulsd (%rax), %xmm3
movsd %xmm3, -0x28(%rbp)
leaq 0x262f33(%rip), %rax    # 0x325300
movsd (%rax), %xmm2
mulsd %xmm4, %xmm0
mulsd %xmm4, %xmm1
leaq 0x165580(%rip), %r14    # 0x227960
leaq 0x5a43d(%rip), %rsi     # 0x11c824
movq %r14, %rdi
movb $0x3, %al
callq 0x9060
movl %ebx, %edi
callq 0xb25f5
movsd (%r15), %xmm0
movsd 0x30d5b(%rip), %xmm1    # 0xf3160
mulsd %xmm1, %xmm0
mulsd (%r12), %xmm1
leaq 0x234bca(%rip), %rax    # 0x2f6fe0
movsd (%rax), %xmm2
leaq 0x5a427(%rip), %rsi     # 0x11c848
movq %r14, %rdi
movb $0x3, %al
callq 0x9060
movl %ebx, %edi
callq 0xb25f5
leaq 0x234b87(%rip), %rax    # 0x2f6fc0
movq (%rax), %rcx
movsd -0x28(%rbp), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
movsd -0x30(%rbp), %xmm0
movapd %xmm0, %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
sqrtsd %xmm3, %xmm2
leaq 0x5a407(%rip), %rsi     # 0x11c86c
movq %r14, %rdi
movq %rcx, %rdx
movq %rcx, %r8
movb $0x3, %al
callq 0x9060
movl %ebx, %edi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xb25f5
leaq 0x1654d1(%rip), %rdi    # 0x227960
leaq 0x5a325(%rip), %rsi     # 0x11c7bb
xorl %eax, %eax
callq 0x9060
jmp 0xc234d