// File: /workspace/github_cpp_makefile_star2_O1/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 0x1e4bb(%rip), %rsi     # 0x75728
movl $0x4, %edi
xorl %eax, %eax
callq 0x4ded0
cmpl $0x0, 0x81a8c(%rbx)
je 0x572a4
leaq 0x70e70(%rbx), %rdi
movl 0x81a78(%rbx), %edx
movzbl 0x81a96(%rbx), %ecx
leaq 0x1e4a2(%rip), %rsi     # 0x7573f
xorl %eax, %eax
callq 0x8120
movzbl 0x81a95(%rbx), %edx
movl 0x81a7c(%rbx), %ecx
cmpl %edx, %ecx
jne 0x572df
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 0x572fc
leaq 0x1e4a2(%rip), %rsi     # 0x7577a
movl $0x2, %edi
jmp 0x572eb
leaq 0x1e476(%rip), %rsi     # 0x7575c
movl $0x2, %edi
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5766b
cmpl $0x40, %ecx
movl $0x40, %eax
cmovbl %ecx, %eax
movl %eax, -0x64(%rbp)
testl %ecx, %ecx
je 0x57654
leaq 0x81a97(%rbx), %rcx
leaq 0x7f670(%rbx), %rax
movq %rax, -0x80(%rbp)
leaq 0x82a90(%rbx), %rax
movq %rax, -0x78(%rbp)
leaq 0x81a99(%rbx), %rdx
leaq 0x81aa1(%rbx), %r14
leaq 0x81aa9(%rbx), %r12
xorl %r13d, %r13d
movl $0x0, -0x30(%rbp)
xorl %esi, %esi
movq %r14, -0x58(%rbp)
movq %rdx, -0x48(%rbp)
movzbl (%rcx), %r15d
leal -0x1(%r15), %eax
movl $0x1, %r14d
cmpb $0x20, %al
movq %rcx, -0x60(%rbp)
movl %esi, -0x34(%rbp)
jae 0x57377
movb $0x1, -0x29(%rbp)
jmp 0x573c0
leal -0x41(%r15), %eax
cmpb $0x1b, %al
jae 0x5738f
movb $0x1, -0x29(%rbp)
addl $-0x40, %r15d
movl $0x4, %r14d
jmp 0x573c0
testl %r15d, %r15d
je 0x573b3
leal 0x37(%r15), %eax
cmpb $0x25, %al
jae 0x5763c
addl $0xffffff38, %r15d      # imm = 0xFFFFFF38
movl $0x20, %r14d
movb $0x2f, -0x29(%rbp)
jmp 0x573c0
movb $0x1, -0x29(%rbp)
movl $0x10, %r14d
xorl %r15d, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x4dbc5
movq %rax, -0x70(%rbp)
testl %eax, %eax
je 0x575f7
movq -0x60(%rbp), %rax
movzbl 0x16(%rax), %edi
xorpd %xmm0, %xmm0
xorpd %xmm1, %xmm1
testb $0x1, %dil
movq -0x48(%rbp), %rsi
movq -0x58(%rbp), %r14
je 0x57410
xorl %eax, %eax
leaq -0x39(%rbp), %rcx
movb (%rsi,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x573fb
movsd -0x40(%rbp), %xmm1
movsd %xmm1, -0x50(%rbp)
movl %edi, %r15d
testb $0x4, %dil
je 0x5743a
xorl %eax, %eax
leaq -0x39(%rbp), %rcx
movb (%r14,%rax), %dl
movb %dl, (%rcx)
decq %rcx
incq %rax
cmpl $0x8, %eax
jne 0x57424
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
addsd 0x1d766(%rip), %xmm0    # 0x74bb0
movsd 0x1e15e(%rip), %xmm1    # 0x755b0
divsd %xmm1, %xmm0
callq 0x8ad0
mulsd 0x1e14d(%rip), %xmm0    # 0x755b0
movsd -0x88(%rbp), %xmm1
subsd %xmm0, %xmm1
movq 0x1d28(%rbx), %rax
movslq -0x30(%rbp), %rcx
leaq (%rcx,%rcx,2), %rdx
shlq $0x5, %rdx
movsd -0x50(%rbp), %xmm0
movsd %xmm0, 0x38(%rax,%rdx)
movq %rdx, -0x50(%rbp)
movsd %xmm1, 0x20(%rax,%rdx)
xorpd %xmm0, %xmm0
movl %r15d, %r8d
testb $0x2, %r8b
je 0x574c1
xorl %edx, %edx
leaq -0x3d(%rbp), %rsi
movb (%r12,%rdx), %dil
movb %dil, (%rsi)
decq %rsi
incq %rdx
cmpl $0x4, %edx
jne 0x574aa
movss -0x40(%rbp), %xmm0
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %r15
movss %xmm0, 0x50(%rax,%r15)
movq -0x60(%rbp), %rcx
movb 0x1(%rcx), %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), %rcx
movq -0x80(%rbp), %rdx
movsd %xmm0, (%rdx,%rcx,8)
movq 0x1d28(%rbx), %rax
movsd 0x20(%rax,%r15), %xmm0
ucomisd 0x133d2(%rip), %xmm0    # 0x6a908
jne 0x5753a
jnp 0x5754c
leaq (%rdx,%rcx,8), %rcx
addq %r15, %rax
movb %r8b, 0x15(%rax)
movq $0x0, (%rcx)
movq -0x78(%rbp), %rdi
leaq 0x1e2a0(%rip), %rsi     # 0x757f7
callq 0x8160
testq %rax, %rax
je 0x57580
movq 0x1d28(%rbx), %rax
movq -0x50(%rbp), %rcx
movsd 0x20(%rax,%rcx), %xmm0
xorpd 0x13556(%rip), %xmm0    # 0x6aad0
movlpd %xmm0, 0x20(%rax,%rcx)
movq 0x1d28(%rbx), %rax
movupd (%rbx), %xmm0
movupd %xmm0, (%rax,%r15)
movq 0x1d28(%rbx), %rax
movq -0x70(%rbp), %rcx
movb %cl, 0x10(%rax,%r15)
xorl %eax, %eax
movq -0x48(%rbp), %rdx
movl -0x34(%rbp), %esi
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 0x575aa
incl -0x30(%rbp)
jmp 0x5761b
movl $0x2, %edi
leaq 0x1e1c5(%rip), %rsi     # 0x757c8
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4ded0
movq -0x48(%rbp), %rdx
movl -0x34(%rbp), %esi
movq -0x58(%rbp), %r14
incl %esi
movq -0x60(%rbp), %rcx
addq $0x17, %rcx
addq $0x17, %rdx
addq $0x17, %r14
addq $0x17, %r12
cmpl -0x64(%rbp), %esi
jne 0x57350
jmp 0x5765b
movl $0x2, %edi
leaq 0x1e158(%rip), %rsi     # 0x757a0
movl %r15d, %edx
xorl %eax, %eax
callq 0x4ded0
jmp 0x57610
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