// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_msm5(bamboo::rtcm_t*, int)
static int decode_msm5(rtcm_t *rtcm, int sys)
{
    msm_h_t h={0};
    double r[64],rr[64],pr[64],cp[64],rrf[64],cnr[64];
    int i,j,type,sync,iod,ncell,rng,rng_m,rate,prv,cpv,rrv,lock[64];
    int ex[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*36+ncell*63>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]=rr[j]=0.0; ex[j]=15;
    }
    for (j=0;j<ncell;j++) pr[j]=cp[j]=rrf[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++) { /* extended info */
        ex[j]=getbitu(rtcm->buff,i, 4); i+= 4;
    }
    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;
    }
    for (j=0;j<h.nsat;j++) { /* phaserangerate */
        rate =getbits(rtcm->buff,i,14); i+=14;
        if (rate!=-8192) rr[j]=rate*1.0;
    }
    /* 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;
    }
    for (j=0;j<ncell;j++) { /* phaserangerate */
        rrv=getbits(rtcm->buff,i,15); i+=15;
        if (rrv!=-16384) rrf[j]=rrv*0.0001;
    }
    /* save obs data in msm message */
    save_msm_obs(rtcm,sys,&h,r,pr,cp,rr,rrf,cnr,lock,ex,half);
    
    rtcm->obsflag=!sync;
    return sync?0:1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1028, %rsp           # imm = 0x1028
movq %rdi, -0x28(%rbp)
movl %esi, -0x2c(%rbp)
leaq -0xd4(%rbp), %rdi
xorl %esi, %esi
movl $0xa8, %edx
callq 0x93d0
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl $0x18, %esi
movl $0xc, %edx
callq 0x8bfc0
movl %eax, -0xcec(%rbp)
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %esi
leaq -0xcf0(%rbp), %rdx
leaq -0xcf4(%rbp), %rcx
leaq -0xd4(%rbp), %r8
leaq -0xce4(%rbp), %r9
callq 0x7b250
movl %eax, -0xcf8(%rbp)
cmpl $0x0, %eax
jge 0x78049
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x78775
movl -0xce4(%rbp), %eax
movzbl -0xce(%rbp), %ecx
imull $0x24, %ecx, %ecx
addl %ecx, %eax
imull $0x3f, -0xcf8(%rbp), %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jle 0x780b3
movl -0xcec(%rbp), %edx
movzbl -0xce(%rbp), %ecx
movl -0xcf8(%rbp), %r8d
movq -0x28(%rbp), %rax
movl 0x9f0c0(%rax), %r9d
movl $0x2, %edi
leaq 0x49bc8(%rip), %rsi     # 0xc1c68
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x78775
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78117
movslq -0xce8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x4e0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x2e0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
movl $0xf, -0xf10(%rbp,%rax,4)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x780bd
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x78188
movslq -0xce8(%rbp), %rax
movsd 0x488f2(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0xae0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
movsd 0x488da(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0x8e0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
movsd 0x488c2(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0x6e0(%rbp,%rax,8)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78121
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78219
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x8, %edx
callq 0x8bfc0
movl %eax, -0xcfc(%rbp)
movl -0xce4(%rbp), %eax
addl $0x8, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xff, -0xcfc(%rbp)
je 0x78203
cvtsi2sdl -0xcfc(%rbp), %xmm0
movsd 0x487f1(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x2e0(%rbp,%rax,8)
jmp 0x78205
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78192
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7827f
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, %ecx
movslq -0xce8(%rbp), %rax
movl %ecx, -0xf10(%rbp,%rax,4)
movl -0xce4(%rbp), %eax
addl $0x4, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78223
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7833e
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xa, %edx
callq 0x8bfc0
movl %eax, -0xd00(%rbp)
movl -0xce4(%rbp), %eax
addl $0xa, %eax
movl %eax, -0xce4(%rbp)
movslq -0xce8(%rbp), %rax
movsd -0x2e0(%rbp,%rax,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x782eb
jp 0x782eb
jmp 0x78328
cvtsi2sdl -0xd00(%rbp), %xmm0
movsd 0x4872d(%rip), %xmm1    # 0xc0a28
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd -0x2e0(%rbp,%rax,8), %xmm1
movsd 0x486c9(%rip), %xmm2    # 0xc09e0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x2e0(%rbp,%rax,8)
jmp 0x7832a
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78289
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x783cf
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xe, %edx
callq 0x8c050
movl %eax, -0xd04(%rbp)
movl -0xce4(%rbp), %eax
addl $0xe, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xffffe000, -0xd04(%rbp) # imm = 0xFFFFE000
je 0x783b9
cvtsi2sdl -0xd04(%rbp), %xmm0
movsd 0x43abb(%rip), %xmm1    # 0xbbe60
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x4e0(%rbp,%rax,8)
jmp 0x783bb
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78348
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x7846d
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xf, %edx
callq 0x8c050
movl %eax, -0xd08(%rbp)
movl -0xce4(%rbp), %eax
addl $0xf, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xffffc000, -0xd08(%rbp) # imm = 0xFFFFC000
je 0x78457
cvtsi2sdl -0xd08(%rbp), %xmm0
movsd 0x46a91(%rip), %xmm1    # 0xbeec8
mulsd %xmm1, %xmm0
movsd 0x4859d(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x6e0(%rbp,%rax,8)
jmp 0x78459
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x783d9
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x7850b
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x16, %edx
callq 0x8c050
movl %eax, -0xd0c(%rbp)
movl -0xce4(%rbp), %eax
addl $0x16, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xffe00000, -0xd0c(%rbp) # imm = 0xFFE00000
je 0x784f5
cvtsi2sdl -0xd0c(%rbp), %xmm0
movsd 0x4699b(%rip), %xmm1    # 0xbee70
mulsd %xmm1, %xmm0
movsd 0x484ff(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x8e0(%rbp,%rax,8)
jmp 0x784f7
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78477
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x7856e
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, %ecx
movslq -0xce8(%rbp), %rax
movl %ecx, -0xe10(%rbp,%rax,4)
movl -0xce4(%rbp), %eax
addl $0x4, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78515
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x785d1
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, %ecx
movslq -0xce8(%rbp), %rax
movl %ecx, -0x1010(%rbp,%rax,4)
movl -0xce4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78578
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x78647
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x6, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x4384d(%rip), %xmm1    # 0xbbe60
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0xce0(%rbp,%rax,8)
movl -0xce4(%rbp), %eax
addl $0x6, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x785db
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x786d5
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xf, %edx
callq 0x8c050
movl %eax, -0xd10(%rbp)
movl -0xce4(%rbp), %eax
addl $0xf, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xffffc000, -0xd10(%rbp) # imm = 0xFFFFC000
je 0x786bf
cvtsi2sdl -0xd10(%rbp), %xmm0
movsd 0x447bd(%rip), %xmm1    # 0xbce68
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0xae0(%rbp,%rax,8)
jmp 0x786c1
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78651
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %esi
leaq -0x2e0(%rbp), %rcx
leaq -0x6e0(%rbp), %r8
leaq -0x8e0(%rbp), %r9
leaq -0x4e0(%rbp), %r15
leaq -0xae0(%rbp), %r14
leaq -0xce0(%rbp), %rbx
leaq -0xe10(%rbp), %r11
leaq -0xf10(%rbp), %r10
leaq -0x1010(%rbp), %rax
leaq -0xd4(%rbp), %rdx
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
callq 0x7b9f0
cmpl $0x0, -0xcf0(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x9bdd0(%rax)
movl -0xcf0(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x1028, %rsp           # imm = 0x1028
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)