// File: DoubleString[P]RtConverter/src/Rtklib/rtcm2.cpp
// Function: bamboo::decode_type19(bamboo::rtcm_t*)
static int decode_type19(rtcm_t *rtcm)
{
    gtime_t time;
    double usec,pr,tt;
    int i=48,index,freq,sync=1,code,sys,prn,sat;
    
    trace(4,"decode_type19: len=%d\n",rtcm->len);
    
    if (i+24<=rtcm->len*8) {
        freq=getbitu(rtcm->buff,i, 2); i+= 2+2;
        usec=getbitu(rtcm->buff,i,20); i+=20;
    }
    else {
        trace(2,"rtcm2 19 length error: len=%d\n",rtcm->len);
        return -1;
    }
    if (freq&0x1) {
        trace(2,"rtcm2 19 not supported frequency: freq=%d\n",freq);
        return -1;
    }
    freq>>=1;
    
    while (i+48<=rtcm->len*8&&rtcm->obs.n<MAXOBS) {
        sync=getbitu(rtcm->buff,i, 1); i+= 1;
        code=getbitu(rtcm->buff,i, 1); i+= 1;
        sys =getbitu(rtcm->buff,i, 1); i+= 1;
        prn =getbitu(rtcm->buff,i, 5); i+= 5+8;
        pr  =getbitu(rtcm->buff,i,32); i+=32;
        if (prn==0) prn=32;
        if (!(sat=satno(sys?SYS_GLO:SYS_GPS,prn))) {
            trace(2,"rtcm2 19 satellite number error: sys=%d prn=%d\n",sys,prn);
            continue;
        }
        time=timeadd(rtcm->time,usec*1E-6);
        if (sys) time=utc2gpst(time); /* convert glonass time to gpst */
        
        tt=timediff(rtcm->obs.data[0].time,time);
        if (rtcm->obsflag||fabs(tt)>1E-9) {
            rtcm->obs.n=rtcm->obsflag=0;
        }
        if ((index=obsindex(&rtcm->obs,time,sat))>=0) {
            rtcm->obs.data[index].P[freq]=pr*0.02;
            rtcm->obs.data[index].code[freq]=
                !freq?(code?CODE_L1P:CODE_L1C):(code?CODE_L2P:CODE_L2C);
        }
    }
    rtcm->obsflag=!sync;
    return sync?0:1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x30, -0x3c(%rbp)
movl $0x1, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x4, %edi
leaq 0x536ef(%rip), %rsi     # 0xc0912
movb $0x0, %al
callq 0x8b980
movl -0x3c(%rbp), %eax
addl $0x18, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x6d294
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
movl $0x2, %edx
callq 0x8bfc0
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
movl $0x14, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x3c(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x3c(%rbp)
jmp 0x6d2bd
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
movl $0x2, %edi
leaq 0x5367f(%rip), %rsi     # 0xc0929
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6d66f
movl -0x44(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6d2ea
movl -0x44(%rbp), %edx
movl $0x2, %edi
leaq 0x53671(%rip), %rsi     # 0xc0948
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6d66f
movl -0x44(%rbp), %eax
sarl %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %ecx
addl $0x30, %ecx
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %edx
shll $0x3, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0xc9(%rbp)
jg 0x6d322
movq -0x10(%rbp), %rax
cmpl $0x40, 0x30(%rax)
setl %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x6d331
jmp 0x6d644
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
movl $0x1, %edx
movl %edx, -0xd0(%rbp)
callq 0x8bfc0
movl -0xd0(%rbp), %edx
movl %eax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
incl %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
callq 0x8bfc0
movl -0xd0(%rbp), %edx
movl %eax, -0x4c(%rbp)
movl -0x3c(%rbp), %eax
incl %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
callq 0x8bfc0
movl %eax, -0x50(%rbp)
movl -0x3c(%rbp), %eax
incl %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x54(%rbp)
movl -0x3c(%rbp), %eax
addl $0xd, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x3c(%rbp), %esi
movl $0x20, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x6d400
movl $0x20, -0x54(%rbp)
movl -0x50(%rbp), %ecx
movl $0x1, %edi
movl $0x4, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edi
movl -0x54(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x58(%rbp)
cmpl $0x0, %eax
jne 0x6d441
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
movl $0x2, %edi
leaq 0x5353e(%rip), %rsi     # 0xc0973
movb $0x0, %al
callq 0x8b980
jmp 0x6d2f2
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movsd 0x51973(%rip), %xmm1    # 0xbedd0
mulsd -0x28(%rbp), %xmm1
movq -0x78(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
callq 0x8e860
movq %rax, -0x68(%rbp)
movsd %xmm0, -0x60(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x6d4d8
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rdi
movsd -0x90(%rbp), %xmm0
callq 0x8f0a0
movq %rax, -0x88(%rbp)
movsd %xmm0, -0x80(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
movq -0xb8(%rbp), %rsi
movsd -0xb0(%rbp), %xmm1
callq 0x8e8e0
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x9bdd0(%rax)
jne 0x6d55e
movsd -0x38(%rbp), %xmm0
movaps 0x4fcd4(%rip), %xmm1    # 0xbd220
pand %xmm1, %xmm0
movsd 0x50848(%rip), %xmm1    # 0xbdda0
ucomisd %xmm1, %xmm0
jbe 0x6d577
movq -0x10(%rbp), %rax
movl $0x0, 0x9bdd0(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x58(%rbp), %edx
movq -0xc8(%rbp), %rsi
movsd -0xc0(%rbp), %xmm0
callq 0x6d9f0
movl %eax, -0x40(%rbp)
cmpl $0x0, %eax
jl 0x6d63f
movsd 0x507c8(%rip), %xmm0    # 0xbdd88
mulsd -0x30(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x40(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, 0x38(%rax,%rcx,8)
cmpl $0x0, -0x44(%rbp)
jne 0x6d603
movl -0x4c(%rbp), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0xd4(%rbp)
jmp 0x6d61c
movl -0x4c(%rbp), %edx
movl $0xe, %eax
movl $0x13, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
movb %al, %dl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x40(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x44(%rbp), %rcx
movb %dl, 0x18(%rax,%rcx)
jmp 0x6d2f2
cmpl $0x0, -0x48(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9bdd0(%rax)
movl -0x48(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)