// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rcvraw.cpp
// Function: bamboo::decode_gal_inav(unsigned char const*, bamboo::eph_t*)
extern int decode_gal_inav(const unsigned char *buff, eph_t *eph)
{
    double tow,toc,tt,sqrtA;
    int i,time_f,week,svid,e5b_hs,e1b_hs,e5b_dvs,e1b_dvs,type[6],iod_nav[4];
    
    i=0; /* word type 0 */
    type[0]    =getbitu(buff,i, 6);              i+= 6;
    time_f     =getbitu(buff,i, 2);              i+= 2+88;
    week       =getbitu(buff,i,12);              i+=12; /* gst-week */
    tow        =getbitu(buff,i,20);
    
    i=128; /* word type 1 */
    type[1]    =getbitu(buff,i, 6);              i+= 6;
    iod_nav[0] =getbitu(buff,i,10);              i+=10;
    eph->toes  =getbitu(buff,i,14)*60.0;         i+=14;
    eph->M0    =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->e     =getbitu(buff,i,32)*P2_33;        i+=32;
    sqrtA      =getbitu(buff,i,32)*P2_19;
    
    i=128*2; /* word type 2 */
    type[2]    =getbitu(buff,i, 6);              i+= 6;
    iod_nav[1] =getbitu(buff,i,10);              i+=10;
    eph->OMG0  =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->i0    =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->omg   =getbits(buff,i,32)*P2_31*SC2RAD; i+=32;
    eph->idot  =getbits(buff,i,14)*P2_43*SC2RAD;
    
    i=128*3; /* word type 3 */
    type[3]    =getbitu(buff,i, 6);              i+= 6;
    iod_nav[2] =getbitu(buff,i,10);              i+=10;
    eph->OMGd  =getbits(buff,i,24)*P2_43*SC2RAD; i+=24;
    eph->deln  =getbits(buff,i,16)*P2_43*SC2RAD; i+=16;
    eph->cuc   =getbits(buff,i,16)*P2_29;        i+=16;
    eph->cus   =getbits(buff,i,16)*P2_29;        i+=16;
    eph->crc   =getbits(buff,i,16)*P2_5;         i+=16;
    eph->crs   =getbits(buff,i,16)*P2_5;         i+=16;
    eph->sva   =getbitu(buff,i, 8);
    
    i=128*4; /* word type 4 */
    type[4]    =getbitu(buff,i, 6);              i+= 6;
    iod_nav[3] =getbitu(buff,i,10);              i+=10;
    svid       =getbitu(buff,i, 6);              i+= 6;
    eph->cic   =getbits(buff,i,16)*P2_29;        i+=16;
    eph->cis   =getbits(buff,i,16)*P2_29;        i+=16;
    toc        =getbitu(buff,i,14)*60.0;         i+=14;
    eph->f0    =getbits(buff,i,31)*P2_34;        i+=31;
    eph->f1    =getbits(buff,i,21)*P2_46;        i+=21;
    eph->f2    =getbits(buff,i, 6)*P2_59;
    
    i=128*5; /* word type 5 */
    type[5]    =getbitu(buff,i, 6);              i+= 6+41;
    eph->tgd[0]=getbits(buff,i,10)*P2_32;        i+=10; /* BGD E5a/E1 */
    eph->tgd[1]=getbits(buff,i,10)*P2_32;        i+=10; /* BGD E5b/E1 */
    e5b_hs     =getbitu(buff,i, 2);              i+= 2;
    e1b_hs     =getbitu(buff,i, 2);              i+= 2;
    e5b_dvs    =getbitu(buff,i, 1);              i+= 1;
    e1b_dvs    =getbitu(buff,i, 1);
    
    /* test word types */
    if (type[0]!=0||type[1]!=1||type[2]!=2||type[3]!=3||type[4]!=4||type[5]!=5) {
        trace(3,"decode_gal_inav error: type=%d %d %d %d %d %d\n",type[0],
              type[1],type[2],type[3],type[4],type[5]);
        return 0;
    }
    /* test word type 0 time field */
    if (time_f!=2) {
        trace(3,"decode_gal_inav error: word0-time=%d\n",time_f);
        return 0;
    }
    /* test consistency of iod_nav */
    if (iod_nav[0]!=iod_nav[1]||iod_nav[0]!=iod_nav[2]||iod_nav[0]!=iod_nav[3]) {
        trace(3,"decode_gal_inav error: ionav=%d %d %d %d\n",iod_nav[0],
              iod_nav[1],iod_nav[2],iod_nav[3]);
        return 0;
    }
    if (!(eph->sat=satno(SYS_GAL,svid))) {
        trace(2,"decode_gal_inav svid error: svid=%d\n",svid);
        return 0;
    }
    eph->A=sqrtA*sqrtA;
    eph->iode=eph->iodc=iod_nav[0];
    eph->svh=(e5b_hs<<7)|(e5b_dvs<<6)|(e1b_hs<<1)|e1b_dvs;
    eph->ttr=gst2time(week,tow);
    tt=timediff(gst2time(week,eph->toes),eph->ttr); /* week complient to toe */
    if      (tt> 302400.0) week--;
    else if (tt<-302400.0) week++;
    eph->toe=gst2time(week,eph->toes);
    eph->toc=gst2time(week,toc);
    eph->week=week+1024; /* gal-week = gst-week + 1024 */
    eph->code =(1<<0)|(1<<9); /* data source = i/nav e1b, af0-2,toc,sisa for e5b-e1 */
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r12
xorl %esi, %esi
movl $0x6, %edx
callq 0x4e341
movl %eax, -0x30(%rbp)
movq %r12, %rdi
movl $0x6, %esi
movl $0x2, %edx
callq 0x4e341
movl %eax, -0x60(%rbp)
movq %r12, %rdi
movl $0x60, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, -0x48(%rbp)
movq %r12, %rdi
movl $0x6c, %esi
movl $0x14, %edx
callq 0x4e341
movl %eax, -0x44(%rbp)
movq %r12, %rdi
movl $0x80, %esi
movl $0x6, %edx
callq 0x4e341
movl %eax, -0x6c(%rbp)
movq %r12, %rdi
movl $0x86, %esi
movl $0xa, %edx
callq 0x4e341
movl %eax, -0x5c(%rbp)
movq %r12, %rdi
movl $0x90, %esi
movl $0xe, %edx
callq 0x4e341
movl %eax, %eax
cvtsi2sd %rax, %xmm0
mulsd 0x36e00(%rip), %xmm0    # 0x6a8b8
movsd %xmm0, 0xc8(%rbx)
movq %r12, %rdi
movl $0x9e, %esi
movl $0x20, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x391d7(%rip), %xmm0    # 0x6ccb8
mulsd 0x382bf(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x78(%rbx)
movq %r12, %rdi
movl $0xbe, %esi
movl $0x20, %edx
callq 0x4e341
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x391ae(%rip), %xmm0    # 0x6ccc0
movsd %xmm0, 0x58(%rbx)
movq %r12, %rdi
movl $0xde, %esi
movl $0x20, %edx
callq 0x4e341
movl %eax, -0x40(%rbp)
movq %r12, %rdi
movl $0x100, %esi            # imm = 0x100
movl $0x6, %edx
callq 0x4e341
movl %eax, -0x68(%rbp)
movq %r12, %rdi
movl $0x106, %esi            # imm = 0x106
movl $0xa, %edx
callq 0x4e341
movl %eax, -0x58(%rbp)
movq %r12, %rdi
movl $0x110, %esi            # imm = 0x110
movl $0x20, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x39141(%rip), %xmm0    # 0x6ccb8
mulsd 0x38229(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x68(%rbx)
movq %r12, %rdi
movl $0x130, %esi            # imm = 0x130
movl $0x20, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x39113(%rip), %xmm0    # 0x6ccb8
mulsd 0x381fb(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x60(%rbx)
movq %r12, %rdi
movl $0x150, %esi            # imm = 0x150
movl $0x20, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x390e5(%rip), %xmm0    # 0x6ccb8
mulsd 0x381cd(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x70(%rbx)
movq %r12, %rdi
movl $0x170, %esi            # imm = 0x170
movl $0xe, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x390cf(%rip), %xmm0    # 0x6ccd0
mulsd 0x3819f(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x90(%rbx)
movq %r12, %rdi
movl $0x180, %esi            # imm = 0x180
movl $0x6, %edx
callq 0x4e341
movl %eax, -0x64(%rbp)
movq %r12, %rdi
movl $0x186, %esi            # imm = 0x186
movl $0xa, %edx
callq 0x4e341
movl %eax, -0x54(%rbp)
movq %r12, %rdi
movl $0x190, %esi            # imm = 0x190
movl $0x18, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x39074(%rip), %xmm0    # 0x6ccd0
mulsd 0x38144(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x88(%rbx)
movq %r12, %rdi
movl $0x1a8, %esi            # imm = 0x1A8
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x39043(%rip), %xmm0    # 0x6ccd0
mulsd 0x38113(%rip), %xmm0    # 0x6bda8
movsd %xmm0, 0x80(%rbx)
movq %r12, %rdi
movl $0x1b8, %esi            # imm = 0x1B8
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x3901a(%rip), %xmm0    # 0x6ccd8
movsd %xmm0, 0xa8(%rbx)
movq %r12, %rdi
movl $0x1c8, %esi            # imm = 0x1C8
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38ff1(%rip), %xmm0    # 0x6ccd8
movsd %xmm0, 0xb0(%rbx)
movq %r12, %rdi
movl $0x1d8, %esi            # imm = 0x1D8
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38fd0(%rip), %xmm0    # 0x6cce0
movsd %xmm0, 0x98(%rbx)
movq %r12, %rdi
movl $0x1e8, %esi            # imm = 0x1E8
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38fa7(%rip), %xmm0    # 0x6cce0
movsd %xmm0, 0xa0(%rbx)
movq %r12, %rdi
movl $0x1f8, %esi            # imm = 0x1F8
movl $0x8, %edx
callq 0x4e341
movl %eax, 0xc(%rbx)
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movl $0x6, %edx
callq 0x4e341
movl %eax, %r14d
movq %r12, %rdi
movl $0x206, %esi            # imm = 0x206
movl $0xa, %edx
callq 0x4e341
movl %eax, -0x50(%rbp)
movq %r12, %rdi
movl $0x210, %esi            # imm = 0x210
movl $0x6, %edx
callq 0x4e341
movl %eax, -0x4c(%rbp)
movq %r12, %rdi
movl $0x216, %esi            # imm = 0x216
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38f22(%rip), %xmm0    # 0x6ccd8
movsd %xmm0, 0xb8(%rbx)
movq %r12, %rdi
movl $0x226, %esi            # imm = 0x226
movl $0x10, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38ef9(%rip), %xmm0    # 0x6ccd8
movsd %xmm0, 0xc0(%rbx)
movq %r12, %rdi
movl $0x236, %esi            # imm = 0x236
movl $0xe, %edx
callq 0x4e341
movl %eax, -0x3c(%rbp)
movq %r12, %rdi
movl $0x244, %esi            # imm = 0x244
movl $0x1f, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38ecb(%rip), %xmm0    # 0x6cce8
movsd %xmm0, 0xd8(%rbx)
movq %r12, %rdi
movl $0x263, %esi            # imm = 0x263
movl $0x15, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38eaa(%rip), %xmm0    # 0x6ccf0
movsd %xmm0, 0xe0(%rbx)
movq %r12, %rdi
movl $0x278, %esi            # imm = 0x278
movl $0x6, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38e89(%rip), %xmm0    # 0x6ccf8
movsd %xmm0, 0xe8(%rbx)
movq %r12, %rdi
movl $0x280, %esi            # imm = 0x280
movl $0x6, %edx
callq 0x4e341
movl %eax, %r15d
movq %r12, %rdi
movl $0x2af, %esi            # imm = 0x2AF
movl $0xa, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38e53(%rip), %xmm0    # 0x6cd00
movsd %xmm0, 0xf0(%rbx)
movq %r12, %rdi
movl $0x2b9, %esi            # imm = 0x2B9
movl $0xa, %edx
callq 0x4e390
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x38e2a(%rip), %xmm0    # 0x6cd00
movsd %xmm0, 0xf8(%rbx)
movq %r12, %rdi
movl $0x2c3, %esi            # imm = 0x2C3
movl $0x2, %edx
callq 0x4e341
movl %eax, -0x38(%rbp)
movq %r12, %rdi
movl $0x2c5, %esi            # imm = 0x2C5
movl $0x2, %edx
callq 0x4e341
movl %eax, -0x34(%rbp)
movq %r12, %rdi
movl $0x2c7, %esi            # imm = 0x2C7
movl $0x1, %edx
callq 0x4e341
movl %eax, %r13d
movq %r12, %rdi
movl $0x2c8, %esi            # imm = 0x2C8
movl $0x1, %edx
callq 0x4e341
movl -0x64(%rbp), %r9d
movl -0x68(%rbp), %r8d
movl -0x6c(%rbp), %ecx
movl -0x30(%rbp), %edx
movl %eax, %r12d
movl %ecx, %eax
xorl $0x1, %eax
orl %edx, %eax
movl %r8d, %edi
xorl $0x2, %edi
movl %r9d, %esi
xorl $0x3, %esi
orl %edi, %esi
orl %eax, %esi
movl %r14d, %eax
xorl $0x4, %eax
orl %esi, %eax
movl %r15d, %esi
xorl $0x5, %esi
orl %eax, %esi
je 0x33f8b
leaq 0x39018(%rip), %rsi     # 0x6cf88
movl $0x3, %edi
xorl %eax, %eax
pushq %r15
pushq %r14
callq 0x4ded0
addq $0x10, %rsp
xorl %ebx, %ebx
jmp 0x34118
movl -0x60(%rbp), %edx
cmpl $0x2, %edx
jne 0x3407a
movl -0x5c(%rbp), %r14d
movl %r14d, %eax
movl -0x58(%rbp), %ecx
xorl %ecx, %eax
movl %r14d, %edx
movl -0x54(%rbp), %r8d
xorl %r8d, %edx
orl %eax, %edx
movl %r14d, %eax
movl -0x50(%rbp), %r9d
xorl %r9d, %eax
orl %edx, %eax
jne 0x34094
movl $0x8, %edi
movl -0x4c(%rbp), %r15d
movl %r15d, %esi
callq 0x4dbc5
movl %eax, (%rbx)
testl %eax, %eax
je 0x340ae
movl -0x44(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd 0x38cd4(%rip), %xmm1    # 0x6ccc8
movl -0x3c(%rbp), %eax
cvtsi2sd %rax, %xmm2
mulsd 0x368b4(%rip), %xmm2    # 0x6a8b8
movsd %xmm2, -0x30(%rbp)
mulsd %xmm1, %xmm1
movsd %xmm1, 0x50(%rbx)
movl %r14d, 0x8(%rbx)
movl %r14d, 0x4(%rbx)
movl -0x38(%rbp), %eax
shll $0x7, %eax
shll $0x6, %r13d
movl -0x34(%rbp), %ecx
addl %ecx, %ecx
orl %eax, %ecx
orl %r12d, %r13d
orl %ecx, %r13d
movl %r13d, 0x10(%rbx)
movl -0x48(%rbp), %r14d
movl %r14d, %edi
callq 0x4fca5
movq %rax, 0x40(%rbx)
movsd %xmm0, 0x48(%rbx)
movsd 0xc8(%rbx), %xmm0
movl %r14d, %edi
callq 0x4fca5
movq 0x40(%rbx), %rsi
movsd 0x48(%rbx), %xmm1
movq %rax, %rdi
callq 0x4fe97
ucomisd 0x37d65(%rip), %xmm0    # 0x6bdd8
jbe 0x340c1
decl %r14d
jmp 0x340d2
leaq 0x38f36(%rip), %rsi     # 0x6cfb7
xorl %ebx, %ebx
movl $0x3, %edi
xorl %eax, %eax
callq 0x4ded0
jmp 0x34118
leaq 0x38f42(%rip), %rsi     # 0x6cfdd
xorl %ebx, %ebx
movl $0x3, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4ded0
jmp 0x34118
leaq 0x38f52(%rip), %rsi     # 0x6d007
xorl %ebx, %ebx
movl $0x2, %edi
movl %r15d, %edx
jmp 0x34088
movsd 0x37d07(%rip), %xmm1    # 0x6bdd0
ucomisd %xmm0, %xmm1
jbe 0x340d2
incl %r14d
movsd 0xc8(%rbx), %xmm0
movl %r14d, %edi
callq 0x4fca5
movq %rax, 0x20(%rbx)
movsd %xmm0, 0x28(%rbx)
movl %r14d, %edi
movsd -0x30(%rbp), %xmm0
callq 0x4fca5
movq %rax, 0x30(%rbx)
movsd %xmm0, 0x38(%rbx)
addl $0x400, %r14d           # imm = 0x400
movl %r14d, 0x14(%rbx)
movl $0x201, 0x18(%rbx)      # imm = 0x201
movl $0x1, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq