// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: set_ubx_config(int, double, double, double)
void set_ubx_config(int mode, double slat,double slon,double salt)
{
   if(read_only) return;

   lla_to_ecef(slat, slon, salt);

   if((have_ubx_tmode == 0) || (have_ubx_tmode == 1)) {
      send_ubx_start(UBX_CFG_TMODE, 28);
      send_dword((u32) mode);
      send_dword((S32) (ecef_x*100.0));
      send_dword((S32) (ecef_y*100.0));
      send_dword((S32) (ecef_z*100.0));
      if(mode == 1) {
         send_dword(50000);       // fixed posn variance
         send_dword(do_survey);   // min survey time
         send_dword(0xFFFFFFFF);  // survey stop required variance (mm^2)
      }                           // ... we set to max value so survey is based only on time
      else {
         send_dword(0);   // fixed posn variance
         send_dword(0);   // min survey time
         send_dword(0);   // survey stop required variance (mm^2)
      }
      send_ubx_end();

      request_ubx_msg(UBX_CFG_TMODE);
   }


   // M8T survey / timing mode
   if((have_ubx_tmode == 0) || (have_ubx_tmode == 2)) {
      send_ubx_start(UBX_CFG_TMODE2, 28);
      send_dword((u32) mode);
      send_dword((S32) (ecef_x*100.0));
      send_dword((S32) (ecef_y*100.0));
      send_dword((S32) (ecef_z*100.0));
      if(mode == 1) {
         send_dword(50000);       // fixed posn variance
         send_dword(do_survey);   // min survey time
         send_dword(0xFFFFFFFF);  // survey stop required variance (mm^2)
      }                           // ... we set to max value so survey is based only on time
      else {
         send_dword(0);   // fixed posn variance
         send_dword(0);   // min survey time
         send_dword(0);   // survey stop required variance (mm^2)
      }
      send_ubx_end();

      request_ubx_msg(UBX_CFG_TMODE2);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x2ceee7(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0x68306
movl %edi, %ebx
movsd %xmm2, -0x50(%rbp)
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
callq 0x9710
movsd %xmm0, -0x48(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x9080
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x9710
movsd %xmm0, -0x40(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x9080
movsd 0xb5f19(%rip), %xmm1    # 0x11e0a0
movsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd 0xa0ed4(%rip), %xmm1    # 0x109070
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x681b3
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x681c6
movapd %xmm1, %xmm0
movsd %xmm4, -0x30(%rbp)
callq 0x9270
movsd -0x30(%rbp), %xmm4
movsd 0xb5eda(%rip), %xmm1    # 0x11e0a8
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm2
addsd %xmm2, %xmm0
movsd -0x48(%rbp), %xmm3
mulsd %xmm0, %xmm3
movsd -0x40(%rbp), %xmm0
mulsd %xmm3, %xmm0
leaq 0x2a4df0(%rip), %r12    # 0x30cfe8
movsd %xmm0, (%r12)
mulsd %xmm3, %xmm4
leaq 0x2a4de7(%rip), %r14    # 0x30cff0
mulsd 0xb5e9f(%rip), %xmm1    # 0x11e0b0
movsd %xmm4, (%r14)
addsd %xmm2, %xmm1
movsd -0x38(%rbp), %xmm0
mulsd %xmm1, %xmm0
leaq 0x2a4dce(%rip), %r15    # 0x30cff8
movsd %xmm0, (%r15)
leaq 0x2a517e(%rip), %r13    # 0x30d3b4
cmpl $0x1, (%r13)
ja 0x682fc
movl $0x61d, %edi            # imm = 0x61D
movl $0x1c, %esi
callq 0x5f3f5
movl %ebx, %edi
callq 0x593b5
movsd (%r12), %xmm0
mulsd 0xa0dfb(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x593b5
movsd (%r14), %xmm0
mulsd 0xa0de5(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x593b5
movsd 0xa0dd4(%rip), %xmm0    # 0x109060
mulsd (%r15), %xmm0
cvttsd2si %xmm0, %edi
callq 0x593b5
cmpl $0x1, %ebx
jne 0x682bb
movl $0xc350, %edi           # imm = 0xC350
callq 0x593b5
leaq 0x2a5bc8(%rip), %rax    # 0x30de78
movl (%rax), %r14d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x682c8
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x593b5
xorl %r15d, %r15d
movl %r14d, %edi
callq 0x593b5
movl %r15d, %edi
callq 0x593b5
callq 0x5f4ce
movl $0x61d, %edi            # imm = 0x61D
xorl %esi, %esi
callq 0x5f3f5
callq 0x5f4ce
leaq 0x2a4cfb(%rip), %r14    # 0x30cff0
leaq 0x2a4cfc(%rip), %r15    # 0x30cff8
testl $0xfffffffd, (%r13)     # imm = 0xFFFFFFFD
je 0x68315
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x63d, %edi            # imm = 0x63D
movl $0x1c, %esi
callq 0x5f3f5
movl %ebx, %edi
callq 0x593b5
movsd (%r12), %xmm0
mulsd 0xa0d27(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x593b5
movsd (%r14), %xmm0
mulsd 0xa0d11(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x593b5
movsd 0xa0d00(%rip), %xmm0    # 0x109060
mulsd (%r15), %xmm0
cvttsd2si %xmm0, %edi
callq 0x593b5
cmpl $0x1, %ebx
jne 0x6838e
movl $0xc350, %edi           # imm = 0xC350
callq 0x593b5
leaq 0x2a5af4(%rip), %rax    # 0x30de78
movl (%rax), %ebx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x6839a
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x593b5
xorl %r14d, %r14d
movl %ebx, %edi
callq 0x593b5
movl %r14d, %edi
callq 0x593b5
callq 0x5f4ce
movl $0x63d, %edi            # imm = 0x63D
xorl %esi, %esi
callq 0x5f3f5
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f4ce