// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_msm7(bamboo::rtcm_t*, int)
static int decode_msm7(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*80>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,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 amiguity */
        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;
    }
    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 0x78e19
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x79545
movl -0xce4(%rbp), %eax
movzbl -0xce(%rbp), %ecx
imull $0x24, %ecx, %ecx
addl %ecx, %eax
imull $0x50, -0xcf8(%rbp), %ecx
addl %ecx, %eax
movq -0x28(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jle 0x78e83
movl -0xcec(%rbp), %edx
movzbl -0xce(%rbp), %ecx
movl -0xcf8(%rbp), %r8d
movq -0x28(%rbp), %rax
movl 0x9f0c0(%rax), %r9d
movl $0x2, %edi
leaq 0x48df8(%rip), %rsi     # 0xc1c68
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
jmp 0x79545
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78ee7
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 0x78e8d
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x78f58
movslq -0xce8(%rbp), %rax
movsd 0x47b22(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0xae0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
movsd 0x47b0a(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0x8e0(%rbp,%rax,8)
movslq -0xce8(%rbp), %rax
movsd 0x47af2(%rip), %xmm0    # 0xc0a30
movsd %xmm0, -0x6e0(%rbp,%rax,8)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78ef1
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78fe9
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 0x78fd3
cvtsi2sdl -0xcfc(%rbp), %xmm0
movsd 0x47a21(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x2e0(%rbp,%rax,8)
jmp 0x78fd5
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x78f62
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7904f
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 0x78ff3
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7910e
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 0x790bb
jp 0x790bb
jmp 0x790f8
cvtsi2sdl -0xd00(%rbp), %xmm0
movsd 0x4795d(%rip), %xmm1    # 0xc0a28
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd -0x2e0(%rbp,%rax,8), %xmm1
movsd 0x478f9(%rip), %xmm2    # 0xc09e0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x2e0(%rbp,%rax,8)
jmp 0x790fa
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x79059
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
movzbl -0xce(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7919f
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 0x79189
cvtsi2sdl -0xd04(%rbp), %xmm0
movsd 0x42ceb(%rip), %xmm1    # 0xbbe60
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x4e0(%rbp,%rax,8)
jmp 0x7918b
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x79118
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x7923d
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x14, %edx
callq 0x8c050
movl %eax, -0xd08(%rbp)
movl -0xce4(%rbp), %eax
addl $0x14, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xfff80000, -0xd08(%rbp) # imm = 0xFFF80000
je 0x79227
cvtsi2sdl -0xd08(%rbp), %xmm0
movsd 0x45c69(%rip), %xmm1    # 0xbee70
mulsd %xmm1, %xmm0
movsd 0x477cd(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x6e0(%rbp,%rax,8)
jmp 0x79229
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x791a9
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x792db
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0x18, %edx
callq 0x8c050
movl %eax, -0xd0c(%rbp)
movl -0xce4(%rbp), %eax
addl $0x18, %eax
movl %eax, -0xce4(%rbp)
cmpl $0xff800000, -0xd0c(%rbp) # imm = 0xFF800000
je 0x792c5
cvtsi2sdl -0xd0c(%rbp), %xmm0
movsd 0x43d33(%rip), %xmm1    # 0xbcfd8
mulsd %xmm1, %xmm0
movsd 0x4772f(%rip), %xmm1    # 0xc09e0
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0x8e0(%rbp,%rax,8)
jmp 0x792c7
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x79247
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x7933e
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xa, %edx
callq 0x8bfc0
movl %eax, %ecx
movslq -0xce8(%rbp), %rax
movl %ecx, -0xe10(%rbp,%rax,4)
movl -0xce4(%rbp), %eax
addl $0xa, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x792e5
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x793a1
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 0x79348
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x79417
movq -0x28(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0xce4(%rbp), %esi
movl $0xa, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x47655(%rip), %xmm1    # 0xc0a38
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0xce0(%rbp,%rax,8)
movl -0xce4(%rbp), %eax
addl $0xa, %eax
movl %eax, -0xce4(%rbp)
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x793ab
movl $0x0, -0xce8(%rbp)
movl -0xce8(%rbp), %eax
cmpl -0xcf8(%rbp), %eax
jge 0x794a5
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 0x7948f
cvtsi2sdl -0xd10(%rbp), %xmm0
movsd 0x439ed(%rip), %xmm1    # 0xbce68
mulsd %xmm1, %xmm0
movslq -0xce8(%rbp), %rax
movsd %xmm0, -0xae0(%rbp,%rax,8)
jmp 0x79491
movl -0xce8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xce8(%rbp)
jmp 0x79421
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)