// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::save_msm_obs(bamboo::rtcm_t*, int, bamboo::msm_h_t*, double const*, double const*, double const*, double const*, double const*, double const*, int const*, int const*, int const*)
static void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r,
                         const double *pr, const double *cp, const double *rr,
                         const double *rrf, const double *cnr, const int *lock,
                         const int *ex, const int *half)
{
    const char *sig[32];
    double tt,wl;
    unsigned char code[32];
    char *msm_type="",*q=NULL;
    int i,j,k,type,prn,sat,fn,index=0,freq[32],ind[32];
    
    type=getbitu(rtcm->buff,24,12);
    
    switch (sys) {
        case SYS_GPS: msm_type=q=rtcm->msmtype[0]; break;
        case SYS_GLO: msm_type=q=rtcm->msmtype[1]; break;
        case SYS_GAL: msm_type=q=rtcm->msmtype[2]; break;
        case SYS_QZS: msm_type=q=rtcm->msmtype[3]; break;
        case SYS_SBS: msm_type=q=rtcm->msmtype[4]; break;
        case SYS_CMP: msm_type=q=rtcm->msmtype[5]; break;
    }
    /* id to signal */
    for (i=0;i<h->nsig;i++) {
        switch (sys) {
            case SYS_GPS: sig[i]=msm_sig_gps[h->sigs[i]-1]; break;
            case SYS_GLO: sig[i]=msm_sig_glo[h->sigs[i]-1]; break;
            case SYS_GAL: sig[i]=msm_sig_gal[h->sigs[i]-1]; break;
            case SYS_QZS: sig[i]=msm_sig_qzs[h->sigs[i]-1]; break;
            case SYS_SBS: sig[i]=msm_sig_sbs[h->sigs[i]-1]; break;
            case SYS_CMP: sig[i]=msm_sig_cmp[h->sigs[i]-1]; break;
            default: sig[i]=""; break;
        }
        /* signal to rinex obs type */
        code[i]=obs2code(sig[i],freq+i);
        
        /* freqency index for beidou and galileo */
        if (sys==SYS_CMP) {
            if      (freq[i]==5) freq[i]=2; /* B2 */
            else if (freq[i]==4) freq[i]=3; /* B3 */
        }
        else if (sys==SYS_GAL) {
            if (freq[i]==5) freq[i]=2; /* E5b */
        }
        if (code[i]!=CODE_NONE) {
            if (q) q+=sprintf(q,"L%s%s",sig[i],i<h->nsig-1?",":"");
        }
        else {
            if (q) q+=sprintf(q,"(%d)%s",h->sigs[i],i<h->nsig-1?",":"");
            
            trace(2,"rtcm3 %d: unknown signal id=%2d\n",type,h->sigs[i]);
        }
    }
    trace(3,"rtcm3 %d: signals=%s\n",type,msm_type);
    
    /* get signal index */
    sigindex(sys,code,freq,h->nsig,rtcm->opt,ind);
    
    for (i=j=0;i<h->nsat;i++) {
        
        prn=h->sats[i];
        if      (sys==SYS_QZS) prn+=MINPRNQZS-1;
        else if (sys==SYS_SBS) prn+=MINPRNSBS-1;
        
        if ((sat=satno(sys,prn))) {
            tt=timediff(rtcm->obs.data[0].time,rtcm->time);
            if (rtcm->obsflag||fabs(tt)>1E-9) {
                rtcm->obs.n=rtcm->obsflag=0;
            }
            index=obsindex(&rtcm->obs,rtcm->time,sat);
        }
        else {
            trace(2,"rtcm3 %d satellite error: prn=%d\n",type,prn);
        }
        for (k=0;k<h->nsig;k++) {
            if (!h->cellmask[k+i*h->nsig]) continue;
            
            if (sat&&index>=0&&ind[k]>=0) {
                
                /* satellite carrier wave length */
                wl=satwavelen(sat,freq[k]-1,&rtcm->nav);
                
                /* glonass wave length by extended info */
                if (sys==SYS_GLO&&ex&&ex[i]<=13) {
                    fn=ex[i]-7;
                    wl=CLIGHT/((freq[k]==2?FREQ2_GLO:FREQ1_GLO)+
                               (freq[k]==2?DFRQ2_GLO:DFRQ1_GLO)*fn);
                }
                /* pseudorange (m) */
                if (r[i]!=0.0&&pr[j]>-1E12) {
                    rtcm->obs.data[index].P[ind[k]]=r[i]+pr[j];
                }
                /* carrier-phase (cycle) */
                if (r[i]!=0.0&&cp[j]>-1E12&&wl>0.0) {
                    rtcm->obs.data[index].L[ind[k]]=(r[i]+cp[j])/wl;
                }
                /* doppler (hz) */
                if (rr&&rrf&&rrf[j]>-1E12&&wl>0.0) {
                    rtcm->obs.data[index].D[ind[k]]=(float)(-(rr[i]+rrf[j])/wl);
                }
                rtcm->obs.data[index].LLI[ind[k]]=
                    lossoflock(rtcm,sat,ind[k],lock[j])+(half[j]?3:0);
                rtcm->obs.data[index].SNR [ind[k]]=(unsigned char)(cnr[j]*4.0);
                rtcm->obs.data[index].code[ind[k]]=code[k];
            }
            j++;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %r9, -0x88(%rbp)
movq %r8, -0x80(%rbp)
movq %rcx, -0x70(%rbp)
movq %rdx, -0x40(%rbp)
movl %esi, %r15d
movq %rdi, -0x30(%rbp)
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
pushq $0x18
popq %rsi
pushq $0xc
popq %rdx
callq 0x459f7
movl %eax, -0x4c(%rbp)
leaq 0x24643(%rip), %rdx     # 0x605e5
xorl %r14d, %r14d
leal -0x1(%r15), %ebx
cmpl $0x7, %ebx
movq %r15, -0x58(%rbp)
ja 0x3bfcf
leaq 0x28cf3(%rip), %rax     # 0x64cac
movslq (%rax,%rbx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq -0x30(%rbp), %rax
leaq 0x9bad0(%rax), %r14
jmp 0x3c01a
cmpl $0x10, %r15d
je 0x3c00f
cmpl $0x20, %r15d
jne 0x3c01d
movq -0x30(%rbp), %rax
leaq 0x9bd50(%rax), %r14
jmp 0x3c01a
movq -0x30(%rbp), %rax
leaq 0x9bbd0(%rax), %r14
jmp 0x3c01a
movq -0x30(%rbp), %rax
leaq 0x9bcd0(%rax), %r14
jmp 0x3c01a
movq -0x30(%rbp), %rax
leaq 0x9bb50(%rax), %r14
jmp 0x3c01a
movq -0x30(%rbp), %rax
leaq 0x9bc50(%rax), %r14
movq %r14, %rdx
movq %rdx, -0x48(%rbp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movq -0x40(%rbp), %rax
movzbl 0x7(%rax), %eax
cmpq %rax, %r13
jae 0x3c221
cmpl $0x7, %ebx
ja 0x3c060
leaq 0x28c88(%rip), %rax     # 0x64ccc
movslq (%rax,%rbx,4), %rcx
addq %rax, %rcx
leaq 0x4a60e(%rip), %rax     # 0x86660
jmpq *%rcx
leaq 0x4aa05(%rip), %rax     # 0x86a60
jmp 0x3c12c
movq -0x58(%rbp), %rax
cmpl $0x10, %eax
je 0x3c125
cmpl $0x20, %eax
jne 0x3c0be
movq -0x40(%rbp), %rax
movzbl 0x48(%rax,%r13), %eax
leaq 0x4aadd(%rip), %rcx     # 0x86b60
movq -0x8(%rcx,%rax,8), %r15
leaq (%r12,%rbp), %rsi
addq $-0x180, %rsi           # imm = 0xFE80
movq %r15, %rdi
callq 0x45694
movb %al, -0xc0(%rbp,%r13)
movl -0x180(%rbp,%r13,4), %ecx
cmpl $0x4, %ecx
je 0x3c210
cmpl $0x5, %ecx
je 0x3c10e
jmp 0x3c156
leaq (%r12,%rbp), %rsi
addq $-0x180, %rsi           # imm = 0xFE80
leaq 0x24515(%rip), %r15     # 0x605e5
jmp 0x3c146
movq -0x40(%rbp), %rax
movzbl 0x48(%rax,%r13), %eax
leaq 0x4a77d(%rip), %rcx     # 0x86860
movq -0x8(%rcx,%rax,8), %r15
leaq (%r12,%rbp), %rsi
addq $-0x180, %rsi           # imm = 0xFE80
movq %r15, %rdi
callq 0x45694
movb %al, -0xc0(%rbp,%r13)
cmpl $0x5, -0x180(%rbp,%r13,4)
jne 0x3c156
movl $0x2, -0x180(%rbp,%r13,4)
jmp 0x3c156
leaq 0x4a63d(%rip), %rax     # 0x86760
jmp 0x3c12c
leaq 0x4a834(%rip), %rax     # 0x86960
movq -0x40(%rbp), %rcx
movzbl 0x48(%rcx,%r13), %ecx
movq -0x8(%rax,%rcx,8), %r15
leaq (%r12,%rbp), %rsi
addq $-0x180, %rsi           # imm = 0xFE80
movq %r15, %rdi
callq 0x45694
movb %al, -0xc0(%rbp,%r13)
testb %al, %al
je 0x3c19a
testq %r14, %r14
je 0x3c1de
movq -0x40(%rbp), %rax
movzbl 0x7(%rax), %eax
decq %rax
cmpq %rax, %r13
leaq 0x24471(%rip), %rcx     # 0x605e5
leaq 0x33198(%rip), %rax     # 0x6f313
cmovlq %rax, %rcx
movq %r14, %rdi
leaq 0x298e6(%rip), %rsi     # 0x65a6f
movq %r15, %rdx
xorl %eax, %eax
callq 0x8110
cltq
addq %rax, %r14
jmp 0x3c204
testq %r14, %r14
je 0x3c1e3
movq -0x40(%rbp), %r15
movzbl 0x48(%r15,%r13), %edx
movzbl 0x7(%r15), %eax
decq %rax
cmpq %rax, %r13
leaq 0x2442a(%rip), %rcx     # 0x605e5
leaq 0x33151(%rip), %rax     # 0x6f313
cmovlq %rax, %rcx
movq %r14, %rdi
leaq 0x298a5(%rip), %rsi     # 0x65a75
xorl %eax, %eax
callq 0x8110
cltq
addq %rax, %r14
jmp 0x3c1ea
xorl %r14d, %r14d
jmp 0x3c204
xorl %r14d, %r14d
movq -0x40(%rbp), %r15
movzbl 0x48(%r15,%r13), %ecx
pushq $0x2
popq %rdi
leaq 0x29882(%rip), %rsi     # 0x65a7c
movl -0x4c(%rbp), %edx
xorl %eax, %eax
callq 0x455bc
incq %r13
addq $0x4, %r12
jmp 0x3c027
movl $0x3, -0x180(%rbp,%r13,4)
jmp 0x3c156
leaq 0x29875(%rip), %rsi     # 0x65a9d
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl -0x4c(%rbp), %edx
movq -0x48(%rbp), %rcx
xorl %eax, %eax
callq 0x455bc
movq -0x40(%rbp), %rax
movzbl 0x7(%rax), %ebx
movq -0x30(%rbp), %rax
leaq 0x9fd48(%rax), %r14
xorpd %xmm0, %xmm0
movapd %xmm0, -0xf0(%rbp)
movapd %xmm0, -0x100(%rbp)
movapd %xmm0, -0xd0(%rbp)
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, -0x190(%rbp)
movapd %xmm0, -0x1a0(%rbp)
movapd %xmm0, -0x1b0(%rbp)
movapd %xmm0, -0x1c0(%rbp)
movapd %xmm0, -0x1d0(%rbp)
movapd %xmm0, -0x1e0(%rbp)
movapd %xmm0, -0x1f0(%rbp)
movapd %xmm0, -0x200(%rbp)
cmpq %r15, %rbx
je 0x3c32c
movb -0xc0(%rbp,%r15), %al
testb %al, %al
je 0x3c327
cmpl $0x4, -0x180(%rbp,%r15,4)
jge 0x3c31b
movzbl %al, %esi
movq -0x58(%rbp), %rdi
movq %r14, %rdx
callq 0x4587d
movslq -0x180(%rbp,%r15,4), %rcx
cmpl -0x104(%rbp,%rcx,4), %eax
jle 0x3c31b
movslq -0xe4(%rbp,%rcx,4), %rdx
testq %rdx, %rdx
je 0x3c307
movl $0x1, -0x204(%rbp,%rdx,4)
movl %eax, -0x104(%rbp,%rcx,4)
leal 0x1(%r15), %eax
movl %eax, -0xe4(%rbp,%rcx,4)
jmp 0x3c327
movl $0x1, -0x200(%rbp,%r15,4)
incq %r15
jmp 0x3c2b3
leaq 0x297a2(%rip), %r14     # 0x65ad5
pushq $0x2
popq %r15
pushq $-0x1
popq %r12
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x3c384
cmpl $0x0, -0x200(%rbp,%r13,4)
je 0x3c36d
movzbl -0xc0(%rbp,%r13), %ecx
movl %r15d, %edi
movq %r14, %rsi
movq -0x58(%rbp), %rdx
xorl %eax, %eax
callq 0x455bc
movl %r12d, %eax
jmp 0x3c377
movl -0x180(%rbp,%r13,4), %eax
decl %eax
movl %eax, -0x280(%rbp,%r13,4)
incq %r13
jmp 0x3c33e
movq -0x30(%rbp), %rax
leaq 0x30(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq -0x40(%rbp), %r13
leaq 0x68(%r13), %r12
addq $0x40, %rax
movq %rax, -0x90(%rbp)
movq -0x58(%rbp), %rdi
cmpl $0x4, %edi
sete %al
cmpq $0x0, 0x30(%rbp)
setne %cl
andb %al, %cl
movb %cl, -0x32(%rbp)
cmpq $0x0, 0x10(%rbp)
setne %al
cmpq $0x0, 0x18(%rbp)
setne %cl
andb %al, %cl
movb %cl, -0x31(%rbp)
xorl %ebx, %ebx
movl $0x0, -0x5c(%rbp)
xorl %ecx, %ecx
movq %r12, -0x98(%rbp)
movzbl 0x6(%r13), %eax
cmpq %rax, %rbx
jae 0x3c6ef
movzbl 0x8(%r13,%rbx), %r15d
cmpl $0x2, %edi
movl %ecx, -0x48(%rbp)
je 0x3c407
cmpl $0x10, %edi
jne 0x3c40b
decl %r15d
jmp 0x3c40b
addl $0x77, %r15d
movl %r15d, %esi
callq 0x452fd
movl %eax, %r14d
testl %eax, %eax
je 0x3c485
movl %r14d, %r15d
movq -0x30(%rbp), %r14
movq 0x38(%r14), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%r14), %rsi
movsd 0x18(%r14), %xmm1
callq 0x47322
cmpl $0x0, 0x9bdd0(%r14)
jne 0x3c458
andpd 0x234e2(%rip), %xmm0    # 0x5f930
ucomisd 0x268b2(%rip), %xmm0    # 0x62d08
jbe 0x3c467
movq -0x30(%rbp), %rax
andl $0x0, 0x9bdd0(%rax)
andl $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
movsd 0x18(%rax), %xmm0
movq -0x78(%rbp), %rdi
movl %r15d, %r14d
movl %r15d, %edx
callq 0x3b323
jmp 0x3c49f
pushq $0x2
popq %rdi
leaq 0x29624(%rip), %rsi     # 0x65ab3
movl -0x4c(%rbp), %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x455bc
movl -0x5c(%rbp), %eax
movl %r14d, -0x60(%rbp)
testl %r14d, %r14d
setne %cl
testl %eax, %eax
setns %dl
andb %cl, %dl
movl %eax, -0x5c(%rbp)
movl %eax, %eax
movq %rax, -0x68(%rbp)
xorl %r14d, %r14d
movl -0x48(%rbp), %ecx
movb %dl, -0x33(%rbp)
movzbl 0x7(%r13), %eax
cmpq %rax, %r14
jae 0x3c6e3
imulq %rbx, %rax
addq %r12, %rax
cmpb $0x0, (%r14,%rax)
je 0x3c6db
testb %dl, %dl
je 0x3c6d9
movslq -0x280(%rbp,%r14,4), %r15
testq %r15, %r15
js 0x3c6d9
movl %ecx, -0x48(%rbp)
movl -0x180(%rbp,%r14,4), %esi
decl %esi
movl -0x60(%rbp), %edi
movq -0x90(%rbp), %rdx
callq 0x49f8a
cmpb $0x0, -0x32(%rbp)
je 0x3c56a
movq 0x30(%rbp), %rax
movl (%rax,%rbx,4), %eax
cmpl $0xd, %eax
movl -0x48(%rbp), %edx
jg 0x3c56d
addl $-0x7, %eax
xorl %ecx, %ecx
cmpl $0x2, -0x180(%rbp,%r14,4)
sete %cl
shll $0x3, %ecx
cvtsi2sd %eax, %xmm1
leaq 0x28225(%rip), %rax     # 0x64770
mulsd (%rcx,%rax), %xmm1
leaq 0x28229(%rip), %rax     # 0x64780
addsd (%rcx,%rax), %xmm1
movsd 0x2583c(%rip), %xmm0    # 0x61da0
divsd %xmm1, %xmm0
jmp 0x3c56d
movl -0x48(%rbp), %edx
movq -0x70(%rbp), %rax
movsd (%rax,%rbx,8), %xmm1
ucomisd 0x2437a(%rip), %xmm1    # 0x608f8
movslq %edx, %r13
jne 0x3c585
jnp 0x3c5ba
movq -0x80(%rbp), %rax
movsd (%rax,%r13,8), %xmm2
ucomisd 0x281d1(%rip), %xmm2    # 0x64768
jbe 0x3c5ba
addsd %xmm2, %xmm1
imulq $0x60, -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
addq 0x38(%rcx), %rax
movsd %xmm1, 0x38(%rax,%r15,8)
movq -0x70(%rbp), %rax
movsd (%rax,%rbx,8), %xmm1
ucomisd 0x24336(%rip), %xmm1    # 0x608f8
jne 0x3c5c6
jnp 0x3c603
movq -0x88(%rbp), %rax
movsd (%rax,%r13,8), %xmm2
ucomisd 0x2818d(%rip), %xmm2    # 0x64768
jbe 0x3c603
ucomisd 0x24313(%rip), %xmm0    # 0x608f8
jbe 0x3c603
addsd %xmm2, %xmm1
divsd %xmm0, %xmm1
imulq $0x60, -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
addq 0x38(%rcx), %rax
movsd %xmm1, 0x20(%rax,%r15,8)
cmpb $0x0, -0x31(%rbp)
je 0x3c654
movq 0x18(%rbp), %rax
movsd (%rax,%r13,8), %xmm1
ucomisd 0x2814d(%rip), %xmm1    # 0x64768
jbe 0x3c654
ucomisd 0x242d3(%rip), %xmm0    # 0x608f8
jbe 0x3c654
movq 0x10(%rbp), %rax
addsd (%rax,%rbx,8), %xmm1
xorpd 0x24488(%rip), %xmm1    # 0x60ac0
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
imulq $0x60, -0x68(%rbp), %rax
movq -0x30(%rbp), %rcx
addq 0x38(%rcx), %rax
movss %xmm0, 0x50(%rax,%r15,4)
movq 0x28(%rbp), %rax
movl (%rax,%r13,4), %ecx
movq -0x30(%rbp), %r12
movq %r12, %rdi
movl -0x60(%rbp), %esi
movl %r15d, %edx
callq 0x3b432
xorl %ecx, %ecx
movq 0x38(%rbp), %rdx
cmpl $0x0, (%rdx,%r13,4)
setne %cl
leal (%rcx,%rcx,2), %ecx
addl %eax, %ecx
imulq $0x60, -0x68(%rbp), %rax
movq 0x38(%r12), %rdx
addq %rax, %rdx
movb %cl, 0x15(%r15,%rdx)
movq 0x20(%rbp), %rcx
movsd (%rcx,%r13,8), %xmm0
mulsd 0x241f3(%rip), %xmm0    # 0x60898
cvttsd2si %xmm0, %ecx
movq 0x38(%r12), %rdx
addq %rax, %rdx
movb %cl, 0x12(%r15,%rdx)
movb -0xc0(%rbp,%r14), %cl
addq 0x38(%r12), %rax
movb %cl, 0x18(%r15,%rax)
movq -0x40(%rbp), %r13
movq -0x98(%rbp), %r12
movl -0x48(%rbp), %ecx
movb -0x33(%rbp), %dl
incl %ecx
incq %r14
jmp 0x3c4c2
incq %rbx
movq -0x58(%rbp), %rdi
jmp 0x3c3e1
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)