// File: DoubleString[P]RtConverter/src/Rtklib/ublox.cpp
// Function: bamboo::decode_rxmraw(bamboo::raw_t*)
static int decode_rxmraw(raw_t *raw)
{
    gtime_t time;
    double tow,tt,tadj=0.0,toff=0.0,tn;
    int i,j,prn,sat,n=0,nsat,week;
    unsigned char *p=raw->buff+6;
    char *q;
    
    trace(4,"decode_rxmraw: len=%d\n",raw->len);
    
    if (raw->outtype) {
        sprintf(raw->msgtype,"UBX RXM-RAW   (%4d): nsat=%d",raw->len,U1(p+6));
    }
    /* time tag adjustment option (-TADJ) */
    if ((q=strstr(raw->opt,"-TADJ="))) {
        sscanf(q,"-TADJ=%lf",&tadj);
    }
    nsat=U1(p+6);
    if (raw->len<12+24*nsat) {
        trace(2,"ubx rxmraw length error: len=%d nsat=%d\n",raw->len,nsat);
        return -1;
    }
    tow =U4(p  );
    week=U2(p+4);
    time=gpst2time(week,tow*0.001);
    
    if (week==0) {
        trace(3,"ubx rxmraw week=0 error: len=%d nsat=%d\n",raw->len,nsat);
        return 0;
    }
    /* time tag adjustment */
    if (tadj>0.0) {
        tn=time2gpst(time,&week)/tadj;
        toff=(tn-floor(tn+0.5))*tadj;
        time=timeadd(time,-toff);
    }
    tt=timediff(time,raw->time);
    
    for (i=0,p+=8;i<nsat&&i<MAXOBS;i++,p+=24) {
        raw->obs.data[n].time=time;
        raw->obs.data[n].L[0]  =R8(p   )-toff*FREQ1;
        raw->obs.data[n].P[0]  =R8(p+ 8)-toff*CLIGHT;
        raw->obs.data[n].D[0]  =R4(p+16);
        prn                    =U1(p+20);
        raw->obs.data[n].SNR[0]=(unsigned char)(I1(p+22)*4.0+0.5);
        raw->obs.data[n].LLI[0]=U1(p+23);
        raw->obs.data[n].code[0]=CODE_L1C;
        
        /* phase polarity flip option (-INVCP) */
        if (strstr(raw->opt,"-INVCP")) {
            raw->obs.data[n].L[0]=-raw->obs.data[n].L[0];
        }
        if (!(sat=satno(MINPRNSBS<=prn?SYS_SBS:SYS_GPS,prn))) {
            trace(2,"ubx rxmraw sat number error: prn=%d\n",prn);
            continue;
        }
        raw->obs.data[n].sat=sat;
        
        if (raw->obs.data[n].LLI[0]&1) raw->lockt[sat-1][0]=0.0;
        else if (tt<1.0||10.0<tt) raw->lockt[sat-1][0]=0.0;
        else raw->lockt[sat-1][0]+=tt;
        
        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->time=time;
    raw->obs.n=n;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x10(%rbp), %rax
addq $0x81a90, %rax          # imm = 0x81A90
addq $0x6, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl $0x4, %edi
leaq 0x22029(%rip), %rsi     # 0xcb8f7
movb $0x0, %al
callq 0x8b980
movq -0x10(%rbp), %rax
cmpl $0x0, 0x81a8c(%rax)
je 0xa990d
movq -0x10(%rbp), %rdi
addq $0x70e70, %rdi          # imm = 0x70E70
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movq -0x70(%rbp), %rax
movzbl 0x6(%rax), %ecx
leaq 0x22008(%rip), %rsi     # 0xcb90e
movb $0x0, %al
callq 0x9150
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x2200c(%rip), %rsi     # 0xcb92b
callq 0x91b0
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0xa9944
movq -0x78(%rbp), %rdi
leaq 0x21ff9(%rip), %rsi     # 0xcb932
leaq -0x38(%rbp), %rdx
movb $0x0, %al
callq 0x9750
movq -0x70(%rbp), %rax
movzbl 0x6(%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %eax
imull $0x18, -0x60(%rbp), %ecx
addl $0xc, %ecx
cmpl %ecx, %eax
jge 0xa9990
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl -0x60(%rbp), %ecx
movl $0x2, %edi
leaq 0x21fbf(%rip), %rsi     # 0xcb93c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xa9f98
movq -0x70(%rbp), %rdi
callq 0xac7b0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x70(%rbp), %rdi
addq $0x4, %rdi
callq 0xa8920
movzwl %ax, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %edi
movsd 0x14385(%rip), %xmm0    # 0xbdd48
mulsd -0x28(%rbp), %xmm0
callq 0x8e4a0
movq %rax, -0x88(%rbp)
movsd %xmm0, -0x80(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0xa9a1e
movq -0x10(%rbp), %rax
movl 0x81a78(%rax), %edx
movl -0x60(%rbp), %ecx
movl $0x3, %edi
leaq 0x21f5a(%rip), %rsi     # 0xcb965
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x4(%rbp)
jmp 0xa9f98
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa9b0b
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rdi
movsd -0x90(%rbp), %xmm0
leaq -0x64(%rbp), %rsi
callq 0x8e540
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd 0x13403(%rip), %xmm0    # 0xbce80
addsd -0x48(%rbp), %xmm0
callq 0x9c90
movaps %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
subsd %xmm1, %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movq -0xb8(%rbp), %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x8e860
movq %rax, -0xa8(%rbp)
movsd %xmm0, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0xd8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
movsd -0xc0(%rbp), %xmm0
movq -0xd8(%rbp), %rsi
movsd -0xd0(%rbp), %xmm1
callq 0x8e8e0
movsd %xmm0, -0x30(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x70(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x70(%rbp)
movl -0x4c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x60(%rbp), %ecx
movb %al, -0xe1(%rbp)
jge 0xa9b92
cmpl $0x40, -0x4c(%rbp)
setl %al
movb %al, -0xe1(%rbp)
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0xa9ba1
jmp 0xa9f71
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
movups -0x20(%rbp), %xmm0
movups %xmm0, (%rax,%rcx)
movq -0x70(%rbp), %rdi
callq 0xac7d0
movsd -0x40(%rbp), %xmm1
movsd 0x21b8a(%rip), %xmm2    # 0xcb760
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
movsd %xmm0, 0x20(%rax,%rcx)
movq -0x70(%rbp), %rdi
addq $0x8, %rdi
callq 0xac7d0
movsd -0x40(%rbp), %xmm1
movsd 0x21b53(%rip), %xmm2    # 0xcb768
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
movsd %xmm0, 0x38(%rax,%rcx)
movq -0x70(%rbp), %rdi
addq $0x10, %rdi
callq 0xac7f0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
movss %xmm0, 0x50(%rax,%rcx)
movq -0x70(%rbp), %rax
movzbl 0x14(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x70(%rbp), %rax
movsbl 0x16(%rax), %eax
cvtsi2sd %eax, %xmm0
movsd 0x1316d(%rip), %xmm1    # 0xbcdf0
mulsd %xmm1, %xmm0
movsd 0x131f1(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x12(%rax)
movq -0x70(%rbp), %rax
movb 0x17(%rax), %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x15(%rax)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movb $0x1, 0x18(%rax)
movq -0x10(%rbp), %rdi
addq $0x82a90, %rdi          # imm = 0x82A90
leaq 0x1e859(%rip), %rsi     # 0xc8557
callq 0x91b0
cmpq $0x0, %rax
je 0xa9d56
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd 0x20(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movl -0x54(%rbp), %edx
movl $0x78, %ecx
movl $0x1, %edi
movl $0x2, %eax
cmpl %edx, %ecx
cmovlel %eax, %edi
movl -0x54(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x58(%rbp)
cmpl $0x0, %eax
jne 0xa9d98
movl -0x54(%rbp), %edx
movl $0x2, %edi
leaq 0x21c02(%rip), %rsi     # 0xcb98e
movb $0x0, %al
callq 0x8b980
jmp 0xa9f57
movl -0x58(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x15(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xa9dfb
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xa9e69
movsd 0x1205d(%rip), %xmm0    # 0xbbe60
ucomisd -0x30(%rbp), %xmm0
ja 0xa9e1d
movsd -0x30(%rbp), %xmm0
movsd 0x131e9(%rip), %xmm1    # 0xbd000
ucomisd %xmm1, %xmm0
jbe 0xa9e40
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0xa9e67
movsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x7f670, %rax          # imm = 0x7F670
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0xa9e69
movl $0x1, -0x50(%rbp)
cmpl $0x3, -0x50(%rbp)
jge 0xa9f4e
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x38(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, 0x50(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movb $0x0, 0x15(%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movb $0x0, 0x12(%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x1d28(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x50(%rbp), %rcx
movb $0x0, 0x18(%rax,%rcx)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0xa9e70
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movq -0x70(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
jmp 0xa9b75
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x5c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1d20(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)