// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_msm4(bamboo::rtcm_t*, int)
static int decode_msm4(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*48>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,15); i+=15;
        if (prv!=-16384) pr[j]=prv*P2_24*RANGE_MS;
    }
    for (j=0;j<ncell;j++) { /* phaserange */
        cpv=getbits(rtcm->buff,i,22); i+=22;
        if (cpv!=-2097152) cp[j]=cpv*P2_29*RANGE_MS;
    }
    for (j=0;j<ncell;j++) { /* lock time */
        lock[j]=getbitu(rtcm->buff,i,4); i+=4;
    }
    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,6)*1.0; i+=6;
    }
    /* 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 0x39ff1
movl -0x34(%rbp), %r12d
movzbl -0xee(%rbp), %ecx
imull $0x12, %ecx, %edx
imull $0x30, %eax, %esi
addl %r12d, %esi
addl %edx, %esi
movl 0x9f0c0(%rbx), %r9d
leal (,%r9,8), %edx
cmpl %edx, %esi
jle 0x39d8c
leaq 0x2bcc8(%rip), %rsi     # 0x65a3f
pushq $0x2
popq %rdi
movl %r14d, %edx
movl %eax, %r8d
xorl %eax, %eax
callq 0x455bc
jmp 0x39ff1
movl %ecx, %edx
xorl %ecx, %ecx
cmpq %rcx, %rdx
je 0x39da3
andq $0x0, -0x300(%rbp,%rcx,8)
incq %rcx
jmp 0x39d90
movl %eax, %r13d
xorl %eax, %eax
movabsq $-0x3cbe3c86c81f8000, %rcx # imm = 0xC341C37937E08000
cmpq %rax, %r13
je 0x39dcc
movq %rcx, -0x700(%rbp,%rax,8)
movq %rcx, -0x900(%rbp,%rax,8)
incq %rax
jmp 0x39db2
movq %rbx, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
leal (,%rdx,8), %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0x39e15
leaq (%r12,%r14), %rsi
movq %r15, %rdi
pushq $0x8
popq %rdx
callq 0x459f7
cmpl $0xff, %eax
je 0x39e0f
cvtsi2sd %eax, %xmm0
mulsd 0x2a8f3(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x300(%rbp,%r14)
addq $0x8, %r14
jmp 0x39dde
addl %r14d, %r12d
xorl %r14d, %r14d
pushq $0xa
popq %rbx
cmpq %r14, -0x48(%rbp)
je 0x39e72
movq %r15, %rdi
movl %r12d, %esi
movl %ebx, %edx
callq 0x459f7
movsd -0x300(%rbp,%r14,8), %xmm0
ucomisd 0x26ab5(%rip), %xmm0    # 0x608f8
jne 0x39e47
jnp 0x39e69
cvtsi2sd %eax, %xmm1
mulsd 0x2a8d5(%rip), %xmm1    # 0x64728
mulsd 0x2a89d(%rip), %xmm1    # 0x646f8
addsd %xmm0, %xmm1
movsd %xmm1, -0x300(%rbp,%r14,8)
incq %r14
addl $0xa, %r12d
jmp 0x39e1e
xorl %ebx, %ebx
pushq $0xf
popq %r14
cmpq %rbx, %r13
je 0x39eb8
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x45a39
cmpl $0xffffc000, %eax       # imm = 0xFFFFC000
je 0x39eaf
cvtsi2sd %eax, %xmm0
mulsd 0x28eb2(%rip), %xmm0    # 0x62d50
mulsd 0x2a852(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x900(%rbp,%rbx,8)
incq %rbx
addl $0xf, %r12d
jmp 0x39e78
xorl %ebx, %ebx
pushq $0x16
popq %r14
cmpq %rbx, %r13
je 0x39efe
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x45a39
cmpl $0xffe00000, %eax       # imm = 0xFFE00000
je 0x39ef5
cvtsi2sd %eax, %xmm0
mulsd 0x28df4(%rip), %xmm0    # 0x62cd8
mulsd 0x2a80c(%rip), %xmm0    # 0x646f8
movsd %xmm0, -0x700(%rbp,%rbx,8)
incq %rbx
addl $0x16, %r12d
jmp 0x39ebe
xorl %ebx, %ebx
pushq $0x4
popq %r14
cmpq %rbx, %r13
je 0x39f27
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x500(%rbp,%rbx,4)
addl $0x4, %r12d
incq %rbx
jmp 0x39f04
xorl %ebx, %ebx
pushq $0x1
popq %r14
cmpq %rbx, %r13
je 0x39f4f
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x400(%rbp,%rbx,4)
incl %r12d
incq %rbx
jmp 0x39f2d
xorl %ebx, %ebx
pushq $0x6
popq %r14
cmpq %rbx, %r13
je 0x39f81
movq %r15, %rdi
movl %r12d, %esi
movl %r14d, %edx
callq 0x459f7
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0xb00(%rbp,%rbx,8)
addl $0x6, %r12d
incq %rbx
jmp 0x39f55
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