// File: /workspace/github_cpp_makefile_star2_O3/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 0x1f65e(%rip), %rsi     # 0x7562d
xorl %r12d, %r12d
movl $0x3, %edi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movl 0x81a78(%rbx), %ecx
cmpl $0x8, %ecx
jl 0x5600b
leal -0x3(%rcx), %eax
addq $-0x4, %rax
xorl %edx, %edx
xorl %r12d, %r12d
xorb 0x81a94(%rbx,%rdx), %r12b
incq %rdx
cmpq %rdx, %rax
jne 0x55ffb
movzbl 0x81a8d(%rbx,%r15), %r8d
movb 0x81a8e(%rbx,%r15), %al
cmpb %r8b, %r12b
jne 0x56090
cmpb $0xd, %al
jne 0x56090
movb $0xd, %al
cmpb $0xa, 0x81a8f(%rbx,%r15)
jne 0x56090
cmpl $0x0, 0x81a8c(%rbx)
je 0x56053
leaq 0x70e70(%rbx), %rdi
leaq 0x1f63b(%rip), %rsi     # 0x75684
movl %r14d, %edx
xorl %eax, %eax
callq 0x8120
xorl %r15d, %r15d
cmpl $0xdb, %r14d
jle 0x560d0
addl $0xffffff24, %r14d      # imm = 0xFFFFFF24
cmpl $0x9, %r14d
ja 0x560c0
leaq 0x1f4b1(%rip), %rax     # 0x75524
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 0x5766b
movzbl %r12b, %ecx
movzbl %al, %r9d
movzbl 0x81a8f(%rbx,%r15), %eax
movl %eax, (%rsp)
leaq 0x1f5a0(%rip), %rsi     # 0x7564b
movl $0x2, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4d55d
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 0x56161
cmpl $0x83, %r14d
je 0x56175
cmpl $0x84, %r14d
jne 0x560c0
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x57aa4
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x56b45
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x573b6
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x56fc2
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x56717
movq %rbx, %rdi
callq 0x56647
jmp 0x560c0
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x575d3
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x57a26