// File: /workspace/github_cpp_makefile_star2_O2/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
xorl %r12d, %r12d
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
cvtsi2sd %ebx, %xmm0
leal -0x1(%rbx), %eax
cvtsi2sd %eax, %xmm1
movl (%r14), %eax
testl %eax, %eax
cmovlel %r12d, %eax
xorpd %xmm2, %xmm2
pushq $0x1
popq %r15
xorl %esi, %esi
cmpq %rax, %rsi
je 0x4cf34
movq 0x8(%r14), %rdi
imulq $0x60, %rsi, %rdx
movzbl 0x10(%rdi,%rdx), %ecx
movzbl 0x11(%rdi,%rdx), %edx
leal 0x64(%rcx), %r8d
cmpb $0x65, %r8b
setb %r9b
leal -0x3(%rdx), %r8d
cmpb $-0x2, %r8b
setb %r8b
orb %r9b, %r8b
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
addl %r9d, %edx
addl %r9d, %ecx
imulq $0x744, %rdx, %r9       # imm = 0x744
imulq $0xc, %rcx, %r10
addq %r9, %r10
leaq (%r10,%rbp), %r9
addq $-0xeb0, %r9            # imm = 0xF150
addq %r12, %rdi
imulq $0xe88, %rdx, %rdx      # imm = 0xE88
imulq $0x18, %rcx, %rcx
addq %rdx, %rcx
leaq (%rcx,%rbp), %r10
addq $-0x2bc0, %r10          # imm = 0xD440
leaq (%rcx,%rbp), %r11
addq $-0x48d0, %r11          # imm = 0xB730
leaq 0x19d6e(%rip), %r13     # 0x66bf0
xorl %ecx, %ecx
cmpq $0x3, %rcx
je 0x4cf28
testb %r8b, %r8b
jne 0x4cf1c
movsd 0x38(%rdi,%rcx,8), %xmm3
ucomisd %xmm2, %xmm3
jne 0x4cea5
jnp 0x4cf1c
movsd 0x20(%rdi,%rcx,8), %xmm4
ucomisd %xmm2, %xmm4
jne 0x4ceb3
jnp 0x4cf1c
cmpb $0x0, 0x15(%rdi,%rcx)
je 0x4ceca
andl $0x0, (%r9,%rcx,4)
movsd %xmm3, (%r11,%rcx,8)
movl %r15d, %edx
jmp 0x4cf00
movl (%r9,%rcx,4), %edx
testl %edx, %edx
je 0x4cebf
movapd %xmm4, %xmm5
subsd (%r10,%rcx,8), %xmm5
mulsd (%r13), %xmm5
divsd %xmm0, %xmm3
addsd (%r11,%rcx,8), %xmm5
mulsd %xmm1, %xmm5
divsd %xmm0, %xmm5
addsd %xmm5, %xmm3
movsd %xmm3, (%r11,%rcx,8)
incl %edx
movl %edx, (%r9,%rcx,4)
xorpd %xmm5, %xmm5
cmpl %ebx, %edx
jl 0x4cf10
movapd %xmm3, %xmm5
movsd %xmm5, 0x38(%rdi,%rcx,8)
movsd %xmm4, (%r10,%rcx,8)
incq %rcx
addq $0x8, %r13
jmp 0x4ce84
incq %rsi
addq $0x60, %r12
jmp 0x4cdf9
addq $0x48a8, %rsp           # imm = 0x48A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq