// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_msm6(bamboo::rtcm_t*, int)
static int decode_msm6(rtcm_t *rtcm, int sys)
{
    msm_h_t h={0};
    double r[64],pr[64],cp[64],cnr[64];
    int i,j,type,sync,iod,ncell,rng,rng_m,prv,cpv,lock[64],half[64];
    
    type=getbitu(rtcm->buff,24,12);
    
    /* decode msm header */
    if ((ncell=decode_msm_head(rtcm,sys,&sync,&iod,&h,&i))<0) return -1;
    
    if (i+h.nsat*18+ncell*65>rtcm->len*8) {
        trace(2,"rtcm3 %d length error: nsat=%d ncell=%d len=%d\n",type,h.nsat,
              ncell,rtcm->len);
        return -1;
    }
    for (j=0;j<h.nsat;j++) r[j]=0.0;
    for (j=0;j<ncell;j++) pr[j]=cp[j]=-1E16;
    
    /* decode satellite data */
    for (j=0;j<h.nsat;j++) { /* range */
        rng  =getbitu(rtcm->buff,i, 8); i+= 8;
        if (rng!=255) r[j]=rng*RANGE_MS;
    }
    for (j=0;j<h.nsat;j++) {
        rng_m=getbitu(rtcm->buff,i,10); i+=10;
        if (r[j]!=0.0) r[j]+=rng_m*P2_10*RANGE_MS;
    }
    /* decode signal data */
    for (j=0;j<ncell;j++) { /* pseudorange */
        prv=getbits(rtcm->buff,i,20); i+=20;
        if (prv!=-524288) pr[j]=prv*P2_29*RANGE_MS;
    }
    for (j=0;j<ncell;j++) { /* phaserange */
        cpv=getbits(rtcm->buff,i,24); i+=24;
        if (cpv!=-8388608) cp[j]=cpv*P2_31*RANGE_MS;
    }
    for (j=0;j<ncell;j++) { /* lock time */
        lock[j]=getbitu(rtcm->buff,i,10); i+=10;
    }
    for (j=0;j<ncell;j++) { /* half-cycle ambiguity */
        half[j]=getbitu(rtcm->buff,i,1); i+=1;
    }
    for (j=0;j<ncell;j++) { /* cnr */
        cnr[j]=getbitu(rtcm->buff,i,10)*0.0625; i+=10;
    }
    /* save obs data in msm message */
    save_msm_obs(rtcm,sys,&h,r,pr,cp,NULL,NULL,cnr,lock,NULL,half);
    
    rtcm->obsflag=!sync;
    return sync?0:1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb08, %rsp            # imm = 0xB08
movl %esi, %r13d
movq %rdi, %rbx
leaq -0xf4(%rbp), %r12
movl $0xa8, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x8390
leaq 0x9f0c4(%rbx), %r15
pushq $0x18
popq %rsi
pushq $0xc
popq %rdx
movq %r15, %rdi
callq 0x459f7
movl %eax, %r14d
leaq -0x30(%rbp), %rdx
leaq -0x4c(%rbp), %rcx
leaq -0x34(%rbp), %r9
movq %rbx, %rdi
movl %r13d, -0x2c(%rbp)
movl %r13d, %esi
movq %r12, %r8
callq 0x3bb81
pushq $-0x1
popq %r13
testl %eax, %eax
js 0x3a714
movl -0x34(%rbp), %r12d
movzbl -0xee(%rbp), %ecx
imull $0x12, %ecx, %edx
imull $0x41, %eax, %esi
addl %r12d, %esi
addl %edx, %esi
movl 0x9f0c0(%rbx), %r9d
leal (,%r9,8), %edx
cmpl %edx, %esi
jle 0x3a4a7
leaq 0x2b5ad(%rip), %rsi     # 0x65a3f
pushq $0x2
popq %rdi
movl %r14d, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x455bc
jmp 0x3a714
movl %ecx, %edx
xorl %ecx, %ecx
cmpq %rcx, %rdx
je 0x3a4be
andq $0x0, -0x300(%rbp,%rcx,8)
incq %rcx
jmp 0x3a4ab
movl %eax, %r13d
xorl %eax, %eax
movabsq $-0x3cbe3c86c81f8000, %rcx # imm = 0xC341C37937E08000
cmpq %rax, %r13
je 0x3a4e7
movq %rcx, -0x700(%rbp,%rax,8)
movq %rcx, -0x900(%rbp,%rax,8)
incq %rax
jmp 0x3a4cd
movq %rbx, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
leal (,%rdx,8), %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x3a530
leaq (%r12,%r14), %rsi
movq %r15, %rdi
pushq $0x8
popq %rdx
callq 0x459f7
cmpl $0xff, %eax
je 0x3a52a
cvtsi2sd %eax, %xmm0
mulsd 0x2a1d8(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x300(%rbp,%r14)
addq $0x8, %r14
jmp 0x3a4f9
addl %r14d, %r12d
xorl %r14d, %r14d
pushq $0xa
popq %rbx
cmpq %r14, -0x48(%rbp)
je 0x3a58d
movq %r15, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x459f7
movsd -0x300(%rbp,%r14,8), %xmm0
ucomisd 0x2639a(%rip), %xmm0    # 0x608f8
jne 0x3a562
jnp 0x3a584
cvtsi2sd %eax, %xmm1
mulsd 0x2a1ba(%rip), %xmm1    # 0x64728
mulsd 0x2a182(%rip), %xmm1    # 0x646f8
addsd %xmm0, %xmm1
movsd %xmm1, -0x300(%rbp,%r14,8)
incq %r14
addl $0xa, %r12d
jmp 0x3a539
xorl %ebx, %ebx
pushq $0x14
popq %r14
cmpq %rbx, %r13
je 0x3a5d3
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x45a39
cmpl $0xfff80000, %eax       # imm = 0xFFF80000
je 0x3a5ca
cvtsi2sd %eax, %xmm0
mulsd 0x2871f(%rip), %xmm0    # 0x62cd8
mulsd 0x2a137(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x900(%rbp,%rbx,8)
incq %rbx
addl $0x14, %r12d
jmp 0x3a593
xorl %ebx, %ebx
pushq $0x18
popq %r14
cmpq %rbx, %r13
je 0x3a619
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x45a39
cmpl $0xff800000, %eax       # imm = 0xFF800000
je 0x3a610
cvtsi2sd %eax, %xmm0
mulsd 0x286b9(%rip), %xmm0    # 0x62cb8
mulsd 0x2a0f1(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x700(%rbp,%rbx,8)
incq %rbx
addl $0x18, %r12d
jmp 0x3a5d9
xorl %ebx, %ebx
pushq $0xa
popq %r14
cmpq %rbx, %r13
je 0x3a642
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x500(%rbp,%rbx,4)
addl $0xa, %r12d
incq %rbx
jmp 0x3a61f
xorl %ebx, %ebx
pushq $0x1
popq %r14
cmpq %rbx, %r13
je 0x3a66a
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x400(%rbp,%rbx,4)
incl %r12d
incq %rbx
jmp 0x3a648
xorl %ebx, %ebx
pushq $0xa
popq %r14
cmpq %rbx, %r13
je 0x3a6a4
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x2a09e(%rip), %xmm0    # 0x64730
movsd %xmm0, -0xb00(%rbp,%rbx,8)
addl $0xa, %r12d
incq %rbx
jmp 0x3a670
leaq -0x400(%rbp), %rax
movq %rax, 0x28(%rsp)
leaq -0x500(%rbp), %rax
movq %rax, 0x18(%rsp)
leaq -0xb00(%rbp), %rax
movq %rax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
andq $0x0, 0x20(%rsp)
leaq -0xf4(%rbp), %rdx
leaq -0x300(%rbp), %rcx
leaq -0x900(%rbp), %r8
leaq -0x700(%rbp), %r9
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x3bf58
xorl %r13d, %r13d
cmpl $0x0, -0x30(%rbp)
sete %r13b
movl %r13d, 0x9bdd0(%rbx)
movl %r13d, %eax
addq $0xb08, %rsp            # imm = 0xB08
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq