// File: DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_ubx(bamboo::raw_t*)
static int decode_ubx(raw_t *raw)
{
    int type=(U1(raw->buff+2)<<8)+U1(raw->buff+3);
    
    trace(3,"decode_ubx: type=%04x len=%d\n",type,raw->len);
    
    /* checksum */
    if (!checksum(raw->buff,raw->len)) {
        trace(2,"ubx checksum error: type=%04x len=%d\n",type,raw->len);
        return -1;
    }
    switch (type) {
        case ID_RXMRAW  : return decode_rxmraw  (raw);
        case ID_RXMRAWX : return decode_rxmrawx (raw);
        case ID_RXMSFRB : return decode_rxmsfrb (raw);
        case ID_RXMSFRBX: return decode_rxmsfrbx(raw);
        case ID_NAVSOL  : return decode_navsol  (raw);
        case ID_NAVTIME : return decode_navtime (raw);
        case ID_TRKMEAS : return decode_trkmeas (raw);
        case ID_TRKD5   : return decode_trkd5   (raw);
        case ID_TRKSFRBX: return decode_trksfrbx(raw);
    }
    if (raw->outtype) {
        sprintf(raw->msgtype,"UBX 0x%02X 0x%02X (%4d)",type>>8,type&0xF,
                raw->len);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x81a92(%rax), %eax
shll $0x8, %eax
movq -0x10(%rbp), %rcx
movzbl 0x81a93(%rcx), %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %ecx
movl $0x3, %edi
leaq 0x22f18(%rip), %rsi     # 0xcb89b
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rdi
addq $0x81a90, %rdi          # imm = 0x81A90
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %esi
callq 0xa97e0
cmpl $0x0, %eax
jne 0xa89d5
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %ecx
movl $0x2, %edi
leaq 0x22ef7(%rip), %rsi     # 0xcb8b9
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa8b25
movl -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
subl $0x106, %eax            # imm = 0x106
je 0xa8a9b
jmp 0xa89e8
movl -0x18(%rbp), %eax
subl $0x120, %eax            # imm = 0x120
je 0xa8aa9
jmp 0xa89f8
movl -0x18(%rbp), %eax
subl $0x210, %eax            # imm = 0x210
je 0xa8a57
jmp 0xa8a04
movl -0x18(%rbp), %eax
subl $0x211, %eax            # imm = 0x211
je 0xa8a79
jmp 0xa8a10
movl -0x18(%rbp), %eax
subl $0x213, %eax            # imm = 0x213
je 0xa8a8a
jmp 0xa8a1c
movl -0x18(%rbp), %eax
subl $0x215, %eax            # imm = 0x215
je 0xa8a68
jmp 0xa8a28
movl -0x18(%rbp), %eax
subl $0x30a, %eax            # imm = 0x30A
je 0xa8ac5
jmp 0xa8a38
movl -0x18(%rbp), %eax
subl $0x30f, %eax            # imm = 0x30F
je 0xa8ad3
jmp 0xa8a48
movl -0x18(%rbp), %eax
subl $0x310, %eax            # imm = 0x310
je 0xa8ab7
jmp 0xa8ae1
movq -0x10(%rbp), %rdi
callq 0xa9880
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xa9fb0
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xaabe0
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xaae10
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xab000
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xab100
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xab200
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xabbe0
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rdi
callq 0xac5d0
movl %eax, -0x4(%rbp)
jmp 0xa8b25
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0xa8b1e
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movl -0x14(%rbp), %edx
sarl $0x8, %edx
movl -0x14(%rbp), %ecx
andl $0xf, %ecx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %r8d
leaq 0x22dc8(%rip), %rsi     # 0xcb8df
movb $0x0, %al
callq 0x9150
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop