// File: DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::decode_glostr(unsigned char const*, bamboo::geph_t*)
extern int decode_glostr(const unsigned char *buff, geph_t *geph)
{
    double tow,tod,tof,toe;
    int P,P1,P2,P3,P4,tk_h,tk_m,tk_s,tb,ln,NT,slot,M,week;
    int i=1,frn1,frn2,frn3,frn4;
    
    trace(3,"decode_glostr:\n");
    
    /* frame 1 */
    frn1        =getbitu(buff,i, 4);           i+= 4+2;
    P1          =getbitu(buff,i, 2);           i+= 2;
    tk_h        =getbitu(buff,i, 5);           i+= 5;
    tk_m        =getbitu(buff,i, 6);           i+= 6;
    tk_s        =getbitu(buff,i, 1)*30;        i+= 1;
    geph->vel[0]=getbitg(buff,i,24)*P2_20*1E3; i+=24;
    geph->acc[0]=getbitg(buff,i, 5)*P2_30*1E3; i+= 5;
    geph->pos[0]=getbitg(buff,i,27)*P2_11*1E3; i+=27+4;
    
    /* frame 2 */
    frn2        =getbitu(buff,i, 4);           i+= 4;
    geph->svh   =getbitu(buff,i, 3);           i+= 3;
    P2          =getbitu(buff,i, 1);           i+= 1;
    tb          =getbitu(buff,i, 7);           i+= 7+5;
    geph->vel[1]=getbitg(buff,i,24)*P2_20*1E3; i+=24;
    geph->acc[1]=getbitg(buff,i, 5)*P2_30*1E3; i+= 5;
    geph->pos[1]=getbitg(buff,i,27)*P2_11*1E3; i+=27+4;
    
    /* frame 3 */
    frn3        =getbitu(buff,i, 4);           i+= 4;
    P3          =getbitu(buff,i, 1);           i+= 1;
    geph->gamn  =getbitg(buff,i,11)*P2_40;     i+=11+1;
    P           =getbitu(buff,i, 2);           i+= 2;
    ln          =getbitu(buff,i, 1);           i+= 1;
    geph->vel[2]=getbitg(buff,i,24)*P2_20*1E3; i+=24;
    geph->acc[2]=getbitg(buff,i, 5)*P2_30*1E3; i+= 5;
    geph->pos[2]=getbitg(buff,i,27)*P2_11*1E3; i+=27+4;
    
    /* frame 4 */
    frn4        =getbitu(buff,i, 4);           i+= 4;
    geph->taun  =getbitg(buff,i,22)*P2_30;     i+=22;
    geph->dtaun =getbitg(buff,i, 5)*P2_30;     i+= 5;
    geph->age   =getbitu(buff,i, 5);           i+= 5+14;
    P4          =getbitu(buff,i, 1);           i+= 1;
    geph->sva   =getbitu(buff,i, 4);           i+= 4+3;
    NT          =getbitu(buff,i,11);           i+=11;
    slot        =getbitu(buff,i, 5);           i+= 5;
    M           =getbitu(buff,i, 2);
    
    if (frn1!=1||frn2!=2||frn3!=3||frn4!=4) {
        trace(3,"decode_glostr error: frn=%d %d %d %d %d\n",frn1,frn2,frn3,frn4);
        return 0;
    }
    if (!(geph->sat=satno(SYS_GLO,slot))) {
        trace(2,"decode_glostr error: slot=%d\n",slot);
        return 0;
    }
    geph->frq=0;
    geph->iode=tb;
    tow=time2gpst(gpst2utc(geph->tof),&week);
    tod=fmod(tow,86400.0); tow-=tod;
    tof=tk_h*3600.0+tk_m*60.0+tk_s-10800.0; /* lt->utc */
    if      (tof<tod-43200.0) tof+=86400.0;
    else if (tof>tod+43200.0) tof-=86400.0;
    geph->tof=utc2gpst(gpst2time(week,tow+tof));
    toe=tb*900.0-10800.0; /* lt->utc */
    if      (toe<tod-43200.0) toe+=86400.0;
    else if (toe>tod+43200.0) toe-=86400.0;
    geph->toe=utc2gpst(gpst2time(week,tow+toe)); /* utc->gpst */
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x1, -0x74(%rbp)
movl $0x3, %edi
leaq 0x5a676(%rip), %rsi     # 0xbf2ac
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, -0x78(%rbp)
movl -0x74(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x2, %edx
callq 0x8bfc0
movl %eax, -0x40(%rbp)
movl -0x74(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x50(%rbp)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x6, %edx
callq 0x8bfc0
movl %eax, -0x54(%rbp)
movl -0x74(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
imull $0x1e, %eax, %eax
movl %eax, -0x58(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x18, %edx
callq 0x65450
movsd 0x5a1b6(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x58732(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x50(%rax)
movl -0x74(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x65450
movsd 0x5a16b(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x586f7(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x68(%rax)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1b, %edx
callq 0x65450
movsd 0x5a138(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x586bc(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movl -0x74(%rbp), %eax
addl $0x1f, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, -0x7c(%rbp)
movl -0x74(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x3, %edx
callq 0x8bfc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x74(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x44(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x7, %edx
callq 0x8bfc0
movl %eax, -0x5c(%rbp)
movl -0x74(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x18, %edx
callq 0x65450
movsd 0x5a08b(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x58607(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x58(%rax)
movl -0x74(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x65450
movsd 0x5a040(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x585cc(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1b, %edx
callq 0x65450
movsd 0x5a00d(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x58591(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x40(%rax)
movl -0x74(%rbp), %eax
addl $0x1f, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, -0x80(%rbp)
movl -0x74(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x48(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0xb, %edx
callq 0x65450
movsd 0x59fa8(%rip), %xmm1    # 0xbeea8
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x88(%rax)
movl -0x74(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x2, %edx
callq 0x8bfc0
movl %eax, -0x3c(%rbp)
movl -0x74(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x60(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x18, %edx
callq 0x65450
movsd 0x59f34(%rip), %xmm1    # 0xbeea0
mulsd %xmm1, %xmm0
movsd 0x584b0(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x60(%rax)
movl -0x74(%rbp), %eax
addl $0x18, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x65450
movsd 0x59ee9(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movsd 0x58475(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x78(%rax)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1b, %edx
callq 0x65450
movsd 0x59eb6(%rip), %xmm1    # 0xbee98
mulsd %xmm1, %xmm0
movsd 0x5843a(%rip), %xmm1    # 0xbd428
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movl -0x74(%rbp), %eax
addl $0x1f, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, -0x84(%rbp)
movl -0x74(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x16, %edx
callq 0x65450
movsd 0x59e53(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movl -0x74(%rbp), %eax
addl $0x16, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x65450
movsd 0x59e21(%rip), %xmm1    # 0xbee90
mulsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x90(%rax)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x14(%rax)
movl -0x74(%rbp), %eax
addl $0x13, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x4c(%rbp)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x4, %edx
callq 0x8bfc0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x74(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0xb, %edx
callq 0x8bfc0
movl %eax, -0x64(%rbp)
movl -0x74(%rbp), %eax
addl $0xb, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x68(%rbp)
movl -0x74(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
movl $0x2, %edx
callq 0x8bfc0
movl %eax, -0x6c(%rbp)
cmpl $0x1, -0x78(%rbp)
jne 0x65154
cmpl $0x2, -0x7c(%rbp)
jne 0x65154
cmpl $0x3, -0x80(%rbp)
jne 0x65154
cmpl $0x4, -0x84(%rbp)
je 0x65184
movl -0x78(%rbp), %edx
movl -0x7c(%rbp), %ecx
movl -0x80(%rbp), %r8d
movl -0x84(%rbp), %r9d
movl $0x3, %edi
leaq 0x5a14b(%rip), %rsi     # 0xbf2bc
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0x6543c
movl -0x68(%rbp), %esi
movl $0x4, %edi
callq 0x8b1b0
movq -0x18(%rbp), %rcx
movl %eax, (%rcx)
cmpl $0x0, %eax
jne 0x651be
movl -0x68(%rbp), %edx
movl $0x2, %edi
leaq 0x5a13a(%rip), %rsi     # 0xbf2e5
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0x6543c
movq -0x18(%rbp), %rax
movl $0x0, 0x8(%rax)
movl -0x5c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x30(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa8(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
callq 0x8ef80
movq %rax, -0x98(%rbp)
movsd %xmm0, -0x90(%rbp)
movq -0x98(%rbp), %rdi
movsd -0x90(%rbp), %xmm0
leaq -0x70(%rbp), %rsi
callq 0x8e540
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movsd 0x57be6(%rip), %xmm1    # 0xbce20
callq 0x99f0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
cvtsi2sdl -0x50(%rbp), %xmm0
cvtsi2sdl -0x54(%rbp), %xmm1
movsd 0x57baf(%rip), %xmm2    # 0xbce18
mulsd %xmm2, %xmm1
movsd 0x57b9b(%rip), %xmm2    # 0xbce10
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd 0x57d62(%rip), %xmm1    # 0xbcff0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
movsd 0x58ac7(%rip), %xmm2    # 0xbdd70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x652c7
movsd 0x57b65(%rip), %xmm0    # 0xbce20
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x652f7
movsd -0x30(%rbp), %xmm0
movsd 0x58a9c(%rip), %xmm1    # 0xbdd70
addsd -0x28(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x652f5
movsd -0x30(%rbp), %xmm0
movsd 0x57b34(%rip), %xmm1    # 0xbce20
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x652f7
movl -0x70(%rbp), %edi
movsd -0x20(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0xc8(%rbp)
movsd %xmm0, -0xc0(%rbp)
movq -0xc8(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0xb8(%rbp)
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rax
movq -0xb8(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0xb0(%rbp), %rcx
movq %rcx, 0x30(%rax)
cvtsi2sdl -0x5c(%rbp), %xmm0
movsd 0x57c86(%rip), %xmm1    # 0xbcfe8
mulsd %xmm1, %xmm0
movsd 0x59b42(%rip), %xmm1    # 0xbeeb0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
movsd 0x589e7(%rip), %xmm2    # 0xbdd70
subsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x653a7
movsd 0x57a85(%rip), %xmm0    # 0xbce20
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x653d7
movsd -0x38(%rbp), %xmm0
movsd 0x589bc(%rip), %xmm1    # 0xbdd70
addsd -0x28(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x653d5
movsd -0x38(%rbp), %xmm0
movsd 0x57a54(%rip), %xmm1    # 0xbce20
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x653d7
movl -0x70(%rbp), %edi
movsd -0x20(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0xe8(%rbp)
movsd %xmm0, -0xe0(%rbp)
movq -0xe8(%rbp), %rdi
movsd -0xe0(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0xd8(%rbp)
movsd %xmm0, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0xd0(%rbp), %rcx
movq %rcx, 0x20(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)