// File: DoubleString[P]RtConverter/src/Rtklib/skytraq.cpp
// Function: bamboo::decode_stq(bamboo::raw_t*)
static int decode_stq(raw_t *raw)
{
    int type=U1(raw->buff+4);
    unsigned char cs,*p=raw->buff+raw->len-3;
    
    trace(3,"decode_stq: type=%02x len=%d\n",type,raw->len);
    
    /* checksum */
    cs=checksum(raw->buff,raw->len);
    
    if (cs!=*p||*(p+1)!=0x0D||*(p+2)!=0x0A) {
        trace(2,"stq checksum error: type=%02X cs=%02X tail=%02X%02X%02X\n",
              type,cs,*p,*(p+1),*(p+2));
        return -1;
    }
    if (raw->outtype) {
        sprintf(raw->msgtype,"SKYTRAQ 0x%02X  (%4d):",type,raw->len);
    }
    switch (type) {
        case ID_STQTIME : return decode_stqtime(raw);
        case ID_STQRAW  : return decode_stqraw (raw);
        case ID_STQRAWX : return decode_stqrawx(raw);
        case ID_STQGPS  : return decode_stqgps (raw);
        case ID_STQGLO  : return decode_stqglo (raw);
        case ID_STQGLOE : return decode_stqgloe(raw);
        case ID_STQBDSD1: return decode_stqbds (raw);
        case ID_STQBDSD2: return decode_stqbds (raw);
        case ID_STQACK  : return decode_stqack (raw);
        case ID_STQNACK : return decode_stqnack(raw);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x81a94(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
movq -0x10(%rbp), %rcx
movslq 0x81a78(%rcx), %rcx
addq %rcx, %rax
addq $-0x3, %rax
movq %rax, -0x20(%rbp)
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %ecx
movl $0x3, %edi
leaq 0x2e4b2(%rip), %rsi     # 0xc83d5
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rdi
addq $0x81a90, %rdi          # imm = 0x81A90
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %esi
callq 0x9aa90
movb %al, -0x15(%rbp)
movzbl -0x15(%rbp), %eax
movq -0x20(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x99f70
movq -0x20(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0xd, %eax
jne 0x99f70
movq -0x20(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0xa, %eax
je 0x99fb2
movl -0x14(%rbp), %edx
movzbl -0x15(%rbp), %ecx
movq -0x20(%rbp), %rax
movzbl (%rax), %r8d
movq -0x20(%rbp), %rax
movzbl 0x1(%rax), %r9d
movq -0x20(%rbp), %rax
movzbl 0x2(%rax), %eax
movl $0x2, %edi
leaq 0x2e457(%rip), %rsi     # 0xc83f3
movl %eax, (%rsp)
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9a103
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0x99fe5
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %ecx
leaq 0x2e44e(%rip), %rsi     # 0xc842c
movb $0x0, %al
callq 0x9150
movl -0x14(%rbp), %eax
movl %eax, -0x24(%rbp)
subl $0x5c, %eax
je 0x9a0b6
jmp 0x99ff6
movl -0x24(%rbp), %eax
subl $0x83, %eax
je 0x9a0e0
jmp 0x9a006
movl -0x24(%rbp), %eax
subl $0x84, %eax
je 0x9a0ee
jmp 0x9a016
movl -0x24(%rbp), %eax
subl $0xdc, %eax
je 0x9a06d
jmp 0x9a022
movl -0x24(%rbp), %eax
subl $0xdd, %eax
je 0x9a07e
jmp 0x9a02e
movl -0x24(%rbp), %eax
subl $0xe0, %eax
je 0x9a09a
jmp 0x9a03a
movl -0x24(%rbp), %eax
subl $0xe1, %eax
je 0x9a0a8
jmp 0x9a046
movl -0x24(%rbp), %eax
subl $0xe2, %eax
je 0x9a0c4
jmp 0x9a052
movl -0x24(%rbp), %eax
subl $0xe3, %eax
je 0x9a0d2
jmp 0x9a05e
movl -0x24(%rbp), %eax
subl $0xe5, %eax
je 0x9a08c
jmp 0x9a0fc
movq -0x10(%rbp), %rdi
callq 0x9aae0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9abe0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9b240
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9baf0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9bc80
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9bff0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9c0e0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9c0e0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9c730
movl %eax, -0x4(%rbp)
jmp 0x9a103
movq -0x10(%rbp), %rdi
callq 0x9c7f0
movl %eax, -0x4(%rbp)
jmp 0x9a103
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)