// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1002(bamboo::rtcm_t*)
static int decode_type1002(rtcm_t *rtcm)
{
    double pr1,cnr1,tt,cp1;
    int i=24+64,j,index,nsat,sync,prn,code,sat,ppr1,lock1,amb,sys;
    
    if ((nsat=decode_head1001(rtcm,&sync))<0) return -1;
    
    for (j=0;j<nsat&&rtcm->obs.n<MAXOBS&&i+74<=rtcm->len*8;j++) {
        prn  =getbitu(rtcm->buff,i, 6); i+= 6;
        code =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;
        if (prn<40) {
            sys=SYS_GPS;
        }
        else {
            sys=SYS_SBS; prn+=80;
        }
        if (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 1002 satellite number error: prn=%d\n",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]=code?CODE_L1P:CODE_L1C;
    }
    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
leaq -0x48(%rbp), %rsi
callq 0x4257c
testl %eax, %eax
js 0x3b1dd
je 0x3b1d2
leaq 0x30(%rbx), %rcx
movq %rcx, -0x58(%rbp)
leaq 0x9f0c4(%rbx), %r12
leaq 0x9bdd8(%rbx), %rcx
movq %rcx, -0x50(%rbp)
leaq 0x9cc60(%rbx), %rcx
movq %rcx, -0x60(%rbp)
movl $0xa2, %r14d
movq -0x58(%rbp), %rcx
cmpl $0x3f, (%rcx)
jg 0x3b1d2
movl 0x9f0c0(%rbx), %ecx
shll $0x3, %ecx
cmpl %ecx, %r14d
jg 0x3b1d2
movl %eax, -0x44(%rbp)
leal -0x4a(%r14), %esi
movq %r12, %rdi
movl $0x6, %edx
callq 0x4d9d6
movl %eax, %r15d
leal -0x44(%r14), %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x4d9d6
movl %eax, -0x40(%rbp)
leal -0x43(%r14), %esi
movq %r12, %rdi
movl $0x18, %edx
callq 0x4d9d6
movl %eax, -0x30(%rbp)
leal -0x2b(%r14), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4da25
movl %eax, -0x34(%rbp)
leal -0x17(%r14), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4d9d6
movl %eax, -0x3c(%rbp)
leal -0x10(%r14), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x2c(%rbp)
leal -0x8(%r14), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4d9d6
movl %eax, -0x38(%rbp)
leal 0x50(%r15), %r13d
xorl %edi, %edi
cmpl $0x28, %r15d
setge %dil
cmovll %r15d, %r13d
incl %edi
movl %r13d, %esi
callq 0x4d28d
testl %eax, %eax
je 0x3b044
movl %eax, %r15d
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%rbx), %rsi
movsd 0x18(%rbx), %xmm1
callq 0x4f51b
cmpl $0x0, 0x9bdd0(%rbx)
jne 0x3b004
andpd 0x2e936(%rip), %xmm0    # 0x69930
ucomisd 0x31d06(%rip), %xmm0    # 0x6cd08
jbe 0x3b00f
xorl %eax, %eax
movl %eax, 0x9bdd0(%rbx)
movl %eax, 0x30(%rbx)
movq 0x10(%rbx), %rsi
movsd 0x18(%rbx), %xmm0
movq -0x58(%rbp), %rdi
movl %r15d, %edx
callq 0x42820
testl %eax, %eax
js 0x3b1c3
movl %eax, %eax
movl -0x34(%rbp), %edx
cmpl $0xfff80000, %edx       # imm = 0xFFF80000
jne 0x3b05f
decl %r15d
movslq %r15d, %rdx
jmp 0x3b122
movl $0x2, %edi
leaq 0x33f8e(%rip), %rsi     # 0x6efde
movl %r13d, %edx
xorl %eax, %eax
callq 0x4d55d
jmp 0x3b1c3
movl -0x30(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl -0x2c(%rbp), %xmm1
mulsd 0x33d86(%rip), %xmm1    # 0x6ee00
mulsd 0x30d9e(%rip), %xmm0    # 0x6be20
addsd %xmm1, %xmm0
movq 0x38(%rbx), %rcx
leaq (%rax,%rax,2), %rsi
shlq $0x5, %rsi
movsd %xmm0, 0x38(%rcx,%rsi)
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd 0x33d61(%rip), %xmm1    # 0x6ee08
leaq 0x35b42(%rip), %rdx     # 0x70bf0
movsd (%rdx), %xmm2
divsd %xmm2, %xmm1
decl %r15d
movslq %r15d, %rdx
leaq (%rdx,%rdx,2), %rdi
movq -0x50(%rbp), %r8
movsd (%r8,%rdi,8), %xmm3
ucomisd 0x2f836(%rip), %xmm3    # 0x6a908
jne 0x3b0d6
jnp 0x3b108
movapd %xmm3, %xmm4
addsd 0x33d2e(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3b0f2
addsd 0x33d38(%rip), %xmm1    # 0x6ee28
jmp 0x3b108
addsd 0x33d1e(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3b108
addsd 0x33d18(%rip), %xmm1    # 0x6ee20
movq -0x50(%rbp), %r8
leaq (%r8,%rdi,8), %rdi
movsd %xmm1, (%rdi)
divsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rcx,%rsi)
movl -0x38(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movl -0x3c(%rbp), %r9d
testl %r9d, %r9d
sete %cl
leaq (%rdx,%rdx,2), %rdx
movq -0x60(%rbp), %r8
movzwl (%r8,%rdx,2), %esi
testw %si, %si
sete %dil
andb %cl, %dil
movzwl %si, %ecx
cmpl %ecx, %r9d
setl %cl
orb %dil, %cl
movw %r9w, (%r8,%rdx,2)
movq 0x38(%rbx), %rdx
shlq $0x5, %rax
leaq (%rax,%rax,2), %rax
mulsd 0x2f89d(%rip), %xmm0    # 0x6aa10
ucomisd 0x33cb5(%rip), %xmm0    # 0x6ee30
movb %cl, 0x15(%rdx,%rax)
movapd %xmm0, %xmm1
mulsd 0x2f71d(%rip), %xmm1    # 0x6a8a8
addsd 0x30ae5(%rip), %xmm1    # 0x6bc78
cvttsd2si %xmm1, %ecx
movl $0x0, %edx
cmovael %edx, %ecx
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
cmovael %edx, %ecx
movq 0x38(%rbx), %rdx
movb %cl, 0x12(%rdx,%rax)
cmpl $0x1, -0x40(%rbp)
movb $0x2, %cl
sbbb $0x0, %cl
movq 0x38(%rbx), %rdx
movb %cl, 0x18(%rdx,%rax)
addl $0x4a, %r14d
movl -0x44(%rbp), %eax
decl %eax
jne 0x3aefe
xorl %eax, %eax
cmpl $0x0, -0x48(%rbp)
sete %al
jmp 0x3b1e2
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq