// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1418, %rsp           # imm = 0x1418
movapd %xmm0, %xmm1
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rdx)
movq %rdx, -0x48(%rbp)
movupd %xmm0, (%rdx)
testl %edi, %edi
jle 0x54eaa
movq %rsi, %r14
decl %edi
movl $0x9a, %r12d
cmpq %r12, %rdi
cmovbq %rdi, %r12
shll $0x4, %r12d
addq $0x10, %r12
xorl %r13d, %r13d
movabsq $0x3ff0000000000000, %rbx # imm = 0x3FF0000000000000
xorl %r15d, %r15d
movsd %xmm1, -0x40(%rbp)
movsd 0x8(%r14,%r13), %xmm0
ucomisd %xmm0, %xmm1
ja 0x54e9b
xorpd %xmm2, %xmm2
ucomisd %xmm0, %xmm2
jae 0x54e9b
callq 0x8c00
movsd %xmm0, -0x30(%rbp)
movsd 0x8(%r14,%r13), %xmm0
callq 0x8150
movsd %xmm0, -0x38(%rbp)
movsd (%r14,%r13), %xmm0
callq 0x8150
mulsd -0x30(%rbp), %xmm0
leal (,%r15,4), %eax
cltq
movsd %xmm0, -0x1430(%rbp,%rax,8)
movsd (%r14,%r13), %xmm0
callq 0x8c00
movsd -0x40(%rbp), %xmm1
mulsd -0x30(%rbp), %xmm0
leal 0x1(,%r15,4), %eax
cltq
movsd %xmm0, -0x1430(%rbp,%rax,8)
leal 0x2(,%r15,4), %eax
cltq
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x1430(%rbp,%rax,8)
leal 0x3(,%r15,4), %eax
movl %r15d, %ecx
incl %ecx
cltq
movq %rbx, -0x1430(%rbp,%rax,8)
movl %ecx, %r15d
addq $0x10, %r13
cmpq %r13, %r12
jne 0x54de4
jmp 0x54ead
xorl %r15d, %r15d
cmpl $0x4, %r15d
jl 0x55013
leaq -0xd0(%rbp), %r14
movq %r14, (%rsp)
leaq 0x23bd2(%rip), %rdi     # 0x78a9b
movsd 0x14a4f(%rip), %xmm0    # 0x69920
leaq -0x1430(%rbp), %r8
xorpd %xmm1, %xmm1
movl $0x4, %esi
movl $0x4, %edx
movl %r15d, %ecx
movq %r8, %r9
callq 0x4e91f
movq %r14, %rdi
movl $0x4, %esi
callq 0x4eb12
testl %eax, %eax
jne 0x55013
movsd -0xd0(%rbp), %xmm3
movsd -0x80(%rbp), %xmm2
addsd -0xa8(%rbp), %xmm3
movapd %xmm3, %xmm4
addsd %xmm2, %xmm4
movsd -0x58(%rbp), %xmm0
addsd %xmm4, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movq -0x48(%rbp), %rbx
jb 0x54f70
ucomisd %xmm1, %xmm0
jb 0x54f49
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x54f70
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 0x54fb2
ucomisd %xmm0, %xmm4
jb 0x54f91
xorps %xmm0, %xmm0
sqrtsd %xmm4, %xmm0
jmp 0x54fb2
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 0x54fe7
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm3
jb 0x54fd0
xorps %xmm1, %xmm1
sqrtsd %xmm3, %xmm1
jmp 0x54fe7
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 0x5500e
ucomisd %xmm0, %xmm2
jb 0x55005
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x5500e
movapd %xmm2, %xmm0
callq 0x84e0
movsd %xmm0, 0x18(%rbx)
addq $0x1418, %rsp           # imm = 0x1418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq