// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_gnav(bamboo::raw_t*, int, int, int)
static int decode_gnav(raw_t *raw, int sat, int off, int frq)
{
    geph_t geph={0};
    int i,j,k,m,prn;
    unsigned char *p=raw->buff+6+off,buff[64],*fid;
    
    satsys(sat,&prn);
    
    if (raw->len<24+off) {
        trace(2,"ubx rawsfrbx gnav length error: len=%d\n",raw->len);
        return -1;
    }
    for (i=k=0;i<4;i++,p+=4) for (j=0;j<4;j++) {
        buff[k++]=p[3-j];
    }
    /* test hamming of glonass string */
    if (!test_glostr(buff)) {
        trace(2,"ubx rawsfrbx glo string hamming error: sat=%2d\n",sat);
        return -1;
    }
    m=getbitu(buff,1,4);
    if (m<1||15<m) {
        trace(2,"ubx rawsfrbx glo string no error: sat=%2d\n",sat);
        return -1;
    }
    /* flush frame buffer if frame-id changed */
    fid=raw->subfrm[sat-1]+150;
    if (fid[0]!=buff[12]||fid[1]!=buff[13]) {
        for (i=0;i<4;i++) memset(raw->subfrm[sat-1]+i*10,0,10);
        memcpy(fid,buff+12,2); /* save frame-id */
    }
    memcpy(raw->subfrm[sat-1]+(m-1)*10,buff,10);
    
    if (m!=4) return 0;
    
    /* decode glonass ephemeris strings */
    geph.tof=raw->time;
    if (!decode_glostr(raw->subfrm[sat-1],&geph)||geph.sat!=sat) return 0;
    geph.frq=frq-7;
    
    if (!strstr(raw->opt,"-EPHALL")) {
        if (geph.iode==raw->nav.geph[prn-1].iode) return 0; /* unchanged */
    }
    raw->nav.geph[prn-1]=geph;
    raw->ephsat=sat;
    return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %ecx, %r15d
movl %edx, %r12d
movl %esi, %ebx
movq %rdi, %r14
leaq -0x108(%rbp), %rdi
xorl %r13d, %r13d
movl $0x98, %edx
xorl %esi, %esi
callq 0x8390
leaq -0x2c(%rbp), %rsi
movl %ebx, %edi
callq 0x4dc2a
movl 0x81a78(%r14), %edx
leal 0x18(%r12), %eax
cmpl %eax, %edx
jge 0x62973
leaq 0x166d7(%rip), %rsi     # 0x79043
movl $0x2, %edi
jmp 0x629e7
movl %r12d, %eax
addq %r14, %rax
addq $0x81a99, %rax          # imm = 0x81A99
xorl %ecx, %ecx
movslq %ecx, %rcx
xorl %edx, %edx
movb (%rax,%rdx), %sil
movb %sil, -0x70(%rbp,%rcx)
incq %rcx
decq %rdx
cmpq $-0x4, %rdx
jne 0x62986
incl %r13d
addq $0x4, %rax
cmpl $0x4, %r13d
jne 0x62981
leaq -0x70(%rbp), %rdi
callq 0x355d9
testl %eax, %eax
je 0x629d9
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
movl $0x4, %edx
callq 0x4e341
leal -0x10(%rax), %ecx
cmpl $-0x10, %ecx
ja 0x62a09
leaq 0x166c4(%rip), %rsi     # 0x7909b
jmp 0x629e0
leaq 0x1668b(%rip), %rsi     # 0x7906b
movl $0x2, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal -0x1(%rbx), %ecx
movslq %ecx, %rcx
imulq $0x17c, %rcx, %rcx      # imm = 0x17C
leaq (%r14,%rcx), %rdi
addq $0x70f70, %rdi          # imm = 0x70F70
movb 0x96(%rdi), %cl
cmpb -0x64(%rbp), %cl
jne 0x62a37
movb 0x97(%rdi), %cl
cmpb -0x63(%rbp), %cl
je 0x62a54
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movq $0x0, 0x20(%rdi)
movzwl -0x64(%rbp), %ecx
movw %cx, 0x96(%rdi)
leal (%rax,%rax), %ecx
leal (%rcx,%rcx,4), %ecx
movzwl -0x68(%rbp), %edx
movw %dx, -0x2(%rdi,%rcx)
movq -0x70(%rbp), %rdx
movq %rdx, -0xa(%rdi,%rcx)
xorl %r12d, %r12d
cmpl $0x4, %eax
jne 0x629f4
movups (%r14), %xmm0
leaq -0x108(%rbp), %rsi
movups %xmm0, 0x28(%rsi)
callq 0x3564c
testl %eax, %eax
je 0x629f4
cmpl %ebx, -0x108(%rbp)
jne 0x629f4
addl $-0x7, %r15d
movl %r15d, -0x100(%rbp)
leaq 0x82a90(%r14), %rdi
leaq 0x9c12(%rip), %rsi      # 0x6c6c7
callq 0x8160
testq %rax, %rax
jne 0x62ae4
movl -0x104(%rbp), %eax
movq 0x1d88(%r14), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x98, %rdx, %rdx
cmpl -0x94(%rcx,%rdx), %eax
je 0x629f4
movq 0x1d88(%r14), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x98, %rcx, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x98, %rdi
leaq -0x108(%rbp), %rsi
movl $0x98, %edx
callq 0x84f0
movl %ebx, 0x70e40(%r14)
movl $0x2, %r12d
jmp 0x629f4