// File: 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
subq $0x48e0, %rsp           # imm = 0x48E0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x1d20(%rbp), %rdi
xorl %esi, %esi
movl $0x1d10, %edx           # imm = 0x1D10
callq 0x93d0
leaq -0x3a30(%rbp), %rdi
xorl %esi, %esi
movl $0x1d10, %edx           # imm = 0x1D10
callq 0x93d0
leaq -0x48d0(%rbp), %rdi
xorl %esi, %esi
movl $0xe88, %edx            # imm = 0xE88
callq 0x93d0
movq -0x8(%rbp), %rax
movl (%rax), %edx
movl -0xc(%rbp), %ecx
movl $0x3, %edi
leaq 0x2f082(%rip), %rsi     # 0xc7fe2
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x3a3c(%rbp)
movl -0x3a3c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x99381
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x3a3c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48d8(%rbp)
movq -0x48d8(%rbp), %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x3a44(%rbp)
movq -0x48d8(%rbp), %rax
movzbl 0x11(%rax), %eax
movl %eax, -0x3a48(%rbp)
movl $0x0, -0x3a40(%rbp)
cmpl $0x3, -0x3a40(%rbp)
jge 0x9936b
cmpl $0x0, -0x3a44(%rbp)
jle 0x99005
movl $0x9b, %eax
cmpl -0x3a44(%rbp), %eax
jl 0x99005
cmpl $0x0, -0x3a48(%rbp)
jle 0x99005
movl $0x2, %eax
cmpl -0x3a48(%rbp), %eax
jge 0x9900a
jmp 0x99357
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9902b
jp 0x9902b
jmp 0x9904a
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9904f
jp 0x9904f
jmp 0x99357
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
cmpb $0x0, 0x15(%rax,%rcx)
je 0x990a2
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x48d0(%rbp), %rax
imulq $0x744, %rcx, %rcx      # imm = 0x744
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x48d0(%rbp), %rax
imulq $0x744, %rcx, %rcx      # imm = 0x744
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x99134
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x1d20(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x9925b
movslq -0x3a40(%rbp), %rcx
leaq 0x29e4e(%rip), %rax     # 0xc2f90
movsd (%rax,%rcx,8), %xmm0
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm1
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x3a30(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x3a38(%rbp)
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
divsd %xmm1, %xmm0
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x1d20(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd -0x3a38(%rbp), %xmm1
movl -0xc(%rbp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0xc(%rbp), %xmm2
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x1d20(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
cltq
leaq -0x48d0(%rbp), %rcx
imulq $0x744, %rax, %rax      # imm = 0x744
addq %rax, %rcx
movl -0x3a44(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0xc, %rax, %rax
addq %rax, %rcx
movslq -0x3a40(%rbp), %rdx
movl (%rcx,%rdx,4), %eax
addl $0x1, %eax
movl %eax, (%rcx,%rdx,4)
cmpl -0xc(%rbp), %eax
jge 0x992b7
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rax,%rcx,8)
jmp 0x99307
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x1d20(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd %xmm0, 0x38(%rax,%rcx,8)
movq -0x48d8(%rbp), %rax
movslq -0x3a40(%rbp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm0
movl -0x3a48(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq -0x3a30(%rbp), %rax
imulq $0xe88, %rcx, %rcx      # imm = 0xE88
addq %rcx, %rax
movl -0x3a44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x3a40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3a40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3a40(%rbp)
jmp 0x98fcc
jmp 0x9936d
movl -0x3a3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3a3c(%rbp)
jmp 0x98f71
addq $0x48e0, %rsp           # imm = 0x48E0
popq %rbp
retq
nopw (%rax,%rax)