// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::dops(int, double const*, double, double*)
extern void dops(int ns, const double *azel, double elmin, double *dop)
{
    double H[4*MAXRTKSAT],Q[16],cosel,sinel;
    int i,n;
    
    for (i=0;i<4;i++) dop[i]=0.0;
    for (i=n=0;i<ns&&i<MAXRTKSAT;i++) {
        if (azel[1+i*2]<elmin||azel[1+i*2]<=0.0) continue;
        cosel=cos(azel[1+i*2]);
        sinel=sin(azel[1+i*2]);
        H[  4*n]=cosel*sin(azel[i*2]);
        H[1+4*n]=cosel*cos(azel[i*2]);
        H[2+4*n]=sinel;
        H[3+4*n++]=1.0;
    }
    if (n<4) return;
    
    matmul("NT",4,4,n,1.0,H,H,0.0,Q);
    if (!matinv(Q,4)) {
        dop[0]=SQRT(Q[0]+Q[5]+Q[10]+Q[15]); /* GDOP */
        dop[1]=SQRT(Q[0]+Q[5]+Q[10]);       /* PDOP */
        dop[2]=SQRT(Q[0]+Q[5]);             /* HDOP */
        dop[3]=SQRT(Q[10]);                 /* VDOP */
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1408, %rsp           # imm = 0x1408
movq %rdx, %rbx
movapd %xmm0, %xmm1
movq %rsi, %r14
xorl %eax, %eax
cmpq $0x4, %rax
je 0x4b9f9
andq $0x0, (%rbx,%rax,8)
incq %rax
jmp 0x4b9e9
movslq %edi, %r12
addq $0x8, %r14
xorl %r13d, %r13d
xorl %r15d, %r15d
movsd %xmm1, -0x40(%rbp)
cmpq %r12, %r13
jge 0x4baea
cmpq $0x9a, %r13
ja 0x4baea
movsd (%r14), %xmm0
ucomisd %xmm0, %xmm1
ja 0x4bade
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm2
jae 0x4bade
callq 0x8bf0
movsd %xmm0, -0x30(%rbp)
movsd (%r14), %xmm0
callq 0x8160
movsd %xmm0, -0x38(%rbp)
movsd -0x8(%r14), %xmm0
callq 0x8160
mulsd -0x30(%rbp), %xmm0
leal (,%r15,4), %eax
cltq
movsd %xmm0, -0x1420(%rbp,%rax,8)
movsd -0x8(%r14), %xmm0
callq 0x8bf0
movsd -0x40(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm0
leal 0x1(,%r15,4), %eax
cltq
movsd %xmm0, -0x1420(%rbp,%rax,8)
leal 0x2(,%r15,4), %eax
cltq
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x1420(%rbp,%rax,8)
leal 0x3(,%r15,4), %eax
movl %r15d, %ecx
incl %ecx
cltq
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, -0x1420(%rbp,%rax,8)
movl %ecx, %r15d
incq %r13
addq $0x10, %r14
jmp 0x4ba0b
cmpl $0x4, %r15d
jl 0x4bc3e
leaq -0xc0(%rbp), %r14
movq %r14, (%rsp)
leaq 0x22f41(%rip), %rdi     # 0x6ea47
pushq $0x4
popq %r12
movsd 0x13e0e(%rip), %xmm0    # 0x5f920
leaq -0x1420(%rbp), %r8
xorpd %xmm1, %xmm1
movl %r12d, %esi
movl %r12d, %edx
movl %r15d, %ecx
movq %r8, %r9
callq 0x45f19
movq %r14, %rdi
movl %r12d, %esi
callq 0x46100
testl %eax, %eax
jne 0x4bc3e
movsd -0xc0(%rbp), %xmm3
movsd -0x70(%rbp), %xmm2
addsd -0x98(%rbp), %xmm3
movapd %xmm3, %xmm4
addsd %xmm2, %xmm4
movsd -0x48(%rbp), %xmm0
addsd %xmm4, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x4bba4
ucomisd %xmm1, %xmm0
jb 0x4bb7d
sqrtsd %xmm0, %xmm1
jmp 0x4bba4
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
movsd %xmm4, -0x40(%rbp)
callq 0x84e0
movsd -0x40(%rbp), %xmm4
movsd -0x38(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movapd %xmm0, %xmm1
movsd %xmm1, (%rbx)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm4
xorpd %xmm0, %xmm0
jb 0x4bbe3
ucomisd %xmm0, %xmm4
jb 0x4bbc2
sqrtsd %xmm4, %xmm0
jmp 0x4bbe3
movapd %xmm4, %xmm0
movsd %xmm2, -0x30(%rbp)
movsd %xmm3, -0x38(%rbp)
callq 0x84e0
xorpd %xmm1, %xmm1
movsd -0x38(%rbp), %xmm3
movsd -0x30(%rbp), %xmm2
movsd %xmm0, 0x8(%rbx)
ucomisd %xmm1, %xmm3
jb 0x4bc15
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jb 0x4bbfe
sqrtsd %xmm3, %xmm1
jmp 0x4bc15
movapd %xmm3, %xmm0
movsd %xmm2, -0x30(%rbp)
callq 0x84e0
movsd -0x30(%rbp), %xmm2
movapd %xmm0, %xmm1
movsd %xmm1, 0x10(%rbx)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jb 0x4bc39
ucomisd %xmm0, %xmm2
jb 0x4bc30
sqrtsd %xmm2, %xmm0
jmp 0x4bc39
movapd %xmm2, %xmm0
callq 0x84e0
movsd %xmm0, 0x18(%rbx)
addq $0x1408, %rsp           # imm = 0x1408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq