// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1004(bamboo::rtcm_t*)
static int decode_type1004(rtcm_t *rtcm)
{
    const int L2codes[]={CODE_L2X,CODE_L2P,CODE_L2D,CODE_L2W};
    double pr1,cnr1,cnr2,tt,cp1,cp2;
    int i=24+64,j,index,nsat,sync,prn,sat,code1,code2,pr21,ppr1,ppr2;
    int lock1,lock2,amb,sys;
    
    if ((nsat=decode_head1001(rtcm,&sync))<0) return -1;
    
    for (j=0;j<nsat&&rtcm->obs.n<MAXOBS&&i+125<=rtcm->len*8;j++) {
        prn  =getbitu(rtcm->buff,i, 6); i+= 6;
        code1=getbitu(rtcm->buff,i, 1); i+= 1;
        pr1  =getbitu(rtcm->buff,i,24); i+=24;
        ppr1 =getbits(rtcm->buff,i,20); i+=20;
        lock1=getbitu(rtcm->buff,i, 7); i+= 7;
        amb  =getbitu(rtcm->buff,i, 8); i+= 8;
        cnr1 =getbitu(rtcm->buff,i, 8); i+= 8;
        code2=getbitu(rtcm->buff,i, 2); i+= 2;
        pr21 =getbits(rtcm->buff,i,14); i+=14;
        ppr2 =getbits(rtcm->buff,i,20); i+=20;
        lock2=getbitu(rtcm->buff,i, 7); i+= 7;
        cnr2 =getbitu(rtcm->buff,i, 8); i+= 8;
        if (prn<40) {
            sys=SYS_GPS;
        }
        else {
            sys=SYS_SBS; prn+=80;
        }
        if (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 1004 satellite number error: sys=%d prn=%d\n",sys,prn);
            continue;
        }
        tt=timediff(rtcm->obs.data[0].time,rtcm->time);
        if (rtcm->obsflag||fabs(tt)>1E-9) {
            rtcm->obs.n=rtcm->obsflag=0;
        }
        if ((index=obsindex(&rtcm->obs,rtcm->time,sat))<0) continue;
        pr1=pr1*0.02+amb*PRUNIT_GPS;
        if (ppr1!=(int)0xFFF80000) {
            rtcm->obs.data[index].P[0]=pr1;
            cp1=adjcp(rtcm,sat,0,ppr1*0.0005/lam_carr[0]);
            rtcm->obs.data[index].L[0]=pr1/lam_carr[0]+cp1;
        }
        rtcm->obs.data[index].LLI[0]=lossoflock(rtcm,sat,0,lock1);
        rtcm->obs.data[index].SNR[0]=snratio(cnr1*0.25);
        rtcm->obs.data[index].code[0]=code1?CODE_L1P:CODE_L1C;
        
        if (pr21!=(int)0xFFFFE000) {
            rtcm->obs.data[index].P[1]=pr1+pr21*0.02;
        }
        if (ppr2!=(int)0xFFF80000) {
            cp2=adjcp(rtcm,sat,1,ppr2*0.0005/lam_carr[1]);
            rtcm->obs.data[index].L[1]=pr1/lam_carr[1]+cp2;
        }
        rtcm->obs.data[index].LLI[1]=lossoflock(rtcm,sat,1,lock2);
        rtcm->obs.data[index].SNR[1]=snratio(cnr2*0.25);
        rtcm->obs.data[index].code[1]=L2codes[code2];
    }
    rtcm->obsflag=!sync;
    return sync?0:1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq -0x6c(%rbp), %rsi
callq 0x42e21
testl %eax, %eax
js 0x3bda0
je 0x3bd8e
leaq 0x30(%r14), %rcx
movq %rcx, -0x80(%rbp)
leaq 0x9f0c4(%r14), %r12
leaq 0x9bdd8(%r14), %rcx
movq %rcx, -0x30(%rbp)
leaq 0x9cc60(%r14), %rcx
movq %rcx, -0x38(%rbp)
movl $0xd5, %ebx
movq %r14, -0x78(%rbp)
movq -0x80(%rbp), %rcx
cmpl $0x3f, (%rcx)
jg 0x3bd8e
movl 0x9f0c0(%r14), %ecx
shll $0x3, %ecx
cmpl %ecx, %ebx
jg 0x3bd8e
movl %eax, -0x68(%rbp)
leal -0x7d(%rbx), %esi
movq %r12, %rdi
movl $0x6, %edx
callq 0x4e341
movl %eax, %r13d
leal -0x77(%rbx), %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x4e341
movl %eax, -0x58(%rbp)
leal -0x76(%rbx), %esi
movq %r12, %rdi
movl $0x18, %edx
callq 0x4e341
movl %eax, -0x40(%rbp)
leal -0x5e(%rbx), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4e390
movl %eax, -0x44(%rbp)
leal -0x4a(%rbx), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4e341
movl %eax, -0x50(%rbp)
leal -0x43(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x3c(%rbp)
leal -0x3b(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x48(%rbp)
leal -0x33(%rbx), %esi
movq %r12, %rdi
movl $0x2, %edx
callq 0x4e341
movl %eax, -0x64(%rbp)
leal -0x31(%rbx), %esi
movq %r12, %rdi
movl $0xe, %edx
callq 0x4e390
movl %eax, -0x4c(%rbp)
leal -0x23(%rbx), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4e390
movl %eax, -0x54(%rbp)
leal -0xf(%rbx), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4e341
movl %eax, -0x60(%rbp)
leal -0x8(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x5c(%rbp)
leal 0x50(%r13), %r15d
xorl %r14d, %r14d
cmpl $0x28, %r13d
setge %r14b
cmovll %r13d, %r15d
incl %r14d
movl %r14d, %edi
movl %r15d, %esi
callq 0x4dbc5
testl %eax, %eax
je 0x3baec
movl %eax, %r13d
movq -0x78(%rbp), %r14
movq 0x38(%r14), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%r14), %rsi
movsd 0x18(%r14), %xmm1
callq 0x4fe97
cmpl $0x0, 0x9bdd0(%r14)
jne 0x3ba1d
andpd 0x2df1d(%rip), %xmm0    # 0x69930
ucomisd 0x312ed(%rip), %xmm0    # 0x6cd08
jbe 0x3ba2a
xorl %eax, %eax
movl %eax, 0x9bdd0(%r14)
movl %eax, 0x30(%r14)
movq 0x10(%r14), %rsi
movsd 0x18(%r14), %xmm0
movq -0x80(%rbp), %rdi
movl %r13d, %edx
callq 0x430c2
testl %eax, %eax
js 0x3bd77
movl -0x40(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl -0x3c(%rbp), %xmm1
mulsd 0x3339d(%rip), %xmm1    # 0x6ee00
mulsd 0x303b5(%rip), %xmm0    # 0x6be20
addsd %xmm1, %xmm0
movl %eax, %eax
movl -0x44(%rbp), %esi
cmpl $0xfff80000, %esi       # imm = 0xFFF80000
je 0x3bb42
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rdx
shlq $0x5, %rdx
movsd %xmm0, 0x38(%rcx,%rdx)
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x33367(%rip), %xmm1    # 0x6ee08
leaq 0x35168(%rip), %rsi     # 0x70c10
movsd (%rsi), %xmm2
divsd %xmm2, %xmm1
leal -0x1(%r13), %esi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
movq -0x30(%rbp), %rdi
movsd (%rdi,%rsi,8), %xmm3
ucomisd 0x2ee3c(%rip), %xmm3    # 0x6a908
jne 0x3bad0
jnp 0x3bb24
movapd %xmm3, %xmm4
addsd 0x33334(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3bb0e
addsd 0x3333e(%rip), %xmm1    # 0x6ee28
jmp 0x3bb24
movl $0x2, %edi
leaq 0x33511(%rip), %rsi     # 0x6f009
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4ded0
movq -0x78(%rbp), %r14
jmp 0x3bd77
addsd 0x33302(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3bb24
addsd 0x332fc(%rip), %xmm1    # 0x6ee20
movq -0x30(%rbp), %rdi
leaq (%rdi,%rsi,8), %rsi
movsd %xmm1, (%rsi)
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movsd %xmm3, 0x20(%rcx,%rdx)
movl -0x50(%rbp), %edi
testl %edi, %edi
jne 0x3bb63
leal -0x1(%r13), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq -0x38(%rbp), %rdx
cmpw $0x0, (%rdx,%rcx,2)
je 0x3bc9d
leal -0x1(%r13), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq -0x38(%rbp), %r9
movzwl (%r9,%rcx,2), %ecx
cmpl %ecx, %edi
setl %sil
movl -0x48(%rbp), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
decl %r13d
movslq %r13d, %rcx
leaq (%rcx,%rcx,2), %rdx
movw %di, (%r9,%rdx,2)
movq 0x38(%r14), %rdi
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %rcx
mulsd 0x2ee62(%rip), %xmm1    # 0x6aa10
ucomisd 0x3327a(%rip), %xmm1    # 0x6ee30
movapd %xmm1, %xmm2
mulsd 0x2ece6(%rip), %xmm2    # 0x6a8a8
addsd 0x300ae(%rip), %xmm2    # 0x6bc78
cvttsd2si %xmm2, %r8d
movl $0x0, %r10d
cmovael %r10d, %r8d
xorpd %xmm2, %xmm2
ucomisd %xmm1, %xmm2
movb %sil, 0x15(%rdi,%rcx)
cmovael %r10d, %r8d
movq 0x38(%r14), %rsi
cmpl $0x1, -0x58(%rbp)
movb $0x2, %dil
sbbb $0x0, %dil
movb %r8b, 0x12(%rsi,%rcx)
movq 0x38(%r14), %rsi
movb %dil, 0x18(%rsi,%rcx)
movl -0x4c(%rbp), %esi
cmpl $0xffffe000, %esi       # imm = 0xFFFFE000
movq %r9, %r8
je 0x3bc3a
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x301fc(%rip), %xmm1    # 0x6be20
addsd %xmm0, %xmm1
movq 0x38(%r14), %rsi
leaq (%rax,%rax,2), %rdi
shlq $0x5, %rdi
movsd %xmm1, 0x40(%rsi,%rdi)
movl -0x54(%rbp), %esi
cmpl $0xfff80000, %esi       # imm = 0xFFF80000
movl -0x60(%rbp), %edi
je 0x3bce9
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x331ad(%rip), %xmm1    # 0x6ee08
leaq 0x34fae(%rip), %rsi     # 0x70c10
movsd 0x8(%rsi), %xmm2
divsd %xmm2, %xmm1
movq -0x30(%rbp), %rsi
movsd 0x8(%rsi,%rdx,8), %xmm3
ucomisd 0x2ec8b(%rip), %xmm3    # 0x6a908
jne 0x3bc81
jnp 0x3bcbf
movapd %xmm3, %xmm4
addsd 0x33183(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3bca9
addsd 0x3318d(%rip), %xmm1    # 0x6ee28
jmp 0x3bcbf
movb $0x1, %sil
movq -0x38(%rbp), %r9
jmp 0x3bb7d
addsd 0x33167(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3bcbf
addsd 0x33161(%rip), %xmm1    # 0x6ee20
movq -0x30(%rbp), %rsi
leaq (%rsi,%rdx,8), %rsi
addq $0x8, %rsi
movsd %xmm1, (%rsi)
divsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x38(%r14), %rsi
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
movsd %xmm0, 0x28(%rsi,%rax)
testl %edi, %edi
jne 0x3bcfa
cmpw $0x0, 0x2(%r8,%rdx,2)
je 0x3bd87
movzwl 0x2(%r8,%rdx,2), %eax
cmpl %eax, %edi
setl %al
movl -0x5c(%rbp), %esi
xorps %xmm0, %xmm0
cvtsi2sd %rsi, %xmm0
movw %di, 0x2(%r8,%rdx,2)
movq 0x38(%r14), %rdx
movb %al, 0x16(%rdx,%rcx)
mulsd 0x2ecea(%rip), %xmm0    # 0x6aa10
ucomisd 0x33102(%rip), %xmm0    # 0x6ee30
movapd %xmm0, %xmm1
mulsd 0x2eb6e(%rip), %xmm1    # 0x6a8a8
addsd 0x2ff36(%rip), %xmm1    # 0x6bc78
cvttsd2si %xmm1, %eax
movl $0x0, %edx
cmovael %edx, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovael %edx, %eax
movq 0x38(%r14), %rdx
movb %al, 0x13(%rdx,%rcx)
movslq -0x64(%rbp), %rax
leaq 0x33064(%rip), %rdx     # 0x6edd0
movb (%rdx,%rax,4), %al
movq 0x38(%r14), %rdx
movb %al, 0x19(%rdx,%rcx)
addl $0x7d, %ebx
movl -0x68(%rbp), %eax
decl %eax
jne 0x3b8b0
jmp 0x3bd8e
movb $0x1, %al
jmp 0x3bd05
xorl %eax, %eax
cmpl $0x0, -0x6c(%rbp)
sete %al
movl %eax, 0x9bdd0(%r14)
jmp 0x3bda5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq