// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x33e25(%rip), %rsi     # 0x6314c
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x455bc
pushq $0x1
popq %rbx
pushq $0x4
popq %rdx
movq %r15, %rdi
movl %ebx, %esi
callq 0x459f7
movl %eax, -0x30(%rbp)
pushq $0x7
popq %rsi
pushq $0x2
popq %rdx
movq %r15, %rdi
callq 0x459f7
pushq $0x9
popq %rsi
pushq $0x5
popq %r12
movq %r15, %rdi
movl %r12d, %edx
callq 0x459f7
movl %eax, -0x58(%rbp)
pushq $0xe
popq %rsi
pushq $0x6
popq %rdx
movq %r15, %rdi
callq 0x459f7
movl %eax, -0x54(%rbp)
pushq $0x14
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
callq 0x459f7
movl %eax, -0x4c(%rbp)
pushq $0x15
popq %rsi
pushq $0x18
popq %rdx
movq %r15, %rdi
callq 0x2f80d
mulsd 0x3398a(%rip), %xmm0    # 0x62d28
mulsd 0x320c2(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x50(%r14)
pushq $0x2d
popq %rsi
movq %r15, %rdi
movl %r12d, %edx
callq 0x2f80d
mulsd 0x3396e(%rip), %xmm0    # 0x62d30
mulsd 0x3209e(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x68(%r14)
pushq $0x32
popq %rsi
pushq $0x1b
popq %r13
movq %r15, %rdi
movl %r13d, %edx
callq 0x2f80d
mulsd 0x3394e(%rip), %xmm0    # 0x62d38
mulsd 0x32076(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x38(%r14)
pushq $0x51
popq %rsi
movq %r15, %rdi
pushq $0x4
popq %rdx
movl %edx, %r12d
callq 0x459f7
movl %eax, -0x48(%rbp)
pushq $0x55
popq %rsi
movq %r15, %rdi
pushq $0x3
popq %rdx
callq 0x459f7
movl %eax, 0xc(%r14)
pushq $0x58
popq %rsi
movq %r15, %rdi
movl %ebx, %edx
callq 0x459f7
pushq $0x59
popq %rsi
movq %r15, %rdi
pushq $0x7
popq %rdx
callq 0x459f7
movl %eax, -0x50(%rbp)
pushq $0x65
popq %rsi
movq %r15, %rdi
pushq $0x18
popq %rdx
callq 0x2f80d
mulsd 0x338d6(%rip), %xmm0    # 0x62d28
mulsd 0x3200e(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x58(%r14)
pushq $0x7d
popq %rsi
movq %r15, %rdi
pushq $0x5
popq %rdx
callq 0x2f80d
mulsd 0x338ba(%rip), %xmm0    # 0x62d30
mulsd 0x31fea(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x70(%r14)
movq %r15, %rdi
movl $0x82, %esi
movl %r13d, %edx
callq 0x2f80d
mulsd 0x3389c(%rip), %xmm0    # 0x62d38
mulsd 0x31fc4(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x40(%r14)
movq %r15, %rdi
movl $0xa1, %esi
movl %r12d, %edx
callq 0x459f7
movl %eax, -0x40(%rbp)
movq %r15, %rdi
movl $0xa5, %esi
movl %ebx, %edx
callq 0x459f7
pushq $0xb
popq %rdx
movq %r15, %rdi
movl $0xa6, %esi
callq 0x2f80d
mulsd 0x3385c(%rip), %xmm0    # 0x62d40
movsd %xmm0, 0x88(%r14)
movq %r15, %rdi
movl $0xb2, %esi
pushq $0x2
popq %rdx
callq 0x459f7
movq %r15, %rdi
movl $0xb4, %esi
movl %ebx, %edx
callq 0x459f7
movq %r15, %rdi
movl $0xb5, %esi
pushq $0x18
popq %rdx
callq 0x2f80d
mulsd 0x33804(%rip), %xmm0    # 0x62d28
mulsd 0x31f3c(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x60(%r14)
movq %r15, %rdi
movl $0xcd, %esi
pushq $0x5
popq %r13
movl %r13d, %edx
callq 0x2f80d
mulsd 0x337e2(%rip), %xmm0    # 0x62d30
mulsd 0x31f12(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x78(%r14)
movq %r15, %rdi
movl $0xd2, %esi
pushq $0x1b
popq %rdx
callq 0x2f80d
mulsd 0x337c4(%rip), %xmm0    # 0x62d38
mulsd 0x31eec(%rip), %xmm0    # 0x61468
movsd %xmm0, 0x48(%r14)
movq %r15, %rdi
movl $0xf1, %esi
movl %r12d, %edx
callq 0x459f7
movl %eax, %r12d
pushq $0x16
popq %rdx
movq %r15, %rdi
movl $0xf5, %esi
callq 0x2f80d
mulsd 0x33783(%rip), %xmm0    # 0x62d30
movsd %xmm0, 0x80(%r14)
movq %r15, %rdi
movl $0x10b, %esi            # imm = 0x10B
movl %r13d, %edx
callq 0x2f80d
mulsd 0x33762(%rip), %xmm0    # 0x62d30
movsd %xmm0, 0x90(%r14)
movq %r15, %rdi
movl $0x110, %esi            # imm = 0x110
movl %r13d, %edx
callq 0x459f7
movl %eax, 0x14(%r14)
movq %r15, %rdi
movl $0x123, %esi            # imm = 0x123
movl %ebx, %edx
callq 0x459f7
movq %r15, %rdi
movl $0x124, %esi            # imm = 0x124
pushq $0x4
popq %rdx
callq 0x459f7
movl %eax, 0x10(%r14)
movq %r15, %rdi
movl $0x12b, %esi            # imm = 0x12B
pushq $0xb
popq %rdx
callq 0x459f7
movq %r15, %rdi
movl $0x136, %esi            # imm = 0x136
movl %r13d, %edx
callq 0x459f7
movl %eax, %r13d
movq %r15, %rdi
movl $0x13b, %esi            # imm = 0x13B
pushq $0x2
popq %rdx
callq 0x459f7
movl -0x40(%rbp), %r8d
movl -0x48(%rbp), %ecx
movl -0x30(%rbp), %edx
movl %edx, %eax
xorl $0x1, %eax
movl %ecx, %esi
xorl $0x2, %esi
orl %eax, %esi
movl %r8d, %eax
xorl $0x3, %eax
orl %esi, %eax
movl %r12d, %esi
xorl $0x4, %esi
orl %eax, %esi
je 0x2f684
leaq 0x33aec(%rip), %rsi     # 0x6315c
pushq $0x3
popq %rdi
movl %r12d, %r9d
xorl %eax, %eax
callq 0x455bc
xorl %ebx, %ebx
jmp 0x2f7fc
pushq $0x4
popq %rdi
movl %r13d, %esi
callq 0x452fd
movl %eax, (%r14)
testl %eax, %eax
je 0x2f740
andl $0x0, 0x8(%r14)
imull $0x1e, -0x4c(%rbp), %r15d
movl -0x50(%rbp), %r12d
movl %r12d, 0x4(%r14)
movq 0x28(%r14), %rdi
movsd 0x30(%r14), %xmm0
callq 0x47732
leaq -0x34(%rbp), %rsi
movq %rax, %rdi
callq 0x470f1
movsd %xmm0, -0x30(%rbp)
movsd 0x311ec(%rip), %xmm1    # 0x608c0
callq 0x8840
cvtsi2sdl -0x58(%rbp), %xmm1
cvtsi2sdl -0x54(%rbp), %xmm2
mulsd 0x311bd(%rip), %xmm2    # 0x608a8
mulsd 0x311bd(%rip), %xmm1    # 0x608b0
movapd %xmm0, %xmm3
addsd %xmm2, %xmm1
cvtsi2sd %r15d, %xmm0
movsd -0x30(%rbp), %xmm2
subsd %xmm3, %xmm2
movsd %xmm2, -0x30(%rbp)
addsd %xmm1, %xmm0
addsd 0x3269e(%rip), %xmm0    # 0x61db8
movsd 0x326be(%rip), %xmm1    # 0x61de0
addsd %xmm3, %xmm1
movsd %xmm1, -0x48(%rbp)
ucomisd %xmm0, %xmm1
movsd %xmm3, -0x40(%rbp)
jbe 0x2f75b
addsd 0x31182(%rip), %xmm0    # 0x608c0
jmp 0x2f775
leaq 0x33a3e(%rip), %rsi     # 0x63185
xorl %ebx, %ebx
pushq $0x2
popq %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x455bc
jmp 0x2f7fc
movsd 0x32685(%rip), %xmm1    # 0x61de8
addsd %xmm3, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2f775
addsd 0x3267b(%rip), %xmm0    # 0x61df0
movl -0x34(%rbp), %edi
addsd -0x30(%rbp), %xmm0
callq 0x4708a
movq %rax, %rdi
callq 0x477da
movq %rax, 0x28(%r14)
movsd %xmm0, 0x30(%r14)
cvtsi2sd %r12d, %xmm1
mulsd 0x31307(%rip), %xmm1    # 0x60aa8
addsd 0x3260f(%rip), %xmm1    # 0x61db8
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2f7be
addsd 0x31104(%rip), %xmm1    # 0x608c0
jmp 0x2f7d9
movsd -0x40(%rbp), %xmm0
addsd 0x3261d(%rip), %xmm0    # 0x61de8
ucomisd %xmm0, %xmm1
jbe 0x2f7d9
addsd 0x32617(%rip), %xmm1    # 0x61df0
movl -0x34(%rbp), %edi
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
callq 0x4708a
movq %rax, %rdi
callq 0x477da
movq %rax, 0x18(%r14)
movsd %xmm0, 0x20(%r14)
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq