// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
movl %esi, %ebx
movq %rdi, -0x30(%rbp)
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl $0x18, %esi
movl $0xc, %edx
callq 0x4d9d6
movl %eax, -0x44(%rbp)
leaq 0x2723d(%rip), %rdx     # 0x6a5f5
xorl %r13d, %r13d
leal -0x1(%rbx), %r12d
cmpl $0x7, %r12d
movq %rbx, -0x50(%rbp)
ja 0x433e6
leaq 0x2b7ec(%rip), %rax     # 0x6ebbc
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq -0x30(%rbp), %rax
leaq 0x9bad0(%rax), %r13
jmp 0x4342f
cmpl $0x10, %ebx
je 0x43424
cmpl $0x20, %ebx
jne 0x43432
movq -0x30(%rbp), %rax
leaq 0x9bd50(%rax), %r13
jmp 0x4342f
movq -0x30(%rbp), %rax
leaq 0x9bbd0(%rax), %r13
jmp 0x4342f
movq -0x30(%rbp), %rax
leaq 0x9bcd0(%rax), %r13
jmp 0x4342f
movq -0x30(%rbp), %rax
leaq 0x9bb50(%rax), %r13
jmp 0x4342f
movq -0x30(%rbp), %rax
leaq 0x9bc50(%rax), %r13
movq %r13, %rdx
movq %rdx, -0x58(%rbp)
cmpb $0x0, 0x7(%r15)
movq %r15, -0x40(%rbp)
je 0x43608
leaq -0x200(%rbp), %r14
xorl %ebx, %ebx
cmpl $0x7, %r12d
ja 0x43477
leaq 0x2b781(%rip), %rax     # 0x6ebdc
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
leaq 0x4b1e7(%rip), %rax     # 0x8e650
jmpq *%rcx
leaq 0x4b5de(%rip), %rax     # 0x8ea50
jmp 0x4350c
movq -0x50(%rbp), %rax
cmpl $0x10, %eax
je 0x43505
cmpl $0x20, %eax
jne 0x434c0
movzbl 0x48(%r15,%rbx), %eax
leaq 0x4b6ba(%rip), %rcx     # 0x8eb50
movq -0x8(%rcx,%rax,8), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d636
movb %al, -0xc0(%rbp,%rbx)
movl (%r14), %ecx
cmpl $0x4, %ecx
je 0x435fc
cmpl $0x5, %ecx
je 0x434f3
jmp 0x43529
leaq 0x2712e(%rip), %r15     # 0x6a5f5
jmp 0x43517
movzbl 0x48(%r15,%rbx), %eax
leaq 0x4b37a(%rip), %rcx     # 0x8e850
movq -0x8(%rcx,%rax,8), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d636
movb %al, -0xc0(%rbp,%rbx)
cmpl $0x5, (%r14)
jne 0x43529
movl $0x2, (%r14)
jmp 0x43529
leaq 0x4b24d(%rip), %rax     # 0x8e750
jmp 0x4350c
leaq 0x4b444(%rip), %rax     # 0x8e950
movzbl 0x48(%r15,%rbx), %ecx
movq -0x8(%rax,%rcx,8), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d636
movb %al, -0xc0(%rbp,%rbx)
testb %al, %al
je 0x43575
testq %r13, %r13
je 0x435b9
movq -0x40(%rbp), %r8
movzbl 0x7(%r8), %eax
decq %rax
cmpq %rax, %rbx
leaq 0x270a9(%rip), %rcx     # 0x6a5f5
leaq 0x35df0(%rip), %rax     # 0x79343
cmovlq %rax, %rcx
movq %r13, %rdi
leaq 0x2c512(%rip), %rsi     # 0x6fa73
movq %r15, %rdx
movq %r8, %r15
xorl %eax, %eax
callq 0x8120
cltq
addq %rax, %r13
jmp 0x435e5
testq %r13, %r13
je 0x435c2
movq -0x40(%rbp), %r15
movzbl 0x48(%r15,%rbx), %edx
movzbl 0x7(%r15), %eax
decq %rax
cmpq %rax, %rbx
leaq 0x2705f(%rip), %rcx     # 0x6a5f5
leaq 0x35da6(%rip), %rax     # 0x79343
cmovlq %rax, %rcx
movq %r13, %rdi
leaq 0x2c4ce(%rip), %rsi     # 0x6fa79
xorl %eax, %eax
callq 0x8120
cltq
addq %rax, %r13
jmp 0x435c9
xorl %r13d, %r13d
movq -0x40(%rbp), %r15
jmp 0x435e5
xorl %r13d, %r13d
movq -0x40(%rbp), %r15
movzbl 0x48(%r15,%rbx), %ecx
movl $0x2, %edi
leaq 0x2c4a5(%rip), %rsi     # 0x6fa80
movl -0x44(%rbp), %edx
xorl %eax, %eax
callq 0x4d55d
incq %rbx
movzbl 0x7(%r15), %eax
addq $0x4, %r14
cmpq %rax, %rbx
jb 0x4344e
jmp 0x43608
movl $0x3, (%r14)
jmp 0x43529
leaq 0x2c492(%rip), %rsi     # 0x6faa1
movl $0x3, %edi
movl -0x44(%rbp), %edx
movq -0x58(%rbp), %rcx
xorl %eax, %eax
callq 0x4d55d
movzbl 0x7(%r15), %ebx
xorpd %xmm0, %xmm0
movapd %xmm0, -0xf0(%rbp)
movapd %xmm0, -0x100(%rbp)
movapd %xmm0, -0xd0(%rbp)
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, -0x110(%rbp)
movapd %xmm0, -0x120(%rbp)
movapd %xmm0, -0x130(%rbp)
movapd %xmm0, -0x140(%rbp)
movapd %xmm0, -0x150(%rbp)
movapd %xmm0, -0x160(%rbp)
movapd %xmm0, -0x170(%rbp)
movapd %xmm0, -0x180(%rbp)
testq %rbx, %rbx
je 0x4376b
movq -0x30(%rbp), %rax
leaq 0x9fd48(%rax), %r14
xorl %r15d, %r15d
movb -0xc0(%rbp,%r15), %al
testb %al, %al
je 0x43711
cmpl $0x4, -0x200(%rbp,%r15,4)
jge 0x43705
movzbl %al, %esi
movq -0x50(%rbp), %rdi
movq %r14, %rdx
callq 0x4d82d
movslq -0x200(%rbp,%r15,4), %rcx
cmpl -0x104(%rbp,%rcx,4), %eax
jle 0x43705
movslq -0xe4(%rbp,%rcx,4), %rdx
testq %rdx, %rdx
je 0x436f1
movl $0x1, -0x184(%rbp,%rdx,4)
movl %eax, -0x104(%rbp,%rcx,4)
leal 0x1(%r15), %eax
movl %eax, -0xe4(%rbp,%rcx,4)
jmp 0x43711
movl $0x1, -0x180(%rbp,%r15,4)
incq %r15
cmpq %r15, %rbx
jne 0x436a2
leaq 0x2c3b9(%rip), %r14     # 0x6fad9
xorl %r15d, %r15d
cmpl $0x0, -0x180(%rbp,%r15,4)
je 0x43751
movzbl -0xc0(%rbp,%r15), %ecx
movl $0x2, %edi
movq %r14, %rsi
movq -0x50(%rbp), %rdx
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x4375b
movl -0x200(%rbp,%r15,4), %eax
decl %eax
movl %eax, -0x280(%rbp,%r15,4)
incq %r15
cmpq %r15, %rbx
jne 0x43723
movq -0x40(%rbp), %rcx
cmpb $0x0, 0x6(%rcx)
je 0x43b20
movq -0x30(%rbp), %rdx
leaq 0x30(%rdx), %rax
movq %rax, -0x78(%rbp)
leaq 0x68(%rcx), %rax
movq %rax, -0x68(%rbp)
leaq 0x40(%rdx), %rax
movq %rax, -0x98(%rbp)
cmpl $0x4, -0x50(%rbp)
sete %al
cmpq $0x0, 0x30(%rbp)
setne %sil
andb %al, %sil
movb %sil, -0x32(%rbp)
cmpq $0x0, 0x10(%rbp)
setne %al
cmpq $0x0, 0x18(%rbp)
setne %sil
andb %al, %sil
movb %sil, -0x31(%rbp)
leaq 0x9cc60(%rdx), %rax
movq %rax, -0x90(%rbp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x0, -0x5c(%rbp)
movzbl 0x8(%rcx,%r12), %r15d
movq -0x50(%rbp), %rdi
cmpl $0x2, %edi
je 0x437fb
cmpl $0x10, %edi
jne 0x437ff
decl %r15d
jmp 0x437ff
addl $0x77, %r15d
movl %r15d, %esi
callq 0x4d28d
movl %eax, -0x58(%rbp)
testl %eax, %eax
je 0x43874
movq -0x30(%rbp), %rbx
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%rbx), %rsi
movsd 0x18(%rbx), %xmm1
callq 0x4f51b
cmpl $0x0, 0x9bdd0(%rbx)
jne 0x43847
andpd 0x260f3(%rip), %xmm0    # 0x69930
ucomisd 0x294c3(%rip), %xmm0    # 0x6cd08
jbe 0x43856
movq -0x30(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, 0x9bdd0(%rax)
movl %ecx, 0x30(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
movsd 0x18(%rax), %xmm0
movq -0x78(%rbp), %rdi
movl -0x58(%rbp), %edx
callq 0x42820
movl %eax, -0x5c(%rbp)
jmp 0x4388d
movl $0x2, %edi
leaq 0x2c237(%rip), %rsi     # 0x6fab7
movl -0x44(%rbp), %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movq -0x40(%rbp), %rax
movb 0x7(%rax), %al
testb %al, %al
movq -0x68(%rbp), %rsi
je 0x43b0c
movl -0x58(%rbp), %ecx
addl $-0x1, %ecx
setb %dl
movl -0x5c(%rbp), %edi
testl %edi, %edi
setns %r8b
andb %dl, %r8b
movl %edi, %r15d
movslq %ecx, %rcx
movq %rcx, -0xa0(%rbp)
xorl %ebx, %ebx
movb %r8b, -0x33(%rbp)
movzbl %al, %ecx
imulq %r12, %rcx
addq %rsi, %rcx
cmpb $0x0, (%rbx,%rcx)
je 0x43afd
testb %r8b, %r8b
je 0x43afa
movslq -0x280(%rbp,%rbx,4), %r14
testq %r14, %r14
js 0x43afa
movl -0x200(%rbp,%rbx,4), %esi
decl %esi
movl -0x58(%rbp), %edi
movq -0x98(%rbp), %rdx
callq 0x52684
cmpb $0x0, -0x32(%rbp)
je 0x43965
movq 0x30(%rbp), %rax
movl (%rax,%r12,4), %eax
cmpl $0xd, %eax
xorpd %xmm3, %xmm3
jg 0x43969
addl $-0x7, %eax
xorl %ecx, %ecx
cmpl $0x2, -0x200(%rbp,%rbx,4)
sete %cl
shll $0x3, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
leaq 0x2b46a(%rip), %rax     # 0x6edb0
mulsd (%rcx,%rax), %xmm1
leaq 0x2b46e(%rip), %rax     # 0x6edc0
addsd (%rcx,%rax), %xmm1
movsd 0x28441(%rip), %xmm0    # 0x6bda0
divsd %xmm1, %xmm0
jmp 0x43969
xorpd %xmm3, %xmm3
movq -0x70(%rbp), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd %xmm3, %xmm1
movslq %r13d, %rax
jne 0x4397e
jnp 0x439b6
movq -0x80(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd 0x2b501(%rip), %xmm2    # 0x6ee90
jbe 0x439b6
addsd %xmm2, %xmm1
leaq (%r15,%r15,2), %rcx
shlq $0x5, %rcx
movq -0x30(%rbp), %rdx
addq 0x38(%rdx), %rcx
movsd %xmm1, 0x38(%rcx,%r14,8)
movq -0x70(%rbp), %rcx
movsd (%rcx,%r12,8), %xmm1
ucomisd %xmm3, %xmm1
jne 0x439be
jnp 0x439f9
movq -0x88(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd 0x2b4be(%rip), %xmm2    # 0x6ee90
jbe 0x439f9
ucomisd %xmm3, %xmm0
jbe 0x439f9
addsd %xmm2, %xmm1
divsd %xmm0, %xmm1
leaq (%r15,%r15,2), %rcx
shlq $0x5, %rcx
movq -0x30(%rbp), %rdx
addq 0x38(%rdx), %rcx
movsd %xmm1, 0x20(%rcx,%r14,8)
cmpb $0x0, -0x31(%rbp)
je 0x43a4c
movq 0x18(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd 0x2b480(%rip), %xmm1    # 0x6ee90
jbe 0x43a4c
ucomisd %xmm3, %xmm0
jbe 0x43a4c
movq 0x10(%rbp), %rcx
addsd (%rcx,%r12,8), %xmm1
xorpd 0x270a6(%rip), %xmm1    # 0x6aad0
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
leaq (%r15,%r15,2), %rcx
shlq $0x5, %rcx
movq -0x30(%rbp), %rdx
addq 0x38(%rdx), %rcx
movss %xmm0, 0x50(%rcx,%r14,4)
movq 0x28(%rbp), %rcx
movl (%rcx,%rax,4), %ecx
testl %ecx, %ecx
sete %dl
movq -0xa0(%rbp), %rsi
leaq (%rsi,%rsi,2), %rsi
movq -0x90(%rbp), %rdi
leaq (%rdi,%rsi,2), %rsi
movzwl (%rsi,%r14,2), %edi
testw %di, %di
sete %r8b
andb %dl, %r8b
movzwl %di, %edx
cmpl %edx, %ecx
setl %dl
orb %r8b, %dl
movw %cx, (%rsi,%r14,2)
xorl %ecx, %ecx
movq 0x38(%rbp), %rsi
cmpl $0x0, (%rsi,%rax,4)
setne %cl
leal (%rcx,%rcx,2), %ecx
addb %dl, %cl
movq %r15, %rdx
shlq $0x5, %rdx
leaq (%rdx,%rdx,2), %rdx
movq -0x30(%rbp), %rdi
movq 0x38(%rdi), %rsi
addq %rdx, %rsi
movb %cl, 0x15(%r14,%rsi)
movq 0x20(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd 0x26ddd(%rip), %xmm0    # 0x6a8a8
cvttsd2si %xmm0, %eax
movq 0x38(%rdi), %rcx
addq %rdx, %rcx
movb %al, 0x12(%r14,%rcx)
movb -0xc0(%rbp,%rbx), %al
addq 0x38(%rdi), %rdx
movb %al, 0x18(%r14,%rdx)
movq -0x40(%rbp), %rax
movb 0x7(%rax), %al
movq -0x68(%rbp), %rsi
movb -0x33(%rbp), %r8b
incl %r13d
incq %rbx
movzbl %al, %ecx
cmpq %rcx, %rbx
jb 0x438c8
incq %r12
movq -0x40(%rbp), %rcx
movzbl 0x6(%rcx), %eax
cmpq %rax, %r12
jb 0x437e2
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop