// File: 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
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x4, %edi
leaq 0x2d86d(%rip), %rsi     # 0xc8488
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0x9ac5a
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %ecx
leaq 0x2d84c(%rip), %rsi     # 0xc849f
movb $0x0, %al
callq 0x9150
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x81a7c(%rcx), %eax
je 0x9aca0
movl -0x3c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x81a7c(%rax), %ecx
movl $0x2, %edi
leaq 0x2d82f(%rip), %rsi     # 0xc84bc
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9b230
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %eax
imull $0x17, -0x50(%rbp), %ecx
addl $0x8, %ecx
cmpl %ecx, %eax
jge 0x9acec
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl -0x50(%rbp), %ecx
movl $0x2, %edi
leaq 0x2d801(%rip), %rsi     # 0xc84da
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9b230
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x18(%rbp)
movl -0x34(%rbp), %ecx
xorl %eax, %eax
cmpl -0x50(%rbp), %ecx
movb %al, -0x51(%rbp)
jge 0x9ad16
cmpl $0x40, -0x34(%rbp)
setl %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x9ad22
jmp 0x9b210
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x40(%rbp)
movl $0x1, %eax
cmpl -0x40(%rbp), %eax
jg 0x9ad48
cmpl $0x20, -0x40(%rbp)
jg 0x9ad48
movl $0x1, -0x44(%rbp)
jmp 0x9adde
movl -0x40(%rbp), %ecx
subl $0x40, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jg 0x9ad74
movl -0x40(%rbp), %eax
subl $0x40, %eax
cmpl $0x1b, %eax
jg 0x9ad74
movl $0x4, -0x44(%rbp)
movl -0x40(%rbp), %eax
subl $0x40, %eax
movl %eax, -0x40(%rbp)
jmp 0x9addc
xorl %eax, %eax
cmpl -0x40(%rbp), %eax
jg 0x9ad8a
cmpl $0x0, -0x40(%rbp)
jg 0x9ad8a
movl $0x10, -0x44(%rbp)
jmp 0x9adda
movl -0x40(%rbp), %ecx
subl $0xc8, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jg 0x9adbd
movl -0x40(%rbp), %eax
subl $0xc8, %eax
cmpl $0x25, %eax
jg 0x9adbd
movl $0x20, -0x44(%rbp)
movl -0x40(%rbp), %eax
subl $0xc8, %eax
movl %eax, -0x40(%rbp)
jmp 0x9add8
movl -0x40(%rbp), %edx
movl $0x2, %edi
leaq 0x2d734(%rip), %rsi     # 0xc8500
movb $0x0, %al
callq 0x8b980
jmp 0x9b1f6
jmp 0x9adda
jmp 0x9addc
jmp 0x9adde
movl -0x44(%rbp), %edi
movl -0x40(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x48(%rbp)
cmpl $0x0, %eax
jne 0x9ae0f
movl -0x44(%rbp), %edx
movl -0x40(%rbp), %ecx
movl $0x2, %edi
leaq 0x2d725(%rip), %rsi     # 0xc8528
movb $0x0, %al
callq 0x8b980
jmp 0x9b1f6
movq -0x18(%rbp), %rax
movb 0x16(%rax), %al
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x9ae2f
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x9ae41
movq -0x18(%rbp), %rdi
addq $0x2, %rdi
callq 0x9c910
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movzbl -0x19(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x9ae61
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x9ae73
movq -0x18(%rbp), %rdi
addq $0xa, %rdi
callq 0x9c910
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x2c563(%rip), %xmm0    # 0xc73e8
addsd -0x30(%rbp), %xmm0
movsd 0x2d46e(%rip), %xmm1    # 0xc8300
divsd %xmm1, %xmm0
callq 0x9c90
movsd -0x30(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x2d441(%rip), %xmm2    # 0xc8300
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movzbl -0x19(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x9af22
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x9af38
movq -0x18(%rbp), %rdi
addq $0x12, %rdi
callq 0x9c970
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movss %xmm0, 0x50(%rax)
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
shll $0x2, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x12(%rax)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x15(%rax)
movl -0x44(%rbp), %edx
movl $0x1, %eax
movl $0x2f, %ecx
cmpl $0x20, %edx
cmovel %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x18(%rax)
movzbl -0x19(%rbp), %edx
andl $0x8, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9b028
jp 0x9b028
jmp 0x9b07d
movq -0x10(%rbp), %rax
movl -0x48(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
cvttsd2si 0x7f670(%rax,%rcx,8), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x15(%rax)
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x2d4c8(%rip), %rsi     # 0xc8557
callq 0x91b0
cmpq $0x0, %rax
je 0x9b0c2
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd 0x23d20(%rip), %xmm0    # 0xbedd8
mulsd 0x20(%rax), %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl -0x48(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x10(%rax)
movl $0x1, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x9b1ed
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, 0x50(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movb $0x0, 0x15(%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movb $0x0, 0x12(%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movb $0x0, 0x18(%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x9b10f
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
addq $0x17, %rax
movq %rax, -0x18(%rbp)
jmp 0x9acff
movl -0x4c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1d20(%rax)
movl -0x4c(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)