// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::csmooth(bamboo::obs_t*, int)
extern void csmooth(obs_t *obs, int ns)
{
    double Ps[2][MAXRTKSAT][NFREQ]={{{0}}},Lp[2][MAXRTKSAT][NFREQ]={{{0}}},dcp;
    int i,j,s,r,n[2][MAXRTKSAT][NFREQ]={{{0}}};
    obsd_t *p;
    
    trace(3,"csmooth: nobs=%d,ns=%d\n",obs->n,ns);
    
    for (i=0;i<obs->n;i++) {
        p=&obs->data[i]; s=p->sat; r=p->rcv;
        for (j=0;j<NFREQ;j++) {
            if (s<=0||MAXRTKSAT<s||r<=0||2<r) continue;
            if (p->P[j]==0.0||p->L[j]==0.0) continue;
            if (p->LLI[j]) n[r-1][s-1][j]=0;
            if (n[r-1][s-1][j]==0) Ps[r-1][s-1][j]=p->P[j];
            else {
                dcp=lam_carr[j]*(p->L[j]-Lp[r-1][s-1][j]);
                Ps[r-1][s-1][j]=p->P[j]/ns+(Ps[r-1][s-1][j]+dcp)*(ns-1)/ns;
            }
            if (++n[r-1][s-1][j]<ns) p->P[j]=0.0; else p->P[j]=Ps[r-1][s-1][j];
            Lp[r-1][s-1][j]=p->L[j];
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48a8, %rsp           # imm = 0x48A8
movl %esi, %ebx
movq %rdi, %r14
leaq -0x48d0(%rbp), %rdi
movl $0x1d10, %edx           # imm = 0x1D10
xorl %esi, %esi
callq 0x8390
leaq -0x2bc0(%rbp), %rdi
movl $0x1d10, %edx           # imm = 0x1D10
xorl %esi, %esi
callq 0x8390
leaq -0xeb0(%rbp), %rdi
movl $0xe88, %edx            # imm = 0xE88
xorl %esi, %esi
callq 0x8390
movslq (%r14), %rax
testq %rax, %rax
jle 0x55a49
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cvtsi2sd %ebx, %xmm0
movq 0x8(%r14), %rdx
leal -0x1(%rbx), %esi
cvtsi2sd %esi, %xmm1
xorl %esi, %esi
leaq 0x1b2e1(%rip), %rdi     # 0x70bf0
xorpd %xmm2, %xmm2
movq %rdx, %r8
leaq (%rsi,%rsi,2), %r9
shlq $0x5, %r9
movzbl 0x10(%rdx,%r9), %r10d
movzbl 0x11(%rdx,%r9), %r11d
leal 0x64(%r10), %r9d
cmpb $0x65, %r9b
setb %r14b
leal -0x3(%r11), %r9d
cmpb $-0x2, %r9b
setb %r9b
orb %r14b, %r9b
addl %ecx, %r11d
addl %ecx, %r10d
imulq $0x744, %r11, %r14      # imm = 0x744
leaq (%r10,%r10,2), %r15
leaq (%r14,%r15,4), %r10
addq %rbp, %r10
addq $-0xeb0, %r10           # imm = 0xF150
imulq $0xe88, %r11, %r11      # imm = 0xE88
leaq (%r11,%r15,8), %r14
leaq (%r14,%rbp), %r11
addq $-0x2bc0, %r11          # imm = 0xD440
addq %rbp, %r14
addq $-0x48d0, %r14          # imm = 0xB730
movq %rdi, %r15
xorl %r12d, %r12d
testb %r9b, %r9b
jne 0x55a28
movsd 0x38(%r8,%r12,8), %xmm3
ucomisd %xmm2, %xmm3
jne 0x559a6
jnp 0x55a28
movsd 0x20(%r8,%r12,8), %xmm4
ucomisd %xmm2, %xmm4
jne 0x559b5
jnp 0x55a28
cmpb $0x0, 0x15(%r8,%r12)
je 0x559d3
movl $0x0, (%r10,%r12,4)
movsd %xmm3, (%r14,%r12,8)
movl $0x1, %r13d
jmp 0x55a0a
movl (%r10,%r12,4), %r13d
testl %r13d, %r13d
je 0x559c5
movapd %xmm4, %xmm5
subsd (%r11,%r12,8), %xmm5
mulsd (%r15), %xmm5
divsd %xmm0, %xmm3
addsd (%r14,%r12,8), %xmm5
mulsd %xmm1, %xmm5
divsd %xmm0, %xmm5
addsd %xmm5, %xmm3
movsd %xmm3, (%r14,%r12,8)
incl %r13d
movl %r13d, (%r10,%r12,4)
xorpd %xmm5, %xmm5
cmpl %ebx, %r13d
jl 0x55a1b
movapd %xmm3, %xmm5
movsd %xmm5, 0x38(%r8,%r12,8)
movsd %xmm4, (%r11,%r12,8)
incq %r12
addq $0x8, %r15
cmpq $0x3, %r12
jne 0x5598a
incq %rsi
addq $0x60, %r8
cmpq %rax, %rsi
jne 0x55916
addq $0x48a8, %rsp           # imm = 0x48A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq