// File: DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_rxmsfrb(bamboo::raw_t*)
static int decode_rxmsfrb(raw_t *raw)
{
    unsigned int words[10];
    int i,prn,sat,sys,id;
    unsigned char *p=raw->buff+6;
    
    trace(4,"decode_rxmsfrb: len=%d\n",raw->len);
    
    if (raw->outtype) {
        sprintf(raw->msgtype,"UBX RXM-SFRB  (%4d): prn=%2d",raw->len,U1(p+1));
    }
    if (raw->len<42) {
        trace(2,"ubx rxmsfrb length error: len=%d\n",raw->len);
        return -1;
    }
    prn=U1(p+1);
    if (!(sat=satno(MINPRNSBS<=prn?SYS_SBS:SYS_GPS,prn))) {
        trace(2,"ubx rxmsfrb satellite number error: prn=%d\n",prn);
        return -1;
    }
    sys=satsys(sat,&prn);
    
    if (sys==SYS_GPS) {
        id=save_subfrm(sat,raw);
        if (id==3) return decode_ephem(sat,raw);
        if (id==4) return decode_alm1 (sat,raw);
        if (id==5) return decode_alm2 (sat,raw);
        return 0;
    }
    else if (sys==SYS_SBS) {
        for (i=0,p+=2;i<10;i++,p+=4) words[i]=U4(p);
        return sbsdecodemsg(raw->time,prn,words,&raw->sbsmsg)?3:0;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x6, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x4, %edi
leaq 0x20ef2(%rip), %rsi     # 0xcbb06
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0xaac53
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movq -0x60(%rbp), %rax
movzbl 0x1(%rax), %ecx
leaq 0x20ed2(%rip), %rsi     # 0xcbb1e
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rax
cmpl $0x2a, 0x81a78(%rax)
jge 0xaac89
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x2, %edi
leaq 0x20ec5(%rip), %rsi     # 0xcbb3b
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaadf8
movq -0x60(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %edx
movl $0x78, %ecx
movl $0x1, %edi
movl $0x2, %eax
cmpl %edx, %ecx
cmovlel %eax, %edi
movl -0x48(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x4c(%rbp)
cmpl $0x0, %eax
jne 0xaacdd
movl -0x48(%rbp), %edx
movl $0x2, %edi
leaq 0x20e93(%rip), %rsi     # 0xcbb5d
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaadf8
movl -0x4c(%rbp), %edi
leaq -0x48(%rbp), %rsi
callq 0x8b3b0
movl %eax, -0x50(%rbp)
cmpl $0x1, -0x50(%rbp)
jne 0xaad5b
movl -0x4c(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xacbc0
movl %eax, -0x54(%rbp)
cmpl $0x3, -0x54(%rbp)
jne 0xaad1b
movl -0x4c(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xacd20
movl %eax, -0x4(%rbp)
jmp 0xaadf8
cmpl $0x4, -0x54(%rbp)
jne 0xaad35
movl -0x4c(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xacf00
movl %eax, -0x4(%rbp)
jmp 0xaadf8
cmpl $0x5, -0x54(%rbp)
jne 0xaad4f
movl -0x4c(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xad0a0
movl %eax, -0x4(%rbp)
jmp 0xaadf8
movl $0x0, -0x4(%rbp)
jmp 0xaadf8
cmpl $0x2, -0x50(%rbp)
jne 0xaadef
movl $0x0, -0x44(%rbp)
movq -0x60(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x60(%rbp)
cmpl $0xa, -0x44(%rbp)
jge 0xaada8
movq -0x60(%rbp), %rdi
callq 0xac7b0
movl %eax, %ecx
movslq -0x44(%rbp), %rax
movl %ecx, -0x40(%rbp,%rax,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x60(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x60(%rbp)
jmp 0xaad78
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x70(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movl -0x48(%rbp), %esi
leaq -0x40(%rbp), %rdx
movq -0x10(%rbp), %rcx
addq $0x70e44, %rcx          # imm = 0x70E44
movq -0x70(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
callq 0xa9640
movl %eax, %edx
xorl %eax, %eax
movl $0x3, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xaadf8
jmp 0xaadf1
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)