// File: /workspace/github_cpp_makefile_star2_O3/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, -0x76(%rbp)
movapd %xmm0, -0x80(%rbp)
movl 0x81a78(%r12), %ecx
leal 0x2c(%rbx), %eax
cmpl %eax, %ecx
jge 0x6164f
leaq 0x17880(%rip), %rsi     # 0x78ebb
movl $0x2, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4d55d
jmp 0x6180e
movl %ebx, %eax
addq %r12, %rax
addq $0x81a99, %rax          # imm = 0x81A99
xorl %ecx, %ecx
movslq %ecx, %rcx
xorl %edx, %edx
movb (%rax,%rdx), %sil
movb %sil, -0xa0(%rbp,%rcx)
incq %rcx
decq %rdx
cmpq $-0x4, %rdx
jne 0x61661
incl %r14d
addq $0x4, %rax
cmpl $0x8, %r14d
jne 0x6165c
movq %r12, -0x30(%rbp)
movq %r15, -0x38(%rbp)
leaq -0xa0(%rbp), %rbx
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, %r14d
leaq -0x90(%rbp), %r15
movq %r15, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, %ebx
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4d9d6
cmpl $0x1, %r14d
je 0x61814
cmpl $0x1, %eax
je 0x61814
testl %r13d, %r13d
jne 0x617ee
cmpl $0x1, %ebx
jne 0x617ee
movl $0x4, %r12d
leaq -0xa0(%rbp), %r13
leaq -0x80(%rbp), %rbx
leal -0x4(%r12), %esi
movq %r13, %rdi
movl $0x8, %edx
callq 0x4d9d6
movq %rbx, %rdi
movl %r12d, %esi
movl $0x8, %edx
movl %eax, %ecx
callq 0x4da98
addl $0x8, %r12d
cmpl $0x7c, %r12d
jne 0x6171f
xorl %r12d, %r12d
leaq -0x80(%rbp), %rbx
leal 0x76(%r12), %r14d
movq %r15, %rdi
movl %r12d, %esi
movl $0x8, %edx
callq 0x4d9d6
movq %rbx, %rdi
movl %r14d, %esi
movl $0x8, %edx
movl %eax, %ecx
callq 0x4da98
addl $0x8, %r12d
cmpl $0x58, %r12d
jne 0x61754
leaq -0x80(%rbp), %rdi
movl $0x19, %esi
callq 0x4db73
movl %eax, %ebx
movq %r15, %rdi
movl $0x52, %esi
movl $0x18, %edx
callq 0x4d9d6
cmpl %eax, %ebx
jne 0x617f7
leaq -0xa0(%rbp), %rdi
movl $0x2, %esi
movl $0x6, %edx
callq 0x4d9d6
xorl %r12d, %r12d
cmpl $0x6, %eax
jg 0x61814
movl %eax, %esi
cmpl $0x2, %eax
jne 0x61829
movq -0x38(%rbp), %rax
decl %eax
movslq %eax, %rdx
imulq $0x17c, %rdx, %rax      # imm = 0x17C
movq -0x30(%rbp), %rcx
movb $0x0, 0x70fe0(%rcx,%rax)
jmp 0x61836
leaq 0x17753(%rip), %rsi     # 0x78f48
jmp 0x617fe
leaq 0x17779(%rip), %rsi     # 0x78f77
movl $0x2, %edi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rax
decl %eax
movslq %eax, %rdx
movq -0x30(%rbp), %rcx
movl %esi, -0x3c(%rbp)
movl %esi, %eax
shll $0x4, %eax
leaq 0x70f70(%rcx), %rsi
movq %rsi, -0x58(%rbp)
cltq
movq %rdx, -0x48(%rbp)
imulq $0x17c, %rdx, %rdx      # imm = 0x17C
movq %rdx, -0x50(%rbp)
addq %rdx, %rax
leaq (%rcx,%rax), %r14
addq $0x70f70, %r14          # imm = 0x70F70
movl $0x2, %ebx
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
movl %ebx, %esi
movl $0x8, %edx
callq 0x4d9d6
movb %al, (%r14)
addl $0x8, %ebx
incq %r14
cmpl $0x72, %ebx
jne 0x61874
movl $0x2, %r13d
movb $0x1, %bl
xorl %r12d, %r12d
movq %r15, %rdi
movl %r13d, %esi
movl $0x8, %edx
callq 0x4d9d6
movb %al, (%r14)
addl $0x8, %r13d
incq %r14
testb $0x1, %bl
movl $0x0, %ebx
jne 0x6189c
movl $0x1, %eax
movl -0x3c(%rbp), %ecx
shll %cl, %eax
movq -0x58(%rbp), %rbx
movq -0x50(%rbp), %r14
orb 0x70(%rbx,%r14), %al
movb %al, 0x70(%rbx,%r14)
cmpb $0x7f, %al
jne 0x61814
movq -0x30(%rbp), %rax
leaq 0x82a90(%rax), %r15
leaq 0xaebd(%rip), %rsi      # 0x6c7b3
movq %r15, %rdi
callq 0x8160
testq %rax, %rax
jne 0x61814
addq %r14, %rbx
leaq -0x1c0(%rbp), %rsi
movq %rbx, %rdi
callq 0x333d0
testl %eax, %eax
je 0x61814
movl -0x1c0(%rbp), %ecx
movq -0x38(%rbp), %rdx
cmpl %edx, %ecx
jne 0x61a12
leaq 0xad8d(%rip), %rsi      # 0x6c6c7
movq %r15, %rdi
callq 0x8160
movq -0x48(%rbp), %rcx
leaq (%rcx,%rcx,8), %r15
testq %rax, %rax
jne 0x619d7
movl -0x1bc(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x1d80(%rax), %rax
movq %r15, %rbx
shlq $0x5, %rbx
cmpl 0x4(%rax,%rbx), %ecx
jne 0x619d7
addq %rbx, %rax
movq -0x1a0(%rbp), %rdi
movsd -0x198(%rbp), %xmm0
movq 0x20(%rax), %rsi
movsd 0x28(%rax), %xmm1
callq 0x4f51b
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x619d7
jp 0x619d7
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 0x4f51b
ucomisd 0x8f39(%rip), %xmm0     # 0x6a908
jne 0x619d7
jnp 0x61814
leaq -0x1c0(%rbp), %rsi
movq -0x38(%rbp), %rbx
movl %ebx, (%rsi)
shlq $0x5, %r15
movq -0x30(%rbp), %r14
addq 0x1d80(%r14), %r15
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
callq 0x84f0
movl %ebx, 0x70e40(%r14)
movl $0x2, %r12d
jmp 0x61814
leaq 0x17588(%rip), %rsi     # 0x78fa1
movl $0x2, %edi
jmp 0x61643