// File: /workspace/github_cpp_makefile_star2_O2/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 0x45362
movl 0x81a78(%r14), %edx
leal 0x18(%r12), %eax
cmpl %eax, %edx
jge 0x58730
leaq 0x168c4(%rip), %rsi     # 0x6efef
pushq $0x2
popq %rdi
jmp 0x587a2
movl %r12d, %eax
addq %r14, %rax
addq $0x81a99, %rax          # imm = 0x81A99
xorl %ecx, %ecx
cmpl $0x4, %r13d
je 0x58769
movslq %ecx, %rcx
xorl %edx, %edx
cmpq $-0x4, %rdx
je 0x58760
movb (%rax,%rdx), %sil
movb %sil, -0x70(%rbp,%rcx)
incq %rcx
decq %rdx
jmp 0x58749
incl %r13d
addq $0x4, %rax
jmp 0x5873e
leaq -0x70(%rbp), %rdi
callq 0x2f2a1
testl %eax, %eax
je 0x58796
leaq -0x70(%rbp), %rdi
pushq $0x1
popq %rsi
pushq $0x4
popq %rdx
callq 0x459f7
leal -0x10(%rax), %ecx
cmpl $-0x10, %ecx
ja 0x587c2
leaq 0x168b3(%rip), %rsi     # 0x6f047
jmp 0x5879d
leaq 0x1687a(%rip), %rsi     # 0x6f017
pushq $0x2
popq %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x455bc
pushq $-0x1
popq %r12
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 0x587f0
movb 0x97(%rdi), %cl
cmpb -0x63(%rbp), %cl
je 0x58814
xorl %ecx, %ecx
cmpq $0x28, %rcx
je 0x58809
andw $0x0, 0x8(%rdi,%rcx)
andq $0x0, (%rdi,%rcx)
addq $0xa, %rcx
jmp 0x587f2
movzwl -0x64(%rbp), %ecx
movw %cx, 0x96(%rdi)
imull $0xa, %eax, %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 0x587ad
movups (%r14), %xmm0
leaq -0x108(%rbp), %rsi
movups %xmm0, 0x28(%rsi)
callq 0x2f309
testl %eax, %eax
je 0x587ad
cmpl %ebx, -0x108(%rbp)
jne 0x587ad
addl $-0x7, %r15d
movl %r15d, -0x100(%rbp)
leaq 0x82a90(%r14), %rdi
leaq 0x9e51(%rip), %rsi      # 0x626c7
callq 0x8170
testq %rax, %rax
je 0x5888d
movq 0x1d88(%r14), %rax
movslq -0x2c(%rbp), %rcx
jmp 0x588b2
movl -0x104(%rbp), %edx
movq 0x1d88(%r14), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x98, %rcx, %rsi
cmpl -0x94(%rax,%rsi), %edx
je 0x587ad
imulq $0x98, %rcx, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x98, %rdi
leaq -0x108(%rbp), %rsi
movl $0x98, %edx
callq 0x84f0
movl %ebx, 0x70e40(%r14)
pushq $0x2
jmp 0x587ab