// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/skytraq.cpp
// Function: bamboo::decode_stqraw(bamboo::raw_t*)
static int decode_stqraw(raw_t *raw)
{
    unsigned char *p=raw->buff+4,ind;
    double pr1,cp1;
    int i,j,iod,prn,sys,sat,n=0,nsat;
    
    trace(4,"decode_stqraw: len=%d\n",raw->len);
    
    if (raw->outtype) {
        sprintf(raw->msgtype,"SKYTRAQ RAW   (%4d): nsat=%d",raw->len,U1(p+2));
    }
    iod=U1(p+1);
    if (iod!=raw->iod) { /* need preceding measurement epoch (0xDC) */
        trace(2,"stq raw iod error: iod=%d %d\n",iod,raw->iod);
        return -1;
    }
    nsat=U1(p+2);
    if (raw->len<8+23*nsat) {
        trace(2,"stq raw length error: len=%d nsat=%d\n",raw->len,nsat);
        return -1;
    }
    for (i=0,p+=3;i<nsat&&i<MAXOBS;i++,p+=23) {
        prn=U1(p);
        
        if (MINPRNGPS<=prn&&prn<=MAXPRNGPS) {
            sys=SYS_GPS;
        }
        else if (MINPRNGLO<=prn-64&&prn-64<=MAXPRNGLO) {
            sys=SYS_GLO;
            prn-=64;
        }
        else if (MINPRNQZS<=prn&&prn<=MAXPRNQZS) {
            sys=SYS_QZS;
        }
        else if (MINPRNCMP<=prn-200&&prn-200<=MAXPRNCMP) {
            sys=SYS_CMP;
            prn-=200;
        }
        else {
            trace(2,"stq raw satellite number error: prn=%d\n",prn);
            continue;
        }
        if (!(sat=satno(sys,prn))) {
            trace(2,"stq raw satellite number error: sys=%d prn=%d\n",sys,prn);
            continue;
        }
        ind=U1(p+22);
        pr1=!(ind&1)?0.0:R8(p+ 2);
        cp1=!(ind&4)?0.0:R8(p+10);
        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+18);
        raw->obs.data[n].SNR[0]=U1(p+1)*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 0x1efa8(%rip), %rsi     # 0x756e0
movl $0x4, %edi
xorl %eax, %eax
callq 0x4d55d
cmpl $0x0, 0x81a8c(%rbx)
je 0x5676f
leaq 0x70e70(%rbx), %rdi
movl 0x81a78(%rbx), %edx
movzbl 0x81a96(%rbx), %ecx
leaq 0x1ef8f(%rip), %rsi     # 0x756f7
xorl %eax, %eax
callq 0x8120
movzbl 0x81a95(%rbx), %edx
movl 0x81a7c(%rbx), %ecx
cmpl %edx, %ecx
jne 0x567aa
movzbl 0x81a96(%rbx), %ecx
movl 0x81a78(%rbx), %edx
leal (%rcx,%rcx,2), %eax
shll $0x3, %eax
subl %ecx, %eax
addl $0x8, %eax
cmpl %eax, %edx
jge 0x567c7
leaq 0x1ef8f(%rip), %rsi     # 0x75732
movl $0x2, %edi
jmp 0x567b6
leaq 0x1ef63(%rip), %rsi     # 0x75714
movl $0x2, %edi
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x56b36
cmpl $0x40, %ecx
movl $0x40, %eax
cmovbl %ecx, %eax
movl %eax, -0x64(%rbp)
testl %ecx, %ecx
je 0x56b1f
leaq 0x81a97(%rbx), %rdi
leaq 0x7f670(%rbx), %rax
movq %rax, -0x80(%rbp)
leaq 0x82a90(%rbx), %rax
movq %rax, -0x78(%rbp)
leaq 0x81a99(%rbx), %rdx
leaq 0x81aa1(%rbx), %rsi
leaq 0x81aa9(%rbx), %r12
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
xorl %ecx, %ecx
movq %rdx, -0x50(%rbp)
movq %rdi, -0x58(%rbp)
movzbl (%rdi), %r15d
leal -0x1(%r15), %eax
movl $0x1, %r14d
cmpb $0x20, %al
movq %rsi, -0x48(%rbp)
movl %ecx, -0x34(%rbp)
jae 0x56842
movb $0x1, -0x29(%rbp)
jmp 0x5688b
leal -0x41(%r15), %eax
cmpb $0x1b, %al
jae 0x5685a
movb $0x1, -0x29(%rbp)
addl $-0x40, %r15d
movl $0x4, %r14d
jmp 0x5688b
testl %r15d, %r15d
je 0x5687e
leal 0x37(%r15), %eax
cmpb $0x25, %al
jae 0x56b07
addl $0xffffff38, %r15d      # imm = 0xFFFFFF38
movl $0x20, %r14d
movb $0x2f, -0x29(%rbp)
jmp 0x5688b
movb $0x1, -0x29(%rbp)
movl $0x10, %r14d
xorl %r15d, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x4d28d
movq %rax, -0x70(%rbp)
testl %eax, %eax
je 0x56ac2
movq -0x58(%rbp), %r14
movzbl 0x16(%r14), %edi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
testb $0x1, %dil
movq -0x50(%rbp), %rsi
je 0x568d8
xorl %eax, %eax
leaq -0x39(%rbp), %rcx
movb (%rsi,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x568c3
movsd -0x40(%rbp), %xmm1
movsd %xmm1, -0x60(%rbp)
movl %edi, %r15d
testb $0x4, %dil
je 0x56905
xorl %eax, %eax
leaq -0x39(%rbp), %rcx
movq -0x48(%rbp), %rsi
movb (%rsi,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x568f0
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
addsd 0x1e27b(%rip), %xmm0    # 0x74b90
movsd 0x1ec4b(%rip), %xmm1    # 0x75568
divsd %xmm1, %xmm0
callq 0x8ac0
mulsd 0x1ec3a(%rip), %xmm0    # 0x75568
movsd -0x88(%rbp), %xmm1
subsd %xmm0, %xmm1
movq 0x1d28(%rbx), %rax
movslq -0x30(%rbp), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rdx
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x38(%rax,%rdx)
movq %rdx, -0x60(%rbp)
movsd %xmm1, 0x20(%rax,%rdx)
xorpd %xmm0, %xmm0
movl %r15d, %r8d
testb $0x2, %r8b
je 0x5698c
xorl %edx, %edx
leaq -0x3d(%rbp), %rsi
movb (%r12,%rdx), %dil
movb %dil, (%rsi)
decq %rsi
incq %rdx
cmpl $0x4, %edx
jne 0x56975
movss -0x40(%rbp), %xmm0
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %r15
movss %xmm0, 0x50(%rax,%r15)
movb 0x1(%r14), %cl
shlb $0x2, %cl
movb %cl, 0x12(%rax,%r15)
movq 0x1d28(%rbx), %rax
movb $0x0, 0x15(%rax,%r15)
movq 0x1d28(%rbx), %rax
movb -0x29(%rbp), %cl
movb %cl, 0x18(%rax,%r15)
shrl $0x3, %r8d
andl $0x1, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r8d, %xmm0
movq -0x70(%rbp), %rax
decl %eax
cltq
leaq (%rax,%rax,2), %rax
movq -0x80(%rbp), %rcx
movsd %xmm0, (%rcx,%rax,8)
movq 0x1d28(%rbx), %r14
movsd 0x20(%r14,%r15), %xmm0
ucomisd 0x13f0a(%rip), %xmm0    # 0x6a908
jne 0x56a02
jnp 0x56a1b
leaq (%rcx,%rax,8), %rax
addq %r15, %r14
movb %r8b, 0x15(%r14)
movq $0x0, (%rax)
movq 0x1d28(%rbx), %r14
movq -0x78(%rbp), %rdi
leaq 0x1ed89(%rip), %rsi     # 0x757af
callq 0x8160
testq %rax, %rax
je 0x56a4a
movq -0x60(%rbp), %rax
movsd 0x20(%r14,%rax), %xmm0
xorpd 0x1408d(%rip), %xmm0    # 0x6aad0
movlpd %xmm0, 0x20(%r14,%rax)
movupd (%rbx), %xmm0
movupd %xmm0, (%r14,%r15)
movq 0x1d28(%rbx), %rax
movq -0x70(%rbp), %rcx
movb %cl, 0x10(%rax,%r15)
xorl %eax, %eax
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rsi
movq 0x1d28(%rbx), %rcx
addq %r15, %rcx
movq %r13, 0x40(%rcx,%rax,8)
movq %r13, 0x28(%rcx,%rax,8)
movl $0x0, 0x54(%rcx,%rax,4)
movb %r13b, 0x16(%rax,%rcx)
movq 0x1d28(%rbx), %rcx
addq %r15, %rcx
movb %r13b, 0x13(%rax,%rcx)
movq 0x1d28(%rbx), %rcx
addq %r15, %rcx
movb %r13b, 0x19(%rax,%rcx)
incq %rax
cmpq $0x2, %rax
jne 0x56a6e
incl -0x30(%rbp)
movq -0x58(%rbp), %rdi
movl -0x34(%rbp), %ecx
jmp 0x56aea
movl $0x2, %edi
leaq 0x1ecb2(%rip), %rsi     # 0x75780
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rsi
movl -0x34(%rbp), %ecx
movq -0x58(%rbp), %rdi
incl %ecx
addq $0x17, %rdi
addq $0x17, %rdx
addq $0x17, %rsi
addq $0x17, %r12
cmpl -0x64(%rbp), %ecx
jne 0x5681b
jmp 0x56b26
movl $0x2, %edi
leaq 0x1ec45(%rip), %rsi     # 0x75758
movl %r15d, %edx
xorl %eax, %eax
callq 0x4d55d
jmp 0x56adb
movl $0x0, -0x30(%rbp)
movl -0x30(%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