// File: /workspace/github_cpp_makefile_star2_O1/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 0x42e21
testl %eax, %eax
js 0x3b843
je 0x3b838
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 0x3b838
movl 0x9f0c0(%rbx), %ecx
shll $0x3, %ecx
cmpl %ecx, %r14d
jg 0x3b838
movl %eax, -0x44(%rbp)
leal -0x4a(%r14), %esi
movq %r12, %rdi
movl $0x6, %edx
callq 0x4e341
movl %eax, %r13d
leal -0x44(%r14), %esi
movq %r12, %rdi
movl $0x1, %edx
callq 0x4e341
movl %eax, -0x40(%rbp)
leal -0x43(%r14), %esi
movq %r12, %rdi
movl $0x18, %edx
callq 0x4e341
movl %eax, -0x30(%rbp)
leal -0x2b(%r14), %esi
movq %r12, %rdi
movl $0x14, %edx
callq 0x4e390
movl %eax, -0x34(%rbp)
leal -0x17(%r14), %esi
movq %r12, %rdi
movl $0x7, %edx
callq 0x4e341
movl %eax, -0x3c(%rbp)
leal -0x10(%r14), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x2c(%rbp)
leal -0x8(%r14), %esi
movq %r12, %rdi
movl $0x8, %edx
callq 0x4e341
movl %eax, -0x38(%rbp)
leal 0x50(%r13), %r15d
xorl %edi, %edi
cmpl $0x28, %r13d
setge %dil
cmovll %r13d, %r15d
incl %edi
movl %r15d, %esi
callq 0x4dbc5
testl %eax, %eax
je 0x3b720
movl %eax, %r13d
movq 0x38(%rbx), %rax
movq (%rax), %rdi
movsd 0x8(%rax), %xmm0
movq 0x10(%rbx), %rsi
movsd 0x18(%rbx), %xmm1
callq 0x4fe97
cmpl $0x0, 0x9bdd0(%rbx)
jne 0x3b654
andpd 0x2e2e6(%rip), %xmm0    # 0x69930
ucomisd 0x316b6(%rip), %xmm0    # 0x6cd08
jbe 0x3b65f
xorl %eax, %eax
movl %eax, 0x9bdd0(%rbx)
movl %eax, 0x30(%rbx)
movq 0x10(%rbx), %rsi
movsd 0x18(%rbx), %xmm0
movq -0x58(%rbp), %rdi
movl %r13d, %edx
callq 0x430c2
testl %eax, %eax
js 0x3b820
movl %eax, %eax
movl -0x34(%rbp), %esi
cmpl $0xfff80000, %esi       # imm = 0xFFF80000
je 0x3b76b
movl -0x30(%rbp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl -0x2c(%rbp), %xmm1
mulsd 0x33758(%rip), %xmm1    # 0x6ee00
mulsd 0x30770(%rip), %xmm0    # 0x6be20
addsd %xmm1, %xmm0
movq 0x38(%rbx), %rcx
leaq (%rax,%rax,2), %rdx
shlq $0x5, %rdx
movsd %xmm0, 0x38(%rcx,%rdx)
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
mulsd 0x33733(%rip), %xmm1    # 0x6ee08
leaq 0x35534(%rip), %rsi     # 0x70c10
movsd (%rsi), %xmm2
divsd %xmm2, %xmm1
leal -0x1(%r13), %esi
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
movq -0x50(%rbp), %rdi
movsd (%rdi,%rsi,8), %xmm3
ucomisd 0x2f208(%rip), %xmm3    # 0x6a908
jne 0x3b704
jnp 0x3b751
movapd %xmm3, %xmm4
addsd 0x33700(%rip), %xmm4    # 0x6ee10
ucomisd %xmm1, %xmm4
jbe 0x3b73b
addsd 0x3370a(%rip), %xmm1    # 0x6ee28
jmp 0x3b751
movl $0x2, %edi
leaq 0x338b2(%rip), %rsi     # 0x6efde
movl %r15d, %edx
xorl %eax, %eax
callq 0x4ded0
jmp 0x3b820
addsd 0x336d5(%rip), %xmm3    # 0x6ee18
ucomisd %xmm3, %xmm1
jbe 0x3b751
addsd 0x336cf(%rip), %xmm1    # 0x6ee20
movq -0x50(%rbp), %rdi
leaq (%rdi,%rsi,8), %rsi
movsd %xmm1, (%rsi)
divsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rcx,%rdx)
movl -0x3c(%rbp), %edi
testl %edi, %edi
movq -0x60(%rbp), %rdx
jne 0x3b78c
leal -0x1(%r13), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
cmpw $0x0, (%rdx,%rcx,2)
je 0x3b831
leal -0x1(%r13), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movzwl (%rdx,%rcx,2), %ecx
cmpl %ecx, %edi
setl %cl
movq %rdx, %rsi
movl -0x38(%rbp), %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
decl %r13d
movslq %r13d, %rdx
leaq (%rdx,%rdx,2), %rdx
movw %di, (%rsi,%rdx,2)
movq 0x38(%rbx), %rdx
shlq $0x5, %rax
leaq (%rax,%rax,2), %rax
mulsd 0x2f240(%rip), %xmm0    # 0x6aa10
ucomisd 0x33658(%rip), %xmm0    # 0x6ee30
movb %cl, 0x15(%rdx,%rax)
movapd %xmm0, %xmm1
mulsd 0x2f0c0(%rip), %xmm1    # 0x6a8a8
addsd 0x30488(%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 0x3b54a
jmp 0x3b838
movb $0x1, %cl
jmp 0x3b7a0
xorl %eax, %eax
cmpl $0x0, -0x48(%rbp)
sete %al
jmp 0x3b848
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq