// File: DoubleString[P]RtConverter/src/Rtklib/rtcm2.cpp
// Function: bamboo::decode_type22(bamboo::rtcm_t*)
static int decode_type22(rtcm_t *rtcm)
{
    double del[2][3]={{0}},hgt=0.0;
    int i=48,j,noh;
    
    trace(4,"decode_type22: len=%d\n",rtcm->len);
    
    if (i+24<=rtcm->len*8) {
        del[0][0]=getbits(rtcm->buff,i,8)/25600.0; i+=8;
        del[0][1]=getbits(rtcm->buff,i,8)/25600.0; i+=8;
        del[0][2]=getbits(rtcm->buff,i,8)/25600.0; i+=8;
    }
    else {
        trace(2,"rtcm2 22 length error: len=%d\n",rtcm->len);
        return -1;
    }
    if (i+24<=rtcm->len*8) {
        i+=5; noh=getbits(rtcm->buff,i,1); i+=1;
        hgt=noh?0.0:getbitu(rtcm->buff,i,18)/25600.0;
        i+=18;
    }
    if (i+24<=rtcm->len*8) {
        del[1][0]=getbits(rtcm->buff,i,8)/1600.0; i+=8;
        del[1][1]=getbits(rtcm->buff,i,8)/1600.0; i+=8;
        del[1][2]=getbits(rtcm->buff,i,8)/1600.0;
    }
    rtcm->sta.deltype=1; /* xyz */
    for (j=0;j<3;j++) rtcm->sta.del[j]=del[0][j];
    rtcm->sta.hgt=hgt;
    return 5;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x93d0
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x30, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x4, %edi
leaq 0x532e2(%rip), %rsi     # 0xc09a3
movb $0x0, %al
callq 0x8b980
movl -0x4c(%rbp), %eax
addl $0x18, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x6d787
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52e89(%rip), %xmm1    # 0xc0590
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x4c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52e53(%rip), %xmm1    # 0xc0590
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x4c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52e1d(%rip), %xmm1    # 0xc0590
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x4c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x4c(%rbp)
jmp 0x6d7b0
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x2, %edi
leaq 0x5321d(%rip), %rsi     # 0xc09ba
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6d958
movl -0x4c(%rbp), %eax
addl $0x18, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x6d84b
movl -0x4c(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x1, %edx
callq 0x8c050
movl %eax, -0x54(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x6d808
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x6d838
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x12, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd 0x52d61(%rip), %xmm1    # 0xc0590
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x4c(%rbp), %eax
addl $0x12, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x18, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x6d8ff
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52d0e(%rip), %xmm1    # 0xc0598
divsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x4c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52cd8(%rip), %xmm1    # 0xc0598
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x4c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x4c(%rbp), %esi
movl $0x8, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x52ca2(%rip), %xmm1    # 0xc0598
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x6f100(%rax)
movl $0x0, -0x50(%rbp)
cmpl $0x3, -0x50(%rbp)
jge 0x6d940
movslq -0x50(%rbp), %rax
movsd -0x40(%rbp,%rax,8), %xmm0
movq -0x10(%rbp), %rax
movslq -0x50(%rbp), %rcx
movsd %xmm0, 0x6f120(%rax,%rcx,8)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x6d914
movsd -0x48(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x6f138(%rax)
movl $0x5, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)