// File: /workspace/github_cpp_makefile_star2_O1/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 $0xaf8, %rsp            # imm = 0xAF8
movl %esi, %r13d
movq %rdi, %r12
leaq -0xec(%rbp), %r14
movl $0xa8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x8390
leaq 0x9f0c4(%r12), %r15
movq %r15, %rdi
movl $0x18, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, %ebx
leaq -0x38(%rbp), %rdx
leaq -0x44(%rbp), %rcx
leaq -0x2c(%rbp), %r9
movq %r12, %rdi
movl %r13d, -0x34(%rbp)
movl %r13d, %esi
movq %r14, %r8
callq 0x4380e
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4232a
movl %eax, %r8d
movzbl -0xe6(%rbp), %r14d
leal (%r14,%r14,8), %eax
movl %r8d, %ecx
shll $0x6, %ecx
addl %r8d, %ecx
addl -0x2c(%rbp), %ecx
leal (%rcx,%rax,2), %eax
movl 0x9f0c0(%r12), %r9d
leal (,%r9,8), %ecx
cmpl %ecx, %eax
jle 0x42011
leaq 0x2da48(%rip), %rsi     # 0x6fa43
movl $0x2, %edi
movl %ebx, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4ded0
jmp 0x4232a
testq %r14, %r14
movl %r8d, -0x30(%rbp)
je 0x42034
leal (,%r14,8), %edx
leaq -0x2f0(%rbp), %rdi
xorl %esi, %esi
callq 0x8390
movl -0x30(%rbp), %r8d
testl %r8d, %r8d
je 0x4206a
cmpl $0x2, %r8d
movl $0x1, %eax
cmovgel %r8d, %eax
xorl %ecx, %ecx
movabsq $-0x3cbe3c86c81f8000, %rdx # imm = 0xC341C37937E08000
movq %rdx, -0x6f0(%rbp,%rcx,8)
movq %rdx, -0x8f0(%rbp,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x42052
movl -0x2c(%rbp), %r13d
testl %r14d, %r14d
movq %r12, -0x40(%rbp)
je 0x420c4
leal (,%r14,8), %r12d
xorl %ebx, %ebx
leal (%rbx,%r13), %esi
movq %r15, %rdi
movl $0x8, %edx
callq 0x4e341
cmpl $0xff, %eax
je 0x420b1
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x2cd58(%rip), %xmm0    # 0x6ee00
movsd %xmm0, -0x2f0(%rbp,%rbx)
addq $0x8, %rbx
cmpq %rbx, %r12
jne 0x42081
addl %r13d, %ebx
movl %ebx, %r13d
movq -0x40(%rbp), %r12
movl %r13d, -0x2c(%rbp)
testq %r14, %r14
je 0x4212a
movl %r14d, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
movl %r13d, %esi
movl $0xa, %edx
callq 0x4e341
movsd -0x2f0(%rbp,%r14,8), %xmm0
ucomisd 0x28813(%rip), %xmm0    # 0x6a908
jne 0x420f9
jnp 0x4211e
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x2cd68(%rip), %xmm1    # 0x6ee70
mulsd 0x2ccf0(%rip), %xmm1    # 0x6ee00
addsd %xmm0, %xmm1
movsd %xmm1, -0x2f0(%rbp,%r14,8)
incq %r14
addl $0xa, %r13d
cmpq %r14, %rbx
jne 0x420d3
movl %r13d, -0x2c(%rbp)
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x42187
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
movl %r13d, %esi
movl $0x14, %edx
callq 0x4e390
cmpl $0xfff80000, %eax       # imm = 0xFFF80000
je 0x4217b
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x2ab6f(%rip), %xmm0    # 0x6ccd8
mulsd 0x2cc8f(%rip), %xmm0    # 0x6ee00
movsd %xmm0, -0x8f0(%rbp,%r14,8)
incq %r14
addl $0x14, %r13d
cmpq %r14, %rbx
jne 0x42143
movl %r13d, -0x2c(%rbp)
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x421e4
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
movl %r13d, %esi
movl $0x18, %edx
callq 0x4e390
cmpl $0xff800000, %eax       # imm = 0xFF800000
je 0x421d8
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x2aaf2(%rip), %xmm0    # 0x6ccb8
mulsd 0x2cc32(%rip), %xmm0    # 0x6ee00
movsd %xmm0, -0x6f0(%rbp,%r14,8)
incq %r14
addl $0x18, %r13d
cmpq %r14, %rbx
jne 0x421a0
movl %r13d, -0x2c(%rbp)
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x42221
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
movl %r13d, %esi
movl $0xa, %edx
callq 0x4e341
movl %eax, -0x4f0(%rbp,%r14,4)
addl $0xa, %r13d
incq %r14
cmpq %r14, %rbx
jne 0x421fd
movl %r13d, -0x2c(%rbp)
movl -0x30(%rbp), %eax
testl %eax, %eax
je 0x42268
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
movl %r13d, %r12d
xorl %r14d, %r14d
leal (%r12,%r14), %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0x4e341
movl %eax, -0x3f0(%rbp,%r14,4)
incq %r14
cmpq %r14, %rbx
jne 0x4223d
addl %r14d, %r13d
movq -0x40(%rbp), %r12
movl -0x30(%rbp), %eax
movl %r13d, -0x2c(%rbp)
testl %eax, %eax
je 0x422b6
cmpl $0x2, %eax
movl $0x1, %ebx
cmovgel %eax, %ebx
xorl %r14d, %r14d
movq %r15, %rdi
movl %r13d, %esi
movl $0xa, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2cbd8(%rip), %xmm0    # 0x6ee78
movsd %xmm0, -0xaf0(%rbp,%r14,8)
addl $0xa, %r13d
incq %r14
cmpq %r14, %rbx
jne 0x4227e
movl %r13d, -0x2c(%rbp)
leaq -0x3f0(%rbp), %rax
movq %rax, 0x28(%rsp)
leaq -0x4f0(%rbp), %rax
movq %rax, 0x18(%rsp)
leaq -0xaf0(%rbp), %rax
movq %rax, 0x10(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, (%rsp)
movq $0x0, 0x20(%rsp)
leaq -0xec(%rbp), %rdx
leaq -0x2f0(%rbp), %rcx
leaq -0x8f0(%rbp), %r8
leaq -0x6f0(%rbp), %r9
movq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x43c1c
xorl %r13d, %r13d
cmpl $0x0, -0x38(%rbp)
sete %r13b
movl %r13d, 0x9bdd0(%r12)
movl %r13d, %eax
addq $0xaf8, %rsp            # imm = 0xAF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq