// File: DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_trksfrbx(bamboo::raw_t*)
static int decode_trksfrbx(raw_t *raw)
{
    int prn,sat,sys;
    unsigned char *p=raw->buff+6;
    
    trace(4,"decode_trksfrbx: len=%d\n",raw->len);
    
    if (raw->outtype) {
        sprintf(raw->msgtype,"UBX TRK-SFRBX (%4d): sys=%d prn=%3d",raw->len,
                U1(p+1),U1(p+2));
    }
    if (!(sys=ubx_sys(U1(p+1)))) {
        trace(2,"ubx trksfrbx sys id error: sys=%d\n",U1(p+1));
        return -1;
    }
    prn=U1(p+2)+(sys==SYS_QZS?192:0);
    if (!(sat=satno(sys,prn))) {
        trace(2,"ubx trksfrbx sat number error: sys=%d prn=%d\n",sys,prn);
        return -1;
    }
    switch (sys) {
        case SYS_GPS: return decode_nav (raw,sat,13);
        case SYS_QZS: return decode_nav (raw,sat,13);
        case SYS_GAL: return decode_enav(raw,sat,13);
        case SYS_CMP: return decode_cnav(raw,sat,13);
        case SYS_GLO: return decode_gnav(raw,sat,13,U1(p+4));
        case SYS_SBS: return decode_snav(raw,sat,13);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x6, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x4, %edi
leaq 0x1f9a8(%rip), %rsi     # 0xcbfac
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0xac64c
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %ecx
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %r8d
leaq 0x1f980(%rip), %rsi     # 0xcbfc5
movb $0x0, %al
callq 0x9150
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %edi
callq 0xac810
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jne 0xac688
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %edx
movl $0x2, %edi
leaq 0x1f974(%rip), %rsi     # 0xcbfe9
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xac798
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %eax
movl -0x1c(%rbp), %esi
xorl %ecx, %ecx
movl $0xc0, %edx
cmpl $0x10, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x1c(%rbp), %edi
movl -0x14(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0xac6dd
movl -0x1c(%rbp), %edx
movl -0x14(%rbp), %ecx
movl $0x2, %edi
leaq 0x1f942(%rip), %rsi     # 0xcc00c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xac798
movl -0x1c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x1f, %eax
ja 0xac791
movq -0x30(%rbp), %rax
leaq 0x1ddd8(%rip), %rcx     # 0xca4d4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0xd, %edx
callq 0xad2c0
movl %eax, -0x4(%rbp)
jmp 0xac798
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0xd, %edx
callq 0xad2c0
movl %eax, -0x4(%rbp)
jmp 0xac798
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0xd, %edx
callq 0xad4b0
movl %eax, -0x4(%rbp)
jmp 0xac798
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0xd, %edx
callq 0xadc50
movl %eax, -0x4(%rbp)
jmp 0xac798
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movq -0x28(%rbp), %rax
movzbl 0x4(%rax), %ecx
movl $0xd, %edx
callq 0xae0e0
movl %eax, -0x4(%rbp)
jmp 0xac798
movq -0x10(%rbp), %rdi
movl -0x18(%rbp), %esi
movl $0xd, %edx
callq 0xae4c0
movl %eax, -0x4(%rbp)
jmp 0xac798
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)