// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_enav(bamboo::raw_t*, int, int)
static int decode_enav(raw_t *raw, int sat, int off)
{
    eph_t eph={0};
    unsigned char *p=raw->buff+6+off,buff[32],crc_buff[26]={0};
    int i,j,k,part1,page1,part2,page2,type;
    
    if (raw->len<44+off) {
        trace(2,"ubx rawsfrbx length error: sat=%d len=%d\n",sat,raw->len);
        return -1;
    }
    for (i=k=0;i<8;i++,p+=4) for (j=0;j<4;j++) {
        buff[k++]=p[3-j];
    }
    part1=getbitu(buff   ,0,1);
    page1=getbitu(buff   ,1,1);
    part2=getbitu(buff+16,0,1);
    page2=getbitu(buff+16,1,1);
    
    /* skip alert page */
    if (page1==1||page2==1) return 0;
    
    /* test even-odd parts */
    if (part1!=0||part2!=1) {
        trace(2,"ubx rawsfrbx gal page even/odd error: sat=%2d\n",sat);
        return -1;
    }
    /* test crc (4(pad) + 114 + 82 bits) */
    for (i=0,j=  4;i<15;i++,j+=8) setbitu(crc_buff,j,8,getbitu(buff   ,i*8,8));
    for (i=0,j=118;i<11;i++,j+=8) setbitu(crc_buff,j,8,getbitu(buff+16,i*8,8));
    if (rtk_crc24q(crc_buff,25)!=getbitu(buff+16,82,24)) {
        trace(2,"ubx rawsfrbx gal page crc error: sat=%2d\n",sat);
        return -1;
    }
    type=getbitu(buff,2,6); /* word type */
    
    /* skip word except for ephemeris, iono, utc parameters */
    if (type>6) return 0;
    
    /* clear word 0-6 flags */
    if (type==2) raw->subfrm[sat-1][112]=0;
    
    /* save page data (112 + 16 bits) to frame buffer */
    k=type*16;
    for (i=0,j=2;i<14;i++,j+=8) raw->subfrm[sat-1][k++]=getbitu(buff   ,j,8);
    for (i=0,j=2;i< 2;i++,j+=8) raw->subfrm[sat-1][k++]=getbitu(buff+16,j,8);
    
    /* test word 0-6 flags */
    raw->subfrm[sat-1][112]|=(1<<type);
    if (raw->subfrm[sat-1][112]!=0x7F) return 0;
    
    if (strstr(raw->opt,"-GALFNAV")) {
        return 0;
    }
    /* decode galileo inav ephemeris */
    if (!decode_gal_inav(raw->subfrm[sat-1],&eph)) {
        return 0;
    }
    /* test svid consistency */
    if (eph.sat!=sat) {
        trace(2,"ubx rawsfrbx gal svid error: sat=%2d %2d\n",sat,eph.sat);
        return -1;
    }
    if (!strstr(raw->opt,"-EPHALL")) {
        if (eph.iode==raw->nav.eph[sat-1].iode&& /* unchanged */
            timediff(eph.toe,raw->nav.eph[sat-1].toe)==0.0&&
            timediff(eph.toc,raw->nav.eph[sat-1].toc)==0.0) return 0;
    }
    eph.sat=sat;
    raw->nav.eph[sat-1]=eph;
    raw->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r12
leaq -0x1c0(%rbp), %rdi
xorl %r14d, %r14d
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
xorpd %xmm0, %xmm0
movupd %xmm0, -0x96(%rbp)
movapd %xmm0, -0xa0(%rbp)
movl 0x81a78(%r12), %ecx
leal 0x2c(%rbx), %eax
cmpl %eax, %ecx
jge 0x5804a
leaq 0x16e57(%rip), %rsi     # 0x6ee8f
pushq $0x2
popq %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x455bc
jmp 0x581f3
movl %ebx, %eax
addq %r12, %rax
addq $0x81a99, %rax          # imm = 0x81A99
leaq -0x60(%rbp), %rcx
xorl %edx, %edx
cmpl $0x8, %r14d
je 0x5808b
movslq %edx, %rdx
movq %rcx, %rdi
xorl %esi, %esi
cmpq $-0x4, %rsi
je 0x5807f
movb (%rax,%rsi), %r8b
movb %r8b, (%rdi,%rdx)
decq %rsi
incq %rdi
jmp 0x58069
incl %r14d
addq $0x4, %rax
subq %rsi, %rdx
jmp 0x5805b
movq %r15, -0x38(%rbp)
movq %r12, -0x30(%rbp)
leaq -0x60(%rbp), %r14
pushq $0x1
popq %r12
movq %r14, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x459f7
movl %eax, %ebx
movq %r14, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0x459f7
movl %eax, %r13d
leaq -0x50(%rbp), %r15
movq %r15, %rdi
xorl %esi, %esi
movl %r12d, %edx
callq 0x459f7
movl %eax, %r14d
movq %r15, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0x459f7
cmpl $0x1, %r13d
je 0x582c7
cmpl $0x1, %eax
movl $0x0, %r13d
je 0x581f7
testl %ebx, %ebx
jne 0x58139
cmpl $0x1, %r14d
jne 0x58139
pushq $0x4
popq %rbx
leaq -0x60(%rbp), %r15
pushq $0x8
popq %r14
leaq -0xa0(%rbp), %r13
cmpl $0x7c, %ebx
je 0x58145
leal -0x4(%rbx), %esi
movq %r15, %rdi
movl %r14d, %edx
callq 0x459f7
movq %r13, %rdi
movl %ebx, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0x45a69
addl $0x8, %ebx
jmp 0x58112
leaq 0x16ddc(%rip), %rsi     # 0x6ef1c
jmp 0x581e5
xorl %ebx, %ebx
pushq $0x8
popq %r14
leaq -0xa0(%rbp), %r15
cmpl $0x58, %ebx
je 0x5817e
leal 0x76(%rbx), %r13d
leaq -0x50(%rbp), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x459f7
movq %r15, %rdi
movl %r13d, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0x45a69
addl $0x8, %ebx
jmp 0x58152
leaq -0xa0(%rbp), %rdi
pushq $0x19
popq %rsi
callq 0x45b4d
movl %eax, %ebx
pushq $0x52
popq %rsi
pushq $0x18
popq %rdx
leaq -0x50(%rbp), %rdi
callq 0x459f7
cmpl %eax, %ebx
jne 0x581de
leaq -0x60(%rbp), %rdi
pushq $0x2
popq %rbx
pushq $0x6
popq %rdx
movl %ebx, %esi
callq 0x459f7
xorl %r13d, %r13d
cmpl $0x6, %eax
movq -0x38(%rbp), %rcx
jg 0x581f7
decl %ecx
movslq %ecx, %rdx
cmpl $0x2, %eax
jne 0x5820c
imulq $0x17c, %rdx, %rsi      # imm = 0x17C
movq -0x30(%rbp), %rcx
movb $0x0, 0x70fe0(%rcx,%rsi)
jmp 0x58210
leaq 0x16d66(%rip), %rsi     # 0x6ef4b
pushq $0x2
popq %rdi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x455bc
pushq $-0x1
popq %r13
movl %r13d, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rcx
movl %eax, -0x3c(%rbp)
shll $0x4, %eax
leaq 0x70f70(%rcx), %rsi
movq %rsi, -0x78(%rbp)
cltq
movq %rdx, -0x68(%rbp)
imulq $0x17c, %rdx, %rdx      # imm = 0x17C
movq %rdx, -0x70(%rbp)
addq %rdx, %rax
leaq (%rcx,%rax), %r15
addq $0x70f70, %r15          # imm = 0x70F70
leaq -0x60(%rbp), %r14
pushq $0x8
popq %r13
cmpl $0x72, %ebx
je 0x58265
movq %r14, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x459f7
movb %al, (%r15)
addl $0x8, %ebx
incq %r15
jmp 0x58248
pushq $0x2
popq %rbx
pushq $0x8
popq %r14
movq -0x30(%rbp), %r13
cmpl $0x12, %ebx
je 0x5828e
leaq -0x50(%rbp), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x459f7
movb %al, (%r15)
addl $0x8, %ebx
incq %r15
jmp 0x58270
movl -0x3c(%rbp), %ecx
shll %cl, %r12d
movq -0x78(%rbp), %r14
movq -0x70(%rbp), %r15
orb 0x70(%r14,%r15), %r12b
movb %r12b, 0x70(%r14,%r15)
cmpb $0x7f, %r12b
jne 0x582c7
leaq 0x82a90(%r13), %rbx
leaq 0xa4f9(%rip), %rsi      # 0x627b3
movq %rbx, %rdi
callq 0x8170
testq %rax, %rax
je 0x582cf
xorl %r13d, %r13d
jmp 0x581f7
addq %r15, %r14
leaq -0x1c0(%rbp), %rsi
movq %r14, %rdi
callq 0x2da38
testl %eax, %eax
movl $0x0, %r13d
je 0x581f7
movl -0x1c0(%rbp), %ecx
movq -0x38(%rbp), %r14
cmpl %r14d, %ecx
jne 0x583d6
leaq 0xa3be(%rip), %rsi      # 0x626c7
movq %rbx, %rdi
callq 0x8170
testq %rax, %rax
movq -0x68(%rbp), %r15
jne 0x583a2
movl -0x1bc(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x1d80(%rax), %rax
imulq $0x120, %r15, %rbx      # imm = 0x120
cmpl 0x4(%rax,%rbx), %ecx
jne 0x583a2
addq %rbx, %rax
movq -0x1a0(%rbp), %rdi
movsd -0x198(%rbp), %xmm0
movq 0x20(%rax), %rsi
movsd 0x28(%rax), %xmm1
callq 0x47322
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x583a2
jp 0x583a2
movq -0x190(%rbp), %rdi
movsd -0x188(%rbp), %xmm0
movq -0x30(%rbp), %rax
movq 0x1d80(%rax), %rax
movq 0x30(%rax,%rbx), %rsi
movsd 0x38(%rax,%rbx), %xmm1
callq 0x47322
ucomisd 0x855e(%rip), %xmm0     # 0x608f8
jne 0x583a2
jnp 0x581f7
leaq -0x1c0(%rbp), %rsi
movl %r14d, (%rsi)
imulq $0x120, %r15, %rdi      # imm = 0x120
movq -0x30(%rbp), %rbx
addq 0x1d80(%rbx), %rdi
movl $0x120, %edx            # imm = 0x120
callq 0x84f0
movl %r14d, 0x70e40(%rbx)
pushq $0x2
jmp 0x581f5
leaq 0x16b98(%rip), %rsi     # 0x6ef75
pushq $0x2
popq %rdi
movl %r14d, %edx
jmp 0x5803e