// File: /workspace/github_cpp_makefile_star2_O1/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 $0x188, %rsp            # imm = 0x188
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r12
leaq -0x1b0(%rbp), %rdi
xorl %r14d, %r14d
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x8390
xorpd %xmm0, %xmm0
movupd %xmm0, -0x66(%rbp)
movapd %xmm0, -0x70(%rbp)
movl 0x81a78(%r12), %ecx
leal 0x2c(%rbx), %eax
cmpl %eax, %ecx
jge 0x62280
leaq 0x16c77(%rip), %rsi     # 0x78ee3
movl $0x2, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4ded0
jmp 0x6260f
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, -0x90(%rbp,%rcx)
incq %rcx
decq %rdx
cmpq $-0x4, %rdx
jne 0x62292
incl %r14d
addq $0x4, %rax
cmpl $0x8, %r14d
jne 0x6228d
movq %r12, -0x30(%rbp)
movq %r15, -0x38(%rbp)
leaq -0x90(%rbp), %rbx
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4e341
movl %eax, %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4e341
movl %eax, %r14d
leaq -0x80(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4e341
movl %eax, %ebx
movq %r12, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x4e341
cmpl $0x1, %r14d
je 0x62615
cmpl $0x1, %eax
je 0x62615
testl %r13d, %r13d
jne 0x625ef
cmpl $0x1, %ebx
jne 0x625ef
movl $0x4, %r15d
leaq -0x90(%rbp), %r13
leaq -0x70(%rbp), %rbx
leal -0x4(%r15), %esi
movq %r13, %rdi
movl $0x8, %edx
callq 0x4e341
movq %rbx, %rdi
movl %r15d, %esi
movl $0x8, %edx
movl %eax, %ecx
callq 0x4e403
addl $0x8, %r15d
cmpl $0x7c, %r15d
jne 0x6234d
xorl %r15d, %r15d
leaq -0x70(%rbp), %rbx
leal 0x76(%r15), %r14d
movq %r12, %rdi
movl %r15d, %esi
movl $0x8, %edx
callq 0x4e341
movq %rbx, %rdi
movl %r14d, %esi
movl $0x8, %edx
movl %eax, %ecx
callq 0x4e403
addl $0x8, %r15d
cmpl $0x58, %r15d
jne 0x62381
leaq -0x70(%rbp), %rdi
movl $0x19, %esi
callq 0x4e4e2
movl %eax, %ebx
movq %r12, %rdi
movl $0x52, %esi
movl $0x18, %edx
callq 0x4e341
cmpl %eax, %ebx
jne 0x625f8
leaq -0x90(%rbp), %rdi
movl $0x2, %esi
movl $0x6, %edx
callq 0x4e341
xorl %r15d, %r15d
cmpl $0x6, %eax
jg 0x62615
movl %eax, %edx
cmpl $0x2, %eax
jne 0x6241f
movq -0x38(%rbp), %rax
decl %eax
cltq
imulq $0x17c, %rax, %rax      # imm = 0x17C
movq -0x30(%rbp), %rcx
movb $0x0, 0x70fe0(%rcx,%rax)
movl %edx, -0x3c(%rbp)
shll $0x4, %edx
movslq %edx, %rax
movq -0x38(%rbp), %rcx
decl %ecx
movslq %ecx, %rdx
movq %rdx, -0x48(%rbp)
imulq $0x17c, %rdx, %rcx      # imm = 0x17C
movq %rcx, -0x50(%rbp)
addq %rcx, %rax
movq -0x30(%rbp), %rcx
leaq (%rcx,%rax), %r14
addq $0x70f70, %r14          # imm = 0x70F70
movl $0x2, %ebx
leaq -0x90(%rbp), %r13
movq %r13, %rdi
movl %ebx, %esi
movl $0x8, %edx
callq 0x4e341
movb %al, (%r14)
addl $0x8, %ebx
incq %r14
cmpl $0x72, %ebx
jne 0x6245e
movl $0x2, %ebx
movq %r12, %rdi
movl %ebx, %esi
movl $0x8, %edx
callq 0x4e341
movb %al, (%r14)
addl $0x8, %ebx
incq %r14
cmpl $0xa, %ebx
je 0x62480
movl $0x1, %eax
movl -0x3c(%rbp), %ecx
shll %cl, %eax
movq -0x30(%rbp), %rbx
movq -0x50(%rbp), %r14
orb 0x70fe0(%rbx,%r14), %al
movb %al, 0x70fe0(%rbx,%r14)
cmpb $0x7f, %al
jne 0x62615
leaq 0x82a90(%rbx), %r12
leaq 0xa2de(%rip), %rsi      # 0x6c7b3
movq %r12, %rdi
callq 0x8160
testq %rax, %rax
jne 0x62615
leaq (%rbx,%r14), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
leaq -0x1b0(%rbp), %rsi
callq 0x33a08
testl %eax, %eax
je 0x62615
movl -0x1b0(%rbp), %ecx
movq -0x38(%rbp), %rdx
cmpl %edx, %ecx
jne 0x6262a
leaq 0xa1a9(%rip), %rsi      # 0x6c6c7
movq %r12, %rdi
callq 0x8160
movq -0x48(%rbp), %rcx
leaq (%rcx,%rcx,8), %r12
testq %rax, %rax
jne 0x625b7
movl -0x1ac(%rbp), %ecx
movq -0x30(%rbp), %rax
movq 0x1d80(%rax), %rax
movq %r12, %rbx
shlq $0x5, %rbx
cmpl 0x4(%rax,%rbx), %ecx
jne 0x625b7
addq %rbx, %rax
movq -0x190(%rbp), %rdi
movsd -0x188(%rbp), %xmm0
movq 0x20(%rax), %rsi
movsd 0x28(%rax), %xmm1
callq 0x4fe97
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x625b7
jp 0x625b7
movq -0x180(%rbp), %rdi
movsd -0x178(%rbp), %xmm0
movq -0x30(%rbp), %rax
movq 0x1d80(%rax), %rax
movq 0x30(%rax,%rbx), %rsi
movsd 0x38(%rax,%rbx), %xmm1
callq 0x4fe97
ucomisd 0x8355(%rip), %xmm0     # 0x6a908
jne 0x625b7
jnp 0x62615
leaq -0x1b0(%rbp), %rsi
movq -0x38(%rbp), %rbx
movl %ebx, (%rsi)
shlq $0x5, %r12
movq -0x30(%rbp), %r14
addq 0x1d80(%r14), %r12
movl $0x120, %edx            # imm = 0x120
movq %r12, %rdi
callq 0x84f0
movl %ebx, 0x70e40(%r14)
movl $0x2, %r15d
jmp 0x62615
leaq 0x1697a(%rip), %rsi     # 0x78f70
jmp 0x625ff
leaq 0x169a0(%rip), %rsi     # 0x78f9f
movl $0x2, %edi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16998(%rip), %rsi     # 0x78fc9
movl $0x2, %edi
jmp 0x62274