// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/skytraq.cpp
// Function: bamboo::decode_stqrawx(bamboo::raw_t*)
static int decode_stqrawx(raw_t *raw)
{
    unsigned char *p=raw->buff+4,ind;
    double tow,peri,pr1,cp1;
    int i,j,ver,week,nsat,sys,sig,prn,sat,n=0;
    int gnss_type, signal_type;
    
    trace(4,"decode_stqraw: len=%d\n",raw->len);
    
    if (raw->outtype) {
        sprintf(raw->msgtype,"SKYTRAQ RAWX  (%4d): nsat=%2d",raw->len,U1(p+13));
    }
    ver=U1(p+1);
    raw->iod=U1(p+2);
    week=U2(p+3);
    tow =U4(p+5)*0.001;
    raw->time=gpst2time(week,tow);
    peri=U2(p+9)*0.001;
    nsat=U1(p+13);
    if (raw->len<19+31*nsat) {
        trace(2,"stq raw length error: len=%d nsat=%d\n",raw->len,nsat);
        return -1;
    }
    for (i=0,p+=14;i<nsat&&i<MAXOBS;i++,p+=31) {
        gnss_type=U1(p)&0xF;
        signal_type=(U1(p)>>4)&0xF;
        if (gnss_type==0) { /* GPS */
            sys=SYS_GPS;
            switch (signal_type) {
                case  1: sig=CODE_L1X; break;
                case  2: sig=CODE_L2X; break;
                case  4: sig=CODE_L5X; break;
                default: sig=CODE_L1C; break;
            }
            prn=U1(p+1);
        }
        else if (gnss_type==1) { /* SBAS */
            sys=SYS_SBS;
            sig=CODE_L1C;
            prn=U1(p+1);
        }
        else if (gnss_type==2) { /* GLONASS */
            sys=SYS_GLO;
            switch (signal_type) {
                case  2: sig=CODE_L2C; break;
                case  4: sig=CODE_L3X; break;
                default: sig=CODE_L1C; break;
            }
            prn=U1(p+1);
        }
        else if (gnss_type==3) { /* Galileo */
            sys=SYS_GAL;
            switch (signal_type) {
                case  4: sig=CODE_L5X; break;
                case  5: sig=CODE_L7X; break;
                case  6: sig=CODE_L6X; break;
                default: sig=CODE_L1C; break;
            }
            prn=U1(p+1);
        }
        else if (gnss_type==4) { /* QZSS */
            sys=SYS_QZS;
            switch (signal_type) {
                case  1: sig=CODE_L1X; break;
                case  2: sig=CODE_L2X; break;
                case  4: sig=CODE_L5X; break;
                case  6: sig=CODE_L6X; break;
                default: sig=CODE_L1C; break;
            }
            prn=U1(p+1);
        }
        else if (gnss_type==5) { /* BeiDou */
            sys=SYS_CMP;
            switch (signal_type) {
                case  4: sig=CODE_L7I; break;
                case  6: sig=CODE_L6I; break;
                default: sig=CODE_L2I; break;
            }
            prn=U1(p+1);
        }
        else {
            trace(2,"stq rawx gnss type error: type=%d\n",U1(p));
            continue;
        }
        if (!(sat=satno(sys,prn))) {
            trace(2,"stq raw satellite number error: sys=%d prn=%d\n",sys,prn);
            continue;
        }
        /* set glonass freq channel number */
        if (gnss_type==2) {
            raw->nav.geph[prn-1].frq=(int)(U1(p+2)&0xF)-7;
        }
        ind=U2(p+27);
        pr1=!(ind&1)?0.0:R8(p+ 4);
        cp1=!(ind&4)?0.0:R8(p+12);
        cp1-=floor((cp1+1E9)/2E9)*2E9; /* -10^9 < cp1 < 10^9 */
        
        raw->obs.data[n].P[0]=pr1;
        raw->obs.data[n].L[0]=cp1;
        raw->obs.data[n].D[0]=!(ind&2)?0.0:R4(p+20);
        raw->obs.data[n].SNR[0]=U1(p+3)*4;
        raw->obs.data[n].LLI[0]=0;
        raw->obs.data[n].code[0]=sys==SYS_CMP?CODE_L1I:CODE_L1C;
        
        raw->lockt[sat-1][0]=ind&8?1:0; /* cycle slip */
        
        if (raw->obs.data[n].L[0]!=0.0) {
            raw->obs.data[n].LLI[0]=(unsigned char)raw->lockt[sat-1][0];
            raw->lockt[sat-1][0]=0;
        }
        /* receiver dependent options */
        if (strstr(raw->opt,"-INVCP")) {
            raw->obs.data[n].L[0]*=-1.0;
        }
        raw->obs.data[n].time=raw->time;
        raw->obs.data[n].sat =sat;
        
        for (j=1;j<NFREQ+NEXOBS;j++) {
            raw->obs.data[n].L[j]=raw->obs.data[n].P[j]=0.0;
            raw->obs.data[n].D[j]=0.0;
            raw->obs.data[n].SNR[j]=raw->obs.data[n].LLI[j]=0;
            raw->obs.data[n].code[j]=CODE_NONE;
        }
        n++;
    }
    raw->obs.n=n;
    return n>0?1:0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movl 0x81a78(%rdi), %edx
leaq 0x1e08d(%rip), %rsi     # 0x75728
movl $0x4, %edi
xorl %eax, %eax
callq 0x4ded0
cmpl $0x0, 0x81a8c(%rbx)
je 0x576d2
leaq 0x70e70(%rbx), %rdi
movl 0x81a78(%rbx), %edx
movzbl 0x81aa1(%rbx), %ecx
leaq 0x1e133(%rip), %rsi     # 0x757fe
xorl %eax, %eax
callq 0x8120
movzbl 0x81a96(%rbx), %eax
movl %eax, 0x81a7c(%rbx)
movl $0x81a97, %eax          # imm = 0x81A97
leaq -0x2f(%rbp), %rcx
movb (%rbx,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x81a98, %eax          # imm = 0x81A98
je 0x576e8
leaq -0x2d(%rbp), %rax
movzwl -0x3(%rax), %edi
movl $0x81a99, %ecx          # imm = 0x81A99
movb (%rbx,%rcx), %dl
movb %dl, (%rax)
decq %rax
incq %rcx
cmpl $0x81a9d, %ecx          # imm = 0x81A9D
jne 0x57707
leaq -0x2f(%rbp), %r14
movl -0x1(%r14), %eax
cvtsi2sd %rax, %xmm0
mulsd 0x14649(%rip), %xmm0    # 0x6bd78
callq 0x4fbc6
movq %rax, (%rbx)
movsd %xmm0, 0x8(%rbx)
movl $0x81a9d, %eax          # imm = 0x81A9D
movb (%rbx,%rax), %cl
movb %cl, (%r14)
decq %r14
incq %rax
cmpl $0x81a9e, %eax          # imm = 0x81A9E
je 0x57741
movzbl 0x81aa1(%rbx), %ecx
movl 0x81a78(%rbx), %edx
movl %ecx, %eax
shll $0x5, %eax
subl %ecx, %eax
addl $0x13, %eax
cmpl %eax, %edx
jge 0x5778c
leaq 0x1e004(%rip), %rsi     # 0x7577a
movl $0x2, %edi
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x57b3d
cmpl $0x40, %ecx
movl $0x40, %eax
cmovbl %ecx, %eax
movl %eax, -0x64(%rbp)
testl %ecx, %ecx
je 0x57b26
leaq 0x81aa2(%rbx), %rax
leaq 0x7f670(%rbx), %rcx
leaq 0x82a90(%rbx), %rdx
movq %rdx, -0x78(%rbp)
leaq 0x81abd(%rbx), %r15
leaq 0x81aa6(%rbx), %rdx
leaq 0x81aae(%rbx), %rsi
leaq 0x81ab6(%rbx), %r13
xorl %r14d, %r14d
xorl %edi, %edi
movl $0x0, -0x34(%rbp)
movq %rcx, -0x80(%rbp)
movl %edi, -0x38(%rbp)
movq %rsi, -0x50(%rbp)
movq %rdx, -0x58(%rbp)
movzbl (%rax), %edx
movl %edx, %r12d
andl $0xf, %r12d
cmpl $0x6, %r12d
movq %rax, -0x60(%rbp)
jae 0x57ab9
movq %r13, -0x70(%rbp)
leal (,%r12,8), %ecx
movabsq $0x2f0101010101, %rdx   # imm = 0x2F0101010101
shrq %cl, %rdx
movq %rdx, -0x90(%rbp)
leaq 0x1dd63(%rip), %rcx     # 0x75594
movl (%rcx,%r12,4), %edi
movzbl 0x1(%rax), %r13d
movl %edi, -0x40(%rbp)
movl %r13d, %esi
callq 0x4dbc5
movl %eax, -0x44(%rbp)
testl %eax, %eax
je 0x57ad9
cmpl $0x2, %r12d
jne 0x5787c
movq -0x60(%rbp), %rax
movzbl 0x2(%rax), %eax
andl $0xf, %eax
addl $-0x7, %eax
movq 0x1d88(%rbx), %rcx
movl %r13d, %edx
imulq $0x98, %rdx, %rdx
movl %eax, -0x90(%rcx,%rdx)
xorl %eax, %eax
leaq -0x2f(%rbp), %rcx
movq -0x58(%rbp), %rsi
movb (%r15,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x1, %eax
je 0x57886
movzwl -0x30(%rbp), %edi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
testb $0x1, %dil
movq -0x70(%rbp), %r13
je 0x578c8
xorl %eax, %eax
leaq -0x29(%rbp), %rcx
movb (%rsi,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x578b3
movsd -0x30(%rbp), %xmm1
movsd %xmm1, -0x40(%rbp)
movl %edi, %r12d
testb $0x4, %dil
je 0x578f5
xorl %eax, %eax
leaq -0x29(%rbp), %rcx
movq -0x50(%rbp), %rsi
movb (%rsi,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x578e0
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
addsd 0x1d2ab(%rip), %xmm0    # 0x74bb0
movsd 0x1dca3(%rip), %xmm1    # 0x755b0
divsd %xmm1, %xmm0
callq 0x8ad0
mulsd 0x1dc92(%rip), %xmm0    # 0x755b0
movsd -0x88(%rbp), %xmm1
subsd %xmm0, %xmm1
movq 0x1d28(%rbx), %rax
movslq -0x34(%rbp), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rdx
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x38(%rax,%rdx)
movq %rdx, -0x40(%rbp)
movsd %xmm1, 0x20(%rax,%rdx)
xorpd %xmm0, %xmm0
movl %r12d, %r8d
testb $0x2, %r8b
je 0x5797d
xorl %edx, %edx
leaq -0x2d(%rbp), %rsi
movb (%r13,%rdx), %dil
movb %dil, (%rsi)
decq %rsi
incq %rdx
cmpl $0x4, %edx
jne 0x57965
movss -0x30(%rbp), %xmm0
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %r12
movss %xmm0, 0x50(%rax,%r12)
movq -0x60(%rbp), %rcx
movb 0x3(%rcx), %cl
shlb $0x2, %cl
movb %cl, 0x12(%rax,%r12)
movq 0x1d28(%rbx), %rax
movb $0x0, 0x15(%rax,%r12)
movq 0x1d28(%rbx), %rax
movq -0x90(%rbp), %rcx
movb %cl, 0x18(%rax,%r12)
shrl $0x3, %r8d
andl $0x1, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movl -0x44(%rbp), %eax
decl %eax
cltq
leaq (%rax,%rax,2), %rcx
movq -0x80(%rbp), %rdx
movsd %xmm0, (%rdx,%rcx,8)
movq 0x1d28(%rbx), %rax
movsd 0x20(%rax,%r12), %xmm0
ucomisd 0x12f13(%rip), %xmm0    # 0x6a908
jne 0x579f9
jnp 0x57a0b
leaq (%rdx,%rcx,8), %rcx
addq %r12, %rax
movb %r8b, 0x15(%rax)
movq $0x0, (%rcx)
movq -0x78(%rbp), %rdi
leaq 0x1dde1(%rip), %rsi     # 0x757f7
callq 0x8160
testq %rax, %rax
je 0x57a3f
movq 0x1d28(%rbx), %rax
movq -0x40(%rbp), %rcx
movsd 0x20(%rax,%rcx), %xmm0
xorpd 0x13097(%rip), %xmm0    # 0x6aad0
movlpd %xmm0, 0x20(%rax,%rcx)
movq 0x1d28(%rbx), %rax
movupd (%rbx), %xmm0
movupd %xmm0, (%rax,%r12)
movq 0x1d28(%rbx), %rax
movl -0x44(%rbp), %ecx
movb %cl, 0x10(%rax,%r12)
xorl %eax, %eax
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rsi
movl -0x38(%rbp), %edi
movq 0x1d28(%rbx), %rcx
addq %r12, %rcx
movq %r14, 0x40(%rcx,%rax,8)
movq %r14, 0x28(%rcx,%rax,8)
movl $0x0, 0x54(%rcx,%rax,4)
movb %r14b, 0x16(%rax,%rcx)
movq 0x1d28(%rbx), %rcx
addq %r12, %rcx
movb %r14b, 0x13(%rax,%rcx)
movq 0x1d28(%rbx), %rcx
addq %r12, %rcx
movb %r14b, 0x19(%rax,%rcx)
incq %rax
cmpq $0x2, %rax
jne 0x57a6c
incl -0x34(%rbp)
jmp 0x57b01
movl $0x2, %edi
leaq 0x1dd57(%rip), %rsi     # 0x7581c
xorl %eax, %eax
callq 0x4ded0
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rsi
movl -0x38(%rbp), %edi
jmp 0x57b01
movl $0x2, %edi
leaq 0x1dce3(%rip), %rsi     # 0x757c8
movl -0x40(%rbp), %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4ded0
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rsi
movl -0x38(%rbp), %edi
movq -0x70(%rbp), %r13
incl %edi
movq -0x60(%rbp), %rax
addq $0x1f, %rax
addq $0x1f, %r15
addq $0x1f, %rdx
addq $0x1f, %rsi
addq $0x1f, %r13
cmpl -0x64(%rbp), %edi
jne 0x577e7
jmp 0x57b2d
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %ecx
movl %ecx, 0x1d20(%rbx)
xorl %eax, %eax
testl %ecx, %ecx
setg %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq