// File: /workspace/github_cpp_makefile_star2_O3/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 0x2ced54(%rip), %rax    # 0x33701a
cmpb $0x0, (%rax)
jne 0x6849c
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 0xb5e2e(%rip), %xmm1    # 0x11e148
movsd -0x38(%rbp), %xmm2
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd 0xa0d41(%rip), %xmm1    # 0x109070
movapd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x68346
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
jmp 0x68359
movapd %xmm1, %xmm0
movsd %xmm4, -0x30(%rbp)
callq 0x9270
movsd -0x30(%rbp), %xmm4
movsd 0xb5def(%rip), %xmm1    # 0x11e150
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 0x2a4c5d(%rip), %r12    # 0x30cfe8
movsd %xmm0, (%r12)
mulsd %xmm3, %xmm4
leaq 0x2a4c54(%rip), %r14    # 0x30cff0
mulsd 0xb5db4(%rip), %xmm1    # 0x11e158
movsd %xmm4, (%r14)
addsd %xmm2, %xmm1
movsd -0x38(%rbp), %xmm0
mulsd %xmm1, %xmm0
leaq 0x2a4c3b(%rip), %r15    # 0x30cff8
movsd %xmm0, (%r15)
leaq 0x2a4feb(%rip), %r13    # 0x30d3b4
movl (%r13), %eax
cmpl $0x1, %eax
ja 0x68495
movl $0x61d, %edi            # imm = 0x61D
movl $0x1c, %esi
callq 0x5f37d
movl %ebx, %edi
callq 0x592eb
movsd (%r12), %xmm0
mulsd 0xa0c66(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x592eb
movsd (%r14), %xmm0
mulsd 0xa0c50(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x592eb
movsd 0xa0c3f(%rip), %xmm0    # 0x109060
mulsd (%r15), %xmm0
cvttsd2si %xmm0, %edi
callq 0x592eb
cmpl $0x1, %ebx
jne 0x68450
movl $0xc350, %edi           # imm = 0xC350
callq 0x592eb
leaq 0x2a5a33(%rip), %rax    # 0x30de78
movl (%rax), %r14d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x6845d
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x592eb
xorl %r15d, %r15d
movl %r14d, %edi
callq 0x592eb
movl %r15d, %edi
callq 0x592eb
callq 0x5f456
movl $0x61d, %edi            # imm = 0x61D
xorl %esi, %esi
callq 0x5f37d
callq 0x5f456
movl (%r13), %eax
leaq 0x2a4b62(%rip), %r14    # 0x30cff0
leaq 0x2a4b63(%rip), %r15    # 0x30cff8
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
je 0x684ab
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 0x5f37d
movl %ebx, %edi
callq 0x592eb
movsd (%r12), %xmm0
mulsd 0xa0b91(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x592eb
movsd (%r14), %xmm0
mulsd 0xa0b7b(%rip), %xmm0    # 0x109060
cvttsd2si %xmm0, %edi
callq 0x592eb
movsd 0xa0b6a(%rip), %xmm0    # 0x109060
mulsd (%r15), %xmm0
cvttsd2si %xmm0, %edi
callq 0x592eb
cmpl $0x1, %ebx
jne 0x68524
movl $0xc350, %edi           # imm = 0xC350
callq 0x592eb
leaq 0x2a595e(%rip), %rax    # 0x30de78
movl (%rax), %ebx
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x68530
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x592eb
xorl %r14d, %r14d
movl %ebx, %edi
callq 0x592eb
movl %r14d, %edi
callq 0x592eb
callq 0x5f456
movl $0x63d, %edi            # imm = 0x63D
xorl %esi, %esi
callq 0x5f37d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5f456