// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::gen_msm_sat(bamboo::rtcm_t*, int, int, unsigned char const*, double*, double*, unsigned char*)
static void gen_msm_sat(rtcm_t *rtcm, int sys, int nsat,
                        const unsigned char *sat_ind, double *rrng,
                        double *rrate, unsigned char *info)
{
    obsd_t *data;
    double lambda,rrng_s,rrate_s;
    int i,j,k,sat,sig,f,fcn;
    
    for (i=0;i<64;i++) rrng[i]=rrate[i]=0.0;
    
    for (i=0;i<rtcm->obs.n;i++) {
        data=rtcm->obs.data+i;
        if (!(sat=to_satid(sys,data->sat))) continue;
        fcn=fcn_glo(data->sat,rtcm);
        
        for (j=0;j<NFREQ+NEXOBS;j++) {
            if (!(sig=to_sigid(sys,data->code[j],&f))) continue;
            k=sat_ind[sat-1]-1;
            lambda=satwavelen(data->sat,f-1,&rtcm->nav);
            
            /* rough range (ms) and rough phase-range-rate (m/s) */
            rrng_s =ROUND( data->P[j]/RANGE_MS/P2_10)*RANGE_MS*P2_10;
            rrate_s=ROUND(-data->D[j]*lambda)*1.0;
            if (rrng [k]==0.0&&data->P[j]!=0.0) rrng [k]=rrng_s;
            if (rrate[k]==0.0&&data->D[j]!=0.0) rrate[k]=rrate_s;
            
            /* extended satellite info */
            if (info) info[k]=sys!=SYS_GLO?0:(fcn<0?15:fcn);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x4c(%rbp)
cmpl $0x40, -0x4c(%rbp)
jge 0x8973a
movq -0x28(%rbp), %rax
movslq -0x4c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x89709
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x899a3
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0xc(%rbp), %edi
movq -0x30(%rbp), %rax
movzbl 0x10(%rax), %esi
callq 0x89f50
movl %eax, -0x58(%rbp)
cmpl $0x0, %eax
jne 0x89785
jmp 0x89995
movq -0x30(%rbp), %rax
movzbl 0x10(%rax), %edi
movq -0x8(%rbp), %rsi
callq 0x87f70
movl %eax, -0x64(%rbp)
movl $0x0, -0x50(%rbp)
cmpl $0x3, -0x50(%rbp)
jge 0x89993
movl -0xc(%rbp), %edi
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
leaq -0x60(%rbp), %rdx
movzbl 0x18(%rax,%rcx), %esi
callq 0x89fb0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
jne 0x897d0
jmp 0x89985
movq -0x18(%rbp), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
subl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x10(%rax), %edi
movl -0x60(%rbp), %esi
subl $0x1, %esi
movq -0x8(%rbp), %rdx
addq $0x40, %rdx
callq 0x938e0
movsd %xmm0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
movsd 0x371c3(%rip), %xmm1    # 0xc09e0
divsd %xmm1, %xmm0
movsd 0x371ff(%rip), %xmm1    # 0xc0a28
divsd %xmm1, %xmm0
movsd 0x3364b(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd 0x37192(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movsd 0x371ce(%rip), %xmm1    # 0xc0a28
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movss 0x50(%rax,%rcx,4), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x38(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x335ed(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movsd 0x325b4(%rip), %xmm1    # 0xbbe60
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x898fa
jp 0x898fa
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movsd 0x38(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x898e8
jp 0x898e8
jmp 0x898fa
movsd -0x40(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89943
jp 0x89943
movq -0x30(%rbp), %rax
movslq -0x50(%rbp), %rcx
movss 0x50(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x89931
jp 0x89931
jmp 0x89943
movsd -0x48(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
cmpq $0x0, 0x10(%rbp)
je 0x89983
cmpl $0x4, -0xc(%rbp)
je 0x89957
xorl %eax, %eax
movl %eax, -0x68(%rbp)
jmp 0x89973
cmpl $0x0, -0x64(%rbp)
jge 0x89967
movl $0xf, %eax
movl %eax, -0x6c(%rbp)
jmp 0x8996d
movl -0x64(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movb %al, %dl
movq 0x10(%rbp), %rax
movslq -0x54(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x89985
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x897a0
jmp 0x89995
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x89741
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)