// File: /workspace/github_cpp_makefile_star2_O1/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 $0x268, %rsp            # imm = 0x268
movq %r9, -0x90(%rbp)
movq %r8, -0x88(%rbp)
movq %rcx, -0x70(%rbp)
movq %rdx, -0x40(%rbp)
movl %esi, %r14d
movq %rdi, -0x30(%rbp)
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl $0x18, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, -0x44(%rbp)
leaq 0x26988(%rip), %rdx     # 0x6a5f5
xorl %r13d, %r13d
leal -0x1(%r14), %ebx
cmpl $0x7, %ebx
movq %r14, -0x60(%rbp)
ja 0x43c9e
leaq 0x2af38(%rip), %rax     # 0x6ebbc
movslq (%rax,%rbx,4), %rcx
addq %rax, %rcx
movq -0x40(%rbp), %rsi
jmpq *%rcx
movq -0x30(%rbp), %rax
leaq 0x9bad0(%rax), %r13
jmp 0x43ce4
cmpl $0x10, %r14d
je 0x44409
cmpl $0x20, %r14d
movq -0x40(%rbp), %rsi
jne 0x43ce7
movq -0x30(%rbp), %rax
leaq 0x9bd50(%rax), %r13
jmp 0x43ce4
movq -0x30(%rbp), %rax
leaq 0x9bbd0(%rax), %r13
jmp 0x43ce4
movq -0x30(%rbp), %rax
leaq 0x9bcd0(%rax), %r13
jmp 0x43ce4
movq -0x30(%rbp), %rax
leaq 0x9bb50(%rax), %r13
movq %r13, %rdx
movq %rdx, -0x50(%rbp)
cmpb $0x0, 0x7(%rsi)
je 0x43e96
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpl $0x7, %ebx
ja 0x43d27
leaq 0x2aed5(%rip), %rax     # 0x6ebdc
movslq (%rax,%rbx,4), %rcx
addq %rax, %rcx
leaq 0x4a93b(%rip), %rax     # 0x8e650
leaq 0x268d9(%rip), %r14     # 0x6a5f5
jmpq *%rcx
leaq 0x4ad2b(%rip), %rax     # 0x8ea50
jmp 0x43d5e
movq -0x60(%rbp), %rax
cmpl $0x10, %eax
je 0x43d57
leaq 0x268be(%rip), %r14     # 0x6a5f5
cmpl $0x20, %eax
jne 0x43d69
leaq 0x4ae0d(%rip), %rax     # 0x8eb50
jmp 0x43d5e
leaq 0x4ab04(%rip), %rax     # 0x8e850
jmp 0x43d5e
leaq 0x4a9fb(%rip), %rax     # 0x8e750
jmp 0x43d5e
leaq 0x4abf2(%rip), %rax     # 0x8e950
movzbl 0x48(%rsi,%r12), %ecx
movq -0x8(%rax,%rcx,8), %r14
leaq (%r15,%rbp), %rsi
addq $-0x210, %rsi           # imm = 0xFDF0
movq %r14, %rdi
callq 0x4dfa9
movb %al, -0xd0(%rbp,%r12)
movq -0x60(%rbp), %rcx
cmpl $0x8, %ecx
je 0x43daa
cmpl $0x20, %ecx
movq -0x40(%rbp), %rsi
jne 0x43dd3
movl -0x210(%rbp,%r12,4), %ecx
cmpl $0x4, %ecx
je 0x43dc7
cmpl $0x5, %ecx
je 0x43db9
jmp 0x43dd3
cmpl $0x5, -0x210(%rbp,%r12,4)
movq -0x40(%rbp), %rsi
jne 0x43dd3
movl $0x2, -0x210(%rbp,%r12,4)
jmp 0x43dd3
movl $0x3, -0x210(%rbp,%r12,4)
testb %al, %al
je 0x43e17
testq %r13, %r13
je 0x43e5a
movzbl 0x7(%rsi), %eax
decq %rax
cmpq %rax, %r12
leaq 0x26808(%rip), %rcx     # 0x6a5f5
leaq 0x35551(%rip), %rax     # 0x79345
cmovlq %rax, %rcx
movq %r13, %rdi
leaq 0x2bc71(%rip), %rsi     # 0x6fa73
movq %r14, %rdx
xorl %eax, %eax
callq 0x8120
movq -0x40(%rbp), %rsi
cltq
addq %rax, %r13
jmp 0x43e82
testq %r13, %r13
je 0x43e5f
movzbl 0x48(%rsi,%r12), %edx
movzbl 0x7(%rsi), %eax
decq %rax
cmpq %rax, %r12
leaq 0x267c2(%rip), %rcx     # 0x6a5f5
leaq 0x3550b(%rip), %rax     # 0x79345
cmovlq %rax, %rcx
movq %r13, %rdi
leaq 0x2bc31(%rip), %rsi     # 0x6fa79
xorl %eax, %eax
callq 0x8120
movq -0x40(%rbp), %rsi
cltq
addq %rax, %r13
jmp 0x43e62
xorl %r13d, %r13d
jmp 0x43e82
xorl %r13d, %r13d
movzbl 0x48(%rsi,%r12), %ecx
movl $0x2, %edi
leaq 0x2bc0c(%rip), %rsi     # 0x6fa80
movl -0x44(%rbp), %edx
xorl %eax, %eax
callq 0x4ded0
movq -0x40(%rbp), %rsi
incq %r12
movzbl 0x7(%rsi), %eax
addq $0x4, %r15
cmpq %rax, %r12
jb 0x43cfb
leaq 0x2bc04(%rip), %rsi     # 0x6faa1
movl $0x3, %edi
movl -0x44(%rbp), %edx
movq -0x50(%rbp), %rcx
xorl %eax, %eax
callq 0x4ded0
movq -0x40(%rbp), %rsi
movzbl 0x7(%rsi), %ebx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x100(%rbp)
movapd %xmm0, -0x110(%rbp)
movapd %xmm0, -0xe0(%rbp)
movapd %xmm0, -0xf0(%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)
movapd %xmm0, -0x190(%rbp)
testq %rbx, %rbx
movq -0x60(%rbp), %r12
je 0x44021
movq -0x30(%rbp), %rax
leaq 0x9fd48(%rax), %r14
xorl %r15d, %r15d
movb -0xd0(%rbp,%r15), %al
testb %al, %al
je 0x43fbb
cmpl $0x4, -0x210(%rbp,%r15,4)
jl 0x43f5c
movl $0x1, -0x190(%rbp,%r15,4)
jmp 0x43fbb
movzbl %al, %esi
movl %r12d, %edi
movq %r14, %rdx
callq 0x4e198
movslq -0x210(%rbp,%r15,4), %rcx
cmpl -0x114(%rbp,%rcx,4), %eax
jle 0x43fab
movslq -0xf4(%rbp,%rcx,4), %rdx
testq %rdx, %rdx
movq -0x40(%rbp), %rsi
je 0x43f97
movl $0x1, -0x194(%rbp,%rdx,4)
movl %eax, -0x114(%rbp,%rcx,4)
leal 0x1(%r15), %eax
movl %eax, -0xf4(%rbp,%rcx,4)
jmp 0x43fbb
movl $0x1, -0x190(%rbp,%r15,4)
movq -0x40(%rbp), %rsi
incq %r15
cmpq %r15, %rbx
jne 0x43f37
testq %rbx, %rbx
je 0x44021
leaq 0x2bb06(%rip), %r14     # 0x6fad9
xorl %r15d, %r15d
cmpl $0x0, -0x190(%rbp,%r15,4)
je 0x44007
movzbl -0xd0(%rbp,%r15), %ecx
movl $0x2, %edi
movq %r14, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x4ded0
movq -0x40(%rbp), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x44011
movl -0x210(%rbp,%r15,4), %eax
decl %eax
movl %eax, -0x290(%rbp,%r15,4)
incq %r15
cmpq %r15, %rbx
jne 0x43fd6
cmpb $0x0, 0x6(%rsi)
je 0x443f7
movq -0x30(%rbp), %rcx
leaq 0x30(%rcx), %rax
movq %rax, -0x80(%rbp)
leaq 0x68(%rsi), %rax
movq %rax, -0x78(%rbp)
leaq 0x40(%rcx), %rax
movq %rax, -0xa0(%rbp)
cmpl $0x4, %r12d
sete %al
cmpq $0x0, 0x30(%rbp)
setne %dl
andb %al, %dl
movb %dl, -0x32(%rbp)
cmpq $0x0, 0x10(%rbp)
setne %al
cmpq $0x0, 0x18(%rbp)
setne %dl
andb %al, %dl
movb %dl, -0x31(%rbp)
leaq 0x9cc60(%rcx), %rax
movq %rax, -0x98(%rbp)
xorl %r11d, %r11d
xorl %r13d, %r13d
movl $0x0, -0x54(%rbp)
movq %r11, -0x68(%rbp)
movzbl 0x8(%rsi,%r11), %r15d
cmpl $0x2, %r12d
je 0x440a9
cmpl $0x10, %r12d
jne 0x440ad
decl %r15d
jmp 0x440ad
addl $0x77, %r15d
movl %r12d, %edi
movl %r15d, %esi
callq 0x4dbc5
movl %eax, -0x50(%rbp)
testl %eax, %eax
je 0x44127
movq -0x30(%rbp), %r14
movq 0x38(%r14), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%r14), %rsi
movsd 0x18(%r14), %xmm1
callq 0x4fe97
cmpl $0x0, 0x9bdd0(%r14)
jne 0x440fa
andpd 0x25840(%rip), %xmm0    # 0x69930
ucomisd 0x28c10(%rip), %xmm0    # 0x6cd08
jbe 0x44109
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 -0x80(%rbp), %rdi
movl -0x50(%rbp), %edx
callq 0x430c2
movl %eax, -0x54(%rbp)
jmp 0x44140
movl $0x2, %edi
leaq 0x2b984(%rip), %rsi     # 0x6fab7
movl -0x44(%rbp), %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4ded0
movq -0x40(%rbp), %rsi
movb 0x7(%rsi), %al
testb %al, %al
movq -0x68(%rbp), %r11
je 0x443e3
movl -0x50(%rbp), %ecx
addl $-0x1, %ecx
setb %dl
movl -0x54(%rbp), %edi
testl %edi, %edi
setns %r9b
andb %dl, %r9b
movl %edi, %r15d
movslq %ecx, %rbx
xorl %r12d, %r12d
movq -0x78(%rbp), %rcx
movq %rbx, -0xa8(%rbp)
movzbl %al, %eax
imulq %r11, %rax
addq %rcx, %rax
cmpb $0x0, (%r12,%rax)
je 0x443ca
testb %r9b, %r9b
je 0x443c7
movslq -0x290(%rbp,%r12,4), %r14
testq %r14, %r14
js 0x443c7
movl %r9d, %ebx
movl -0x210(%rbp,%r12,4), %esi
decl %esi
movl -0x50(%rbp), %edi
movq -0xa0(%rbp), %rdx
callq 0x530a2
cmpb $0x0, -0x32(%rbp)
je 0x44227
movq 0x30(%rbp), %rax
movq -0x68(%rbp), %r11
movl (%rax,%r11,4), %eax
cmpl $0xd, %eax
movq -0x70(%rbp), %rdx
xorpd %xmm3, %xmm3
jg 0x44233
addl $-0x7, %eax
xorl %ecx, %ecx
cmpl $0x2, -0x210(%rbp,%r12,4)
sete %cl
shll $0x3, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
leaq 0x2aba8(%rip), %rax     # 0x6edb0
mulsd (%rcx,%rax), %xmm1
leaq 0x2abac(%rip), %rax     # 0x6edc0
addsd (%rcx,%rax), %xmm1
movsd 0x27b7f(%rip), %xmm0    # 0x6bda0
divsd %xmm1, %xmm0
jmp 0x44233
movq -0x70(%rbp), %rdx
xorpd %xmm3, %xmm3
movq -0x68(%rbp), %r11
movsd (%rdx,%r11,8), %xmm1
ucomisd %xmm3, %xmm1
movslq %r13d, %rax
movq -0x98(%rbp), %rdi
movl %ebx, %r9d
jne 0x4424e
jnp 0x4427f
movq -0x88(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd 0x2ac2e(%rip), %xmm2    # 0x6ee90
jbe 0x4427f
addsd %xmm2, %xmm1
leaq (%r15,%r15,2), %rcx
shlq $0x5, %rcx
movq -0x30(%rbp), %rsi
addq 0x38(%rsi), %rcx
movsd %xmm1, 0x38(%rcx,%r14,8)
movsd (%rdx,%r11,8), %xmm1
ucomisd %xmm3, %xmm1
movq -0xa8(%rbp), %rbx
jne 0x44294
jnp 0x442cf
movq -0x90(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm2
ucomisd 0x2abe8(%rip), %xmm2    # 0x6ee90
jbe 0x442cf
ucomisd %xmm3, %xmm0
jbe 0x442cf
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 0x44322
movq 0x18(%rbp), %rcx
movsd (%rcx,%rax,8), %xmm1
ucomisd 0x2abaa(%rip), %xmm1    # 0x6ee90
jbe 0x44322
ucomisd %xmm3, %xmm0
jbe 0x44322
movq 0x10(%rbp), %rcx
addsd (%rcx,%r11,8), %xmm1
xorpd 0x267d0(%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
jne 0x44341
leaq (%rbx,%rbx,2), %rdx
leaq (%rdi,%rdx,2), %rdx
cmpw $0x0, (%rdx,%r14,2)
je 0x443dc
leaq (%rbx,%rbx,2), %rdx
leaq (%rdi,%rdx,2), %rdx
movzwl (%rdx,%r14,2), %edx
cmpl %edx, %ecx
setl %dl
leaq (%rbx,%rbx,2), %rsi
leaq (%rdi,%rsi,2), %rsi
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 0x2650a(%rip), %xmm0    # 0x6a8a8
cvttsd2si %xmm0, %eax
movq 0x38(%rdi), %rcx
addq %rdx, %rcx
movb %al, 0x12(%r14,%rcx)
movb -0xd0(%rbp,%r12), %al
addq 0x38(%rdi), %rdx
movb %al, 0x18(%r14,%rdx)
movq -0x40(%rbp), %rsi
movq -0x78(%rbp), %rcx
incl %r13d
incq %r12
movzbl 0x7(%rsi), %eax
cmpq %rax, %r12
jb 0x4417c
jmp 0x443e3
movb $0x1, %dl
jmp 0x44353
incq %r11
movzbl 0x6(%rsi), %eax
cmpq %rax, %r11
movq -0x60(%rbp), %r12
jb 0x4408e
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
leaq 0x9bc50(%rax), %r13
movq %r13, %rdx
movq -0x40(%rbp), %rsi
jmp 0x43ce7