// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::gen_msm_sig(bamboo::rtcm_t*, int, int, int, int, unsigned char const*, unsigned char const*, unsigned char const*, double const*, double const*, double*, double*, double*, double*, unsigned char*, float*)
static void gen_msm_sig(rtcm_t *rtcm, int sys, int nsat, int nsig, int ncell,
                        const unsigned char *sat_ind,
                        const unsigned char *sig_ind,
                        const unsigned char *cell_ind, const double *rrng,
                        const double *rrate, double *psrng, double *phrng,
                        double *rate, double *lock, unsigned char *half,
                        float *cnr)
{
    obsd_t *data;
    double lambda,psrng_s,phrng_s,rate_s,lt;
    int i,j,k,sat,sig,cell,f,LLI;
    
    for (i=0;i<ncell;i++) {
        if (psrng) psrng[i]=0.0;
        if (phrng) phrng[i]=0.0;
        if (rate ) rate [i]=0.0;
    }
    for (i=0;i<rtcm->obs.n;i++) {
        data=rtcm->obs.data+i;
        
        if (!(sat=to_satid(sys,data->sat))) continue;
        
        for (j=0;j<NFREQ+NEXOBS;j++) {
            if (!(sig=to_sigid(sys,data->code[j],&f))) continue;
            k=sat_ind[sat-1]-1;
            if ((cell=cell_ind[sig_ind[sig-1]-1+k*nsig])>=64) continue;
            
            lambda=satwavelen(data->sat,f-1,&rtcm->nav);
            psrng_s=data->P[j]==0.0?0.0:data->P[j]-rrng[k];
            phrng_s=data->L[j]==0.0||lambda<=0.0?0.0: data->L[j]*lambda-rrng [k];
            rate_s =data->D[j]==0.0||lambda<=0.0?0.0:-data->D[j]*lambda-rrate[k];
            
            /* subtract phase - psudorange integer cycle offset */
            LLI=data->LLI[j];
            if ((LLI&1)||fabs(phrng_s-rtcm->cp[data->sat-1][j])>1171.0) {
                rtcm->cp[data->sat-1][j]=ROUND(phrng_s/lambda)*lambda;
                LLI|=1;
            }
            phrng_s-=rtcm->cp[data->sat-1][j];
            
            lt=locktime_d(data->time,rtcm->lltime[data->sat-1]+j,LLI);
            
            if (psrng&&psrng_s!=0.0) psrng[cell-1]=psrng_s;
            if (phrng&&phrng_s!=0.0) phrng[cell-1]=phrng_s;
            if (rate &&rate_s !=0.0) rate [cell-1]=rate_s;
            if (lock) lock[cell-1]=lt;
            if (half) half[cell-1]=(data->LLI[j]&2)?1:0;
            if (cnr ) cnr [cell-1]=(float)(data->SNR[j]*0.25);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x89a59
cmpq $0x0, 0x30(%rbp)
je 0x89a1e
movq 0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x38(%rbp)
je 0x89a35
movq 0x38(%rbp), %rax
movslq -0x54(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x40(%rbp)
je 0x89a4c
movq 0x40(%rbp), %rax
movslq -0x54(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x89a4e
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x899ff
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x89f42
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x54(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %edi
movq -0x28(%rbp), %rax
movzbl 0x10(%rax), %esi
callq 0x89f50
movl %eax, -0x60(%rbp)
cmpl $0x0, %eax
jne 0x89aa4
jmp 0x89f34
movl $0x0, -0x58(%rbp)
cmpl $0x3, -0x58(%rbp)
jge 0x89f32
movl -0xc(%rbp), %edi
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
leaq -0x6c(%rbp), %rdx
movzbl 0x18(%rax,%rcx), %esi
callq 0x89fb0
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jne 0x89adb
jmp 0x89f24
movq -0x20(%rbp), %rax
movl -0x60(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rcx
movl -0x64(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
subl $0x1, %ecx
movl -0x5c(%rbp), %edx
imull -0x14(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x68(%rbp)
cmpl $0x40, %eax
jl 0x89b27
jmp 0x89f24
movq -0x28(%rbp), %rax
movzbl 0x10(%rax), %edi
movl -0x6c(%rbp), %esi
subl $0x1, %esi
movq -0x8(%rbp), %rdx
addq $0x40, %rdx
callq 0x938e0
movsd %xmm0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89b6d
jp 0x89b6d
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
jmp 0x89b90
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
movq 0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89bb8
jp 0x89bb8
jmp 0x89bc2
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jb 0x89bcf
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x89c16
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movsd 0x20(%rax,%rcx,8), %xmm0
movsd -0x30(%rbp), %xmm2
movq 0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movss 0x50(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89c42
jp 0x89c42
jmp 0x89c4c
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jb 0x89c59
xorps %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0x89cb1
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movss 0x50(%rax,%rcx,4), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm2
movq 0x28(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movzbl 0x15(%rax,%rcx), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x89d1f
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
addq $0x9bdd8, %rax          # imm = 0x9BDD8
movq -0x28(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x58(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm0
movaps 0x33513(%rip), %xmm1    # 0xbd220
pand %xmm1, %xmm0
movsd 0x380d7(%rip), %xmm1    # 0xc1df0
ucomisd %xmm1, %xmm0
jbe 0x89d78
movsd -0x40(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd 0x3314f(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
mulsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
addq $0x9bdd8, %rax          # imm = 0x9BDD8
movq -0x28(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x58(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x70(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x70(%rbp)
movq -0x8(%rbp), %rax
addq $0x9bdd8, %rax          # imm = 0x9BDD8
movq -0x28(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq -0x58(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x40(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x80(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rsi
addq $0x9d3a8, %rsi          # imm = 0x9D3A8
movq -0x28(%rbp), %rax
movzbl 0x10(%rax), %eax
subl $0x1, %eax
cltq
imulq $0x30, %rax, %rax
addq %rax, %rsi
movslq -0x58(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movl -0x70(%rbp), %eax
movq -0x80(%rbp), %rdi
movsd -0x78(%rbp), %xmm0
movzbl %al, %edx
callq 0x8a180
movsd %xmm0, -0x50(%rbp)
cmpq $0x0, 0x30(%rbp)
je 0x89e34
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89e1d
jp 0x89e1d
jmp 0x89e34
movsd -0x38(%rbp), %xmm0
movq 0x30(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x38(%rbp)
je 0x89e64
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89e4d
jp 0x89e4d
jmp 0x89e64
movsd -0x40(%rbp), %xmm0
movq 0x38(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x40(%rbp)
je 0x89e94
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89e7d
jp 0x89e7d
jmp 0x89e94
movsd -0x48(%rbp), %xmm0
movq 0x40(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x48(%rbp)
je 0x89eb2
movsd -0x50(%rbp), %xmm0
movq 0x48(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x50(%rbp)
je 0x89ee8
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movzbl 0x15(%rax,%rcx), %edx
andl $0x2, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %dl
movq 0x50(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
cmpq $0x0, 0x58(%rbp)
je 0x89f22
movq -0x28(%rbp), %rax
movslq -0x58(%rbp), %rcx
movzbl 0x12(%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
movsd 0x33040(%rip), %xmm1    # 0xbcf48
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rbp), %rax
movl -0x68(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x89f24
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x89aab
jmp 0x89f34
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x89a60
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)