// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movzbl 0x81a94(%rdi), %r14d
movl 0x81a78(%rdi), %eax
movslq %eax, %r15
leaq 0x1ec09(%rip), %rsi     # 0x75675
xorl %r12d, %r12d
movl $0x3, %edi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4ded0
movl 0x81a78(%rbx), %ecx
cmpl $0x8, %ecx
jl 0x56aa8
leal -0x3(%rcx), %eax
addq $-0x4, %rax
xorl %edx, %edx
xorl %r12d, %r12d
xorb 0x81a94(%rbx,%rdx), %r12b
incq %rdx
cmpq %rdx, %rax
jne 0x56a98
movzbl 0x81a8d(%rbx,%r15), %r8d
cmpb %r8b, %r12b
jne 0x56b2a
cmpb $0xd, 0x81a8e(%rbx,%r15)
jne 0x56b2a
cmpb $0xa, 0x81a8f(%rbx,%r15)
jne 0x56b2a
cmpl $0x0, 0x81a8c(%rbx)
je 0x56aed
leaq 0x70e70(%rbx), %rdi
leaq 0x1ebe9(%rip), %rsi     # 0x756cc
movl %r14d, %edx
xorl %eax, %eax
callq 0x8120
xorl %r15d, %r15d
cmpl $0xdb, %r14d
jle 0x56b6f
addl $0xffffff24, %r14d      # imm = 0xFFFFFF24
cmpl $0x9, %r14d
ja 0x56b5f
leaq 0x1ea5f(%rip), %rax     # 0x7556c
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5824d
movzbl %r12b, %ecx
movzbl 0x81a8e(%rbx,%r15), %r9d
movzbl 0x81a8f(%rbx,%r15), %eax
movl %eax, (%rsp)
leaq 0x1eb49(%rip), %rsi     # 0x75693
movl $0x2, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x5c, %r14d
je 0x56c00
cmpl $0x83, %r14d
je 0x56c14
cmpl $0x84, %r14d
jne 0x56b5f
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x58686
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5767a
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x57f92
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x57b4c
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5724c
movq %rbx, %rdi
callq 0x57175
jmp 0x56b5f
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x581b5
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x58608