// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl 0x9f0c0(%rdi), %edx
leaq 0x33cc5(%rip), %rsi     # 0x6e601
movl $0x4, %edi
xorl %eax, %eax
callq 0x4ded0
movl 0x9f0c0(%rbx), %edx
cmpl $0x9, %edx
jl 0x3ab99
leaq 0x9f0c4(%rbx), %r15
movq %r15, %rdi
movl $0x30, %esi
movl $0x2, %edx
callq 0x4e341
movl %eax, %r14d
movq %r15, -0x60(%rbp)
movq %r15, %rdi
movl $0x34, %esi
movl $0x14, %edx
callq 0x4e341
testb $0x1, %r14b
jne 0x3aba7
movl %eax, %ecx
xorl %eax, %eax
cmpl $0xf, 0x9f0c0(%rbx)
jl 0x3ab91
cmpl $0x3f, 0x30(%rbx)
jg 0x3ab91
movl %ecx, %eax
cvtsi2sd %rax, %xmm0
leaq 0x30(%rbx), %rax
movq %rax, -0x40(%rbp)
movl %r14d, -0x2c(%rbp)
sarl %r14d
mulsd 0x32274(%rip), %xmm0    # 0x6cc40
movsd %xmm0, -0x50(%rbp)
movslq %r14d, %rax
movq %rax, -0x48(%rbp)
movl $0x48, %r13d
movq -0x60(%rbp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl $0x1, %edx
callq 0x4e341
movl %eax, -0x30(%rbp)
leal 0x1(%r13), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x4e341
movl %eax, -0x38(%rbp)
leal 0x2(%r13), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x4e341
movl %eax, %r12d
leal 0x3(%r13), %esi
movq %r14, %rdi
movl $0x5, %edx
callq 0x4e341
movl %eax, %r15d
addl $0x10, %r13d
movq %r14, %rdi
movl %r13d, %esi
movl $0x20, %edx
callq 0x4e341
movl %eax, -0x34(%rbp)
testl %r15d, %r15d
movl $0x20, %eax
cmovel %eax, %r15d
xorl %eax, %eax
testl %r12d, %r12d
setne %al
leal (%rax,%rax,2), %edi
incl %edi
movl %r15d, %esi
callq 0x4dbc5
testl %eax, %eax
je 0x3ab4c
movl %eax, %r14d
movq 0x10(%rbx), %rdi
movsd 0x18(%rbx), %xmm0
movsd -0x50(%rbp), %xmm1
callq 0x4fe63
movq %rax, %r15
movaps %xmm0, %xmm1
testl %r12d, %r12d
je 0x3aaa3
movq %r15, %rdi
movaps %xmm1, %xmm0
callq 0x5040e
movq %rax, %r15
movaps %xmm0, %xmm1
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq %r15, %rsi
movsd %xmm1, -0x58(%rbp)
callq 0x4fe97
cmpl $0x0, 0x9bdd0(%rbx)
jne 0x3aad7
andpd 0x2ee63(%rip), %xmm0    # 0x69930
ucomisd 0x32233(%rip), %xmm0    # 0x6cd08
jbe 0x3aae2
xorl %eax, %eax
movl %eax, 0x9bdd0(%rbx)
movl %eax, 0x30(%rbx)
movq -0x40(%rbp), %rdi
movq %r15, %rsi
movsd -0x58(%rbp), %xmm0
movl %r14d, %edx
callq 0x3adaa
testl %eax, %eax
js 0x3ab65
movl -0x34(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movl %eax, %eax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq 0x38(%rbx), %rax
xorl %ecx, %ecx
cmpl $0x0, -0x38(%rbp)
sete %dl
setne %cl
movb $0x2, %sil
subb %dl, %sil
cmpl $0x0, -0x2c(%rbp)
mulsd 0x312ef(%rip), %xmm0    # 0x6be20
movq -0x48(%rbp), %rdi
movsd %xmm0, 0x38(%rax,%rdi,8)
leal 0xe(%rcx,%rcx,4), %ecx
movzbl %sil, %edx
cmovnel %ecx, %edx
movb %dl, 0x18(%rdi,%rax)
jmp 0x3ab65
movl $0x2, %edi
leaq 0x33b0a(%rip), %rsi     # 0x6e662
movl %r12d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4ded0
movl 0x9f0c0(%rbx), %eax
shll $0x3, %eax
addl $0x50, %r13d
cmpl %eax, %r13d
jg 0x3ab88
addl $-0x30, %r13d
movq -0x40(%rbp), %rax
cmpl $0x3f, (%rax)
jle 0x3a9de
xorl %eax, %eax
cmpl $0x0, -0x30(%rbp)
sete %al
movl %eax, 0x9bdd0(%rbx)
jmp 0x3abc2
leaq 0x33a78(%rip), %rsi     # 0x6e618
movl $0x2, %edi
jmp 0x3abb6
leaq 0x33a89(%rip), %rsi     # 0x6e637
movl $0x2, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq