// File: /workspace/github_cpp_makefile_star2_O3/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 -0x64(%rbp), %rsi
callq 0x4257c
testl %eax, %eax
js 0x3b71d
je 0x3b70b
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, -0x70(%rbp)
movl $0xd5, %ebx
movq %r14, -0x78(%rbp)
movq -0x80(%rbp), %rcx
cmpl $0x3f, (%rcx)
jg 0x3b70b
movl 0x9f0c0(%r14), %ecx
shll $0x3, %ecx
cmpl %ecx, %ebx
jg 0x3b70b
movl %eax, -0x60(%rbp)
leal -0x7d(%rbx), %esi
movq %r12, %rdi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %r13d
leal -0x77(%rbx), %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, -0x54(%rbp)
leal -0x76(%rbx), %esi
movq %r12, %rdi
movl $0x18, %edx
callq 0x4d9d6
movl %eax, -0x38(%rbp)
leal -0x5e(%rbx), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4da25
movl %eax, -0x3c(%rbp)
leal -0x4a(%rbx), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4d9d6
movl %eax, -0x48(%rbp)
leal -0x43(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x34(%rbp)
leal -0x3b(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x40(%rbp)
leal -0x33(%rbx), %esi
movq %r12, %rdi
movl $0x2, %edx
callq 0x4d9d6
movl %eax, -0x5c(%rbp)
leal -0x31(%rbx), %esi
movq %r12, %rdi
movl $0xe, %edx
callq 0x4da25
movl %eax, -0x44(%rbp)
leal -0x23(%rbx), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4da25
movl %eax, -0x4c(%rbp)
leal -0xf(%rbx), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4d9d6
movl %eax, -0x58(%rbp)
leal -0x8(%rbx), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x50(%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 0x4d28d
testl %eax, %eax
je 0x3b421
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 0x4f51b
cmpl $0x0, 0x9bdd0(%r14)
jne 0x3b3b7
andpd 0x2e583(%rip), %xmm0    # 0x69930
ucomisd 0x31953(%rip), %xmm0    # 0x6cd08
jbe 0x3b3c4
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 0x42820
testl %eax, %eax
js 0x3b6fd
movl -0x38(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl -0x34(%rbp), %xmm1
mulsd 0x33a03(%rip), %xmm1    # 0x6ee00
mulsd 0x30a1b(%rip), %xmm0    # 0x6be20
addsd %xmm1, %xmm0
movl %eax, %eax
movl -0x3c(%rbp), %edx
cmpl $0xfff80000, %edx       # imm = 0xFFF80000
jne 0x3b443
decl %r13d
movslq %r13d, %rdx
jmp 0x3b4e3
movl $0x2, %edi
leaq 0x33bdc(%rip), %rsi     # 0x6f009
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movq -0x78(%rbp), %r14
jmp 0x3b6fd
movq 0x38(%r14), %rcx
leaq (%rax,%rax,2), %rsi
shlq $0x5, %rsi
movsd %xmm0, 0x38(%rcx,%rsi)
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd 0x339a4(%rip), %xmm1    # 0x6ee08
leaq 0x35785(%rip), %rdx     # 0x70bf0
movsd (%rdx), %xmm2
divsd %xmm2, %xmm1
decl %r13d
movslq %r13d, %rdx
leaq (%rdx,%rdx,2), %rdi
movq -0x30(%rbp), %r8
movsd (%r8,%rdi,8), %xmm3
ucomisd 0x2f479(%rip), %xmm3    # 0x6a908
jne 0x3b493
jnp 0x3b4c5
movapd %xmm3, %xmm4
addsd 0x33971(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3b4af
addsd 0x3397b(%rip), %xmm1    # 0x6ee28
jmp 0x3b4c5
addsd 0x33961(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3b4c5
addsd 0x3395b(%rip), %xmm1    # 0x6ee20
movq -0x30(%rbp), %r8
leaq (%r8,%rdi,8), %rdi
movsd %xmm1, (%rdi)
movapd %xmm0, %xmm3
divsd %xmm2, %xmm3
addsd %xmm1, %xmm3
movsd %xmm3, 0x20(%rcx,%rsi)
movl -0x40(%rbp), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %rcx, %xmm1
movl -0x48(%rbp), %r9d
testl %r9d, %r9d
sete %cl
leaq (%rdx,%rdx,2), %rdx
movq -0x70(%rbp), %r8
movzwl (%r8,%rdx,2), %esi
testw %si, %si
sete %dil
andb %cl, %dil
movzwl %si, %ecx
cmpl %ecx, %r9d
setl %sil
orb %dil, %sil
movw %r9w, (%r8,%rdx,2)
movq 0x38(%r14), %rdi
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rcx,2), %rcx
mulsd 0x2f4d8(%rip), %xmm1    # 0x6aa10
ucomisd 0x338f0(%rip), %xmm1    # 0x6ee30
movapd %xmm1, %xmm2
mulsd 0x2f35c(%rip), %xmm2    # 0x6a8a8
addsd 0x30724(%rip), %xmm2    # 0x6bc78
cvttsd2si %xmm2, %r8d
movl $0x0, %r9d
cmovael %r9d, %r8d
xorpd %xmm2, %xmm2
ucomisd %xmm1, %xmm2
movb %sil, 0x15(%rdi,%rcx)
cmovael %r9d, %r8d
movq 0x38(%r14), %rsi
cmpl $0x1, -0x54(%rbp)
movb $0x2, %dil
sbbb $0x0, %dil
movb %r8b, 0x12(%rsi,%rcx)
movq 0x38(%r14), %rsi
movb %dil, 0x18(%rsi,%rcx)
movl -0x44(%rbp), %esi
cmpl $0xffffe000, %esi       # imm = 0xFFFFE000
je 0x3b5c1
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x30875(%rip), %xmm1    # 0x6be20
addsd %xmm0, %xmm1
movq 0x38(%r14), %rsi
leaq (%rax,%rax,2), %rdi
shlq $0x5, %rdi
movsd %xmm1, 0x40(%rsi,%rdi)
movl -0x4c(%rbp), %esi
cmpl $0xfff80000, %esi       # imm = 0xFFF80000
je 0x3b661
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x33829(%rip), %xmm1    # 0x6ee08
leaq 0x3560a(%rip), %rsi     # 0x70bf0
movsd 0x8(%rsi), %xmm2
divsd %xmm2, %xmm1
movq -0x30(%rbp), %rsi
movsd 0x8(%rsi,%rdx,8), %xmm3
ucomisd 0x2f307(%rip), %xmm3    # 0x6a908
jne 0x3b605
jnp 0x3b637
movapd %xmm3, %xmm4
addsd 0x337ff(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3b621
addsd 0x33809(%rip), %xmm1    # 0x6ee28
jmp 0x3b637
addsd 0x337ef(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3b637
addsd 0x337e9(%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)
movl -0x50(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movl -0x58(%rbp), %r9d
testl %r9d, %r9d
sete %al
movq -0x70(%rbp), %r8
movzwl 0x2(%r8,%rdx,2), %esi
testw %si, %si
sete %dil
andb %al, %dil
movzwl %si, %eax
cmpl %eax, %r9d
setl %al
orb %dil, %al
movw %r9w, 0x2(%r8,%rdx,2)
movq 0x38(%r14), %rdx
movb %al, 0x16(%rdx,%rcx)
mulsd 0x2f364(%rip), %xmm0    # 0x6aa10
ucomisd 0x3377c(%rip), %xmm0    # 0x6ee30
movapd %xmm0, %xmm1
mulsd 0x2f1e8(%rip), %xmm1    # 0x6a8a8
addsd 0x305b0(%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 -0x5c(%rbp), %rax
leaq 0x336de(%rip), %rdx     # 0x6edd0
movb (%rdx,%rax,4), %al
movq 0x38(%r14), %rdx
movb %al, 0x19(%rdx,%rcx)
addl $0x7d, %ebx
movl -0x60(%rbp), %eax
decl %eax
jne 0x3b24a
xorl %eax, %eax
cmpl $0x0, -0x64(%rbp)
sete %al
movl %eax, 0x9bdd0(%r14)
jmp 0x3b722
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq