// File: DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::filter(double*, double*, double const*, double const*, double const*, int, int)
extern int filter(double *x, double *P, const double *H, const double *v,
                  const double *R, int n, int m)
{
    double *x_,*xp_,*P_,*Pp_,*H_;
    int i,j,k,info,*ix;
    
    ix=imat(n,1); for (i=k=0;i<n;i++) if (x[i]!=0.0&&P[i+i*n]>0.0) ix[k++]=i;
    x_=mat(k,1); xp_=mat(k,1); P_=mat(k,k); Pp_=mat(k,k); H_=mat(k,m);
    for (i=0;i<k;i++) {
        x_[i]=x[ix[i]];
        for (j=0;j<k;j++) P_[i+j*k]=P[ix[i]+ix[j]*n];
        for (j=0;j<m;j++) H_[i+j*k]=H[ix[i]+j*n];
    }
    info=filter_(x_,P_,H_,v,R,k,m,xp_,Pp_);
    for (i=0;i<k;i++) {
        x[ix[i]]=xp_[i];
        for (j=0;j<k;j++) P[ix[i]+ix[j]*n]=Pp_[i+j*k];
    }
    free(ix); free(x_); free(xp_); free(P_); free(Pp_); free(H_);
    return info;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl -0x2c(%rbp), %edi
movl $0x1, %esi
callq 0x8c670
movq %rax, -0x70(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x8d75d
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8d717
jp 0x8d717
jmp 0x8d750
movq -0x10(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl -0x5c(%rbp), %edx
imull -0x2c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8d750
movl -0x5c(%rbp), %edx
movq -0x70(%rbp), %rax
movl -0x64(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x64(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x8d752
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8d6f5
movl -0x64(%rbp), %edi
movl $0x1, %esi
callq 0x8c500
movq %rax, -0x38(%rbp)
movl -0x64(%rbp), %edi
movl $0x1, %esi
callq 0x8c500
movq %rax, -0x40(%rbp)
movl -0x64(%rbp), %edi
movl -0x64(%rbp), %esi
callq 0x8c500
movq %rax, -0x48(%rbp)
movl -0x64(%rbp), %edi
movl -0x64(%rbp), %esi
callq 0x8c500
movq %rax, -0x50(%rbp)
movl -0x64(%rbp), %edi
movl 0x10(%rbp), %esi
callq 0x8c500
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x8d89d
movq -0x8(%rbp), %rax
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x8d83b
movq -0x10(%rbp), %rax
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movq -0x70(%rbp), %rdx
movslq -0x60(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
imull -0x2c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %edx
imull -0x64(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8d7e8
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0x8d88d
movq -0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl -0x60(%rbp), %edx
imull -0x2c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %edx
imull -0x64(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8d842
jmp 0x8d88f
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8d7b3
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x64(%rbp), %r9d
movl 0x10(%rbp), %r11d
movq -0x40(%rbp), %r10
movq -0x50(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x8d9c0
movl %eax, -0x68(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x8d976
movq -0x40(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x8d966
movq -0x50(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl -0x60(%rbp), %edx
imull -0x64(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x10(%rbp), %rax
movq -0x70(%rbp), %rcx
movslq -0x5c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movq -0x70(%rbp), %rdx
movslq -0x60(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
imull -0x2c(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x8d913
jmp 0x8d968
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8d8de
movq -0x70(%rbp), %rdi
callq 0x9900
movq -0x38(%rbp), %rdi
callq 0x9900
movq -0x40(%rbp), %rdi
callq 0x9900
movq -0x48(%rbp), %rdi
callq 0x9900
movq -0x50(%rbp), %rdi
callq 0x9900
movq -0x58(%rbp), %rdi
callq 0x9900
movl -0x68(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)