// File: DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_nav(bamboo::raw_t*, int, int)
static int decode_nav(raw_t *raw, int sat, int off)
{
    unsigned int words[10];
    int i,id;
    unsigned char *p=raw->buff+6+off;
    
    if (raw->len<48+off) {
        trace(2,"ubx rawsfrbx length error: sat=%d len=%d\n",sat,raw->len);
        return -1;
    }
    if ((U4(p)>>24)==PREAMB_CNAV) {
        trace(3,"ubx rawsfrbx cnav not supported sat=%d prn=%d\n",sat,
              (U4(p)>>18)&0x3F);
        return 0;
    }
    for (i=0;i<10;i++,p+=4) words[i]=U4(p)>>6; /* 24 bits without parity */
    
    id=(words[1]>>2)&7;
    if (id<1||5<id) {
        trace(2,"ubx rawsfrbx subfrm id error: sat=%2d id=%d len=%d\n",sat,id,
              raw->len);
        return -1;
    }
    for (i=0;i<10;i++) {
        setbitu(raw->subfrm[sat-1]+(id-1)*30,i*24,24,words[i]);
    }
    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;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x6, %rax
movslq -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %eax
movl -0x18(%rbp), %ecx
addl $0x30, %ecx
cmpl %ecx, %eax
jge 0xad32b
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %ecx
movl $0x2, %edi
leaq 0x1e91b(%rip), %rsi     # 0xcbc33
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xad4a2
movq -0x50(%rbp), %rdi
callq 0xac7b0
shrl $0x18, %eax
cmpl $0x8b, %eax
jne 0xad377
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rdi
callq 0xac7b0
movl -0x54(%rbp), %edx
movl %eax, %ecx
shrl $0x12, %ecx
andl $0x3f, %ecx
movl $0x3, %edi
leaq 0x1e8f9(%rip), %rsi     # 0xcbc5d
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0xad4a2
movl $0x0, -0x44(%rbp)
cmpl $0xa, -0x44(%rbp)
jge 0xad3b1
movq -0x50(%rbp), %rdi
callq 0xac7b0
movl %eax, %ecx
shrl $0x6, %ecx
movslq -0x44(%rbp), %rax
movl %ecx, -0x40(%rbp,%rax,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
jmp 0xad37e
movl -0x3c(%rbp), %eax
shrl $0x2, %eax
andl $0x7, %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
jl 0xad3cd
movl $0x5, %eax
cmpl -0x48(%rbp), %eax
jge 0xad3fd
movl -0x14(%rbp), %edx
movl -0x48(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %r8d
movl $0x2, %edi
leaq 0x1e8a2(%rip), %rsi     # 0xcbc8c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xad4a2
movl $0x0, -0x44(%rbp)
cmpl $0xa, -0x44(%rbp)
jge 0xad456
movq -0x10(%rbp), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
movl -0x14(%rbp), %eax
subl $0x1, %eax
cltq
imulq $0x17c, %rax, %rax      # imm = 0x17C
addq %rax, %rdi
movl -0x48(%rbp), %eax
subl $0x1, %eax
imull $0x1e, %eax, %eax
cltq
addq %rax, %rdi
imull $0x18, -0x44(%rbp), %esi
movslq -0x44(%rbp), %rax
movl -0x40(%rbp,%rax,4), %ecx
movl $0x18, %edx
callq 0x8c0d0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xad404
cmpl $0x3, -0x48(%rbp)
jne 0xad46d
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xacd20
movl %eax, -0x4(%rbp)
jmp 0xad4a2
cmpl $0x4, -0x48(%rbp)
jne 0xad484
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xacf00
movl %eax, -0x4(%rbp)
jmp 0xad4a2
cmpl $0x5, -0x48(%rbp)
jne 0xad49b
movl -0x14(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xad0a0
movl %eax, -0x4(%rbp)
jmp 0xad4a2
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)