// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_type1012(bamboo::rtcm_t*)
static int decode_type1012(rtcm_t *rtcm)
{
    double pr1,cnr1,cnr2,tt,cp1,cp2,lam1,lam2;
    int i=24+61,j,index,nsat,sync,prn,sat,freq,code1,code2,pr21,ppr1,ppr2;
    int lock1,lock2,amb,sys=SYS_GLO;
    
    if ((nsat=decode_head1009(rtcm,&sync))<0) return -1;
    
    for (j=0;j<nsat&&rtcm->obs.n<MAXOBS&&i+130<=rtcm->len*8;j++) {
        prn  =getbitu(rtcm->buff,i, 6); i+= 6;
        code1=getbitu(rtcm->buff,i, 1); i+= 1;
        freq =getbitu(rtcm->buff,i, 5); i+= 5;
        pr1  =getbitu(rtcm->buff,i,25); i+=25;
        ppr1 =getbits(rtcm->buff,i,20); i+=20;
        lock1=getbitu(rtcm->buff,i, 7); i+= 7;
        amb  =getbitu(rtcm->buff,i, 7); i+= 7;
        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 (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 1012 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_GLO;
        if (ppr1!=(int)0xFFF80000) {
            lam1=CLIGHT/(FREQ1_GLO+DFRQ1_GLO*(freq-7));
            rtcm->obs.data[index].P[0]=pr1;
            cp1=adjcp(rtcm,sat,0,ppr1*0.0005/lam1);
            rtcm->obs.data[index].L[0]=pr1/lam1+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) {
            lam2=CLIGHT/(FREQ2_GLO+DFRQ2_GLO*(freq-7));
            cp2=adjcp(rtcm,sat,1,ppr2*0.0005/lam2);
            rtcm->obs.data[index].L[1]=pr1/lam2+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]=code2?CODE_L2P:CODE_L2C;
    }
    rtcm->obsflag=!sync;
    return sync?0:1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x55, -0x54(%rbp)
movl $0x4, -0x94(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x64(%rbp), %rsi
callq 0x7a560
movl %eax, -0x60(%rbp)
cmpl $0x0, %eax
jge 0x70901
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x70f76
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %ecx
xorl %eax, %eax
cmpl -0x60(%rbp), %ecx
movb %al, -0xc9(%rbp)
jge 0x7094a
movq -0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x40, 0x30(%rcx)
movb %al, -0xc9(%rbp)
jge 0x7094a
movl -0x54(%rbp), %eax
addl $0x82, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x70959
jmp 0x70f4b
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x6, %edx
callq 0x8bfc0
movl %eax, -0x68(%rbp)
movl -0x54(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x1, %edx
callq 0x8bfc0
movl %eax, -0x74(%rbp)
movl -0x54(%rbp), %eax
incl %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x70(%rbp)
movl -0x54(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x19, %edx
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x18(%rbp)
movl -0x54(%rbp), %eax
addl $0x19, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x14, %edx
movl %edx, -0xd8(%rbp)
callq 0x8c050
movl %eax, -0x80(%rbp)
movl -0x54(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x7, %edx
movl %edx, -0xd4(%rbp)
callq 0x8bfc0
movl -0xd4(%rbp), %edx
movl %eax, -0x88(%rbp)
movl -0x54(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
callq 0x8bfc0
movl %eax, -0x90(%rbp)
movl -0x54(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x8, %edx
movl %edx, -0xd0(%rbp)
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x54(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0x2, %edx
callq 0x8bfc0
movl %eax, -0x78(%rbp)
movl -0x54(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
movl $0xe, %edx
callq 0x8c050
movl -0xd8(%rbp), %edx
movl %eax, -0x7c(%rbp)
movl -0x54(%rbp), %eax
addl $0xe, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
callq 0x8c050
movl -0xd4(%rbp), %edx
movl %eax, -0x84(%rbp)
movl -0x54(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
callq 0x8bfc0
movl -0xd0(%rbp), %edx
movl %eax, -0x8c(%rbp)
movl -0x54(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x54(%rbp), %esi
callq 0x8bfc0
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x54(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x54(%rbp)
movl -0x94(%rbp), %edi
movl -0x68(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
jne 0x70ba0
movl -0x94(%rbp), %edx
movl -0x68(%rbp), %ecx
movl $0x2, %edi
leaq 0x507f6(%rip), %rsi     # 0xc138a
movb $0x0, %al
callq 0x8b980
jmp 0x70f3d
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0xb8(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
movsd -0xa0(%rbp), %xmm0
movq -0xb8(%rbp), %rsi
movsd -0xb0(%rbp), %xmm1
callq 0x8e8e0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x9bdd0(%rax)
jne 0x70c2a
movsd -0x30(%rbp), %xmm0
movaps 0x4c608(%rip), %xmm1    # 0xbd220
pand %xmm1, %xmm0
movsd 0x4d17c(%rip), %xmm1    # 0xbdda0
ucomisd %xmm1, %xmm0
jbe 0x70c43
movq -0x10(%rbp), %rax
movl $0x0, 0x9bdd0(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq %rcx, -0xc8(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0xc0(%rbp)
movl -0x6c(%rbp), %edx
movq -0xc8(%rbp), %rsi
movsd -0xc0(%rbp), %xmm0
callq 0x7a130
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
jge 0x70c89
jmp 0x70f3d
movsd -0x18(%rbp), %xmm0
cvtsi2sdl -0x90(%rbp), %xmm1
movsd 0x4fd5a(%rip), %xmm2    # 0xc09f8
mulsd %xmm2, %xmm1
movsd 0x4d0de(%rip), %xmm2    # 0xbdd88
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
cmpl $0xfff80000, -0x80(%rbp) # imm = 0xFFF80000
je 0x70d64
movl -0x70(%rbp), %eax
subl $0x7, %eax
cvtsi2sd %eax, %xmm1
movsd 0x4c202(%rip), %xmm0    # 0xbced8
mulsd %xmm0, %xmm1
movsd 0x4c1fe(%rip), %xmm0    # 0xbcee0
addsd %xmm0, %xmm1
movsd 0x4d0ba(%rip), %xmm0    # 0xbdda8
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %esi
cvtsi2sdl -0x80(%rbp), %xmm0
movsd 0x4fcc0(%rip), %xmm1    # 0xc09e8
mulsd %xmm1, %xmm0
divsd -0x48(%rbp), %xmm0
xorl %edx, %edx
callq 0x7a2d0
movsd %xmm0, -0x38(%rbp)
movsd -0x18(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x20(%rax)
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %esi
movl -0x88(%rbp), %ecx
xorl %edx, %edx
callq 0x7a3f0
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x15(%rax)
movsd 0x4c1b0(%rip), %xmm0    # 0xbcf48
mulsd -0x20(%rbp), %xmm0
callq 0x7a4a0
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x12(%rax)
movl -0x74(%rbp), %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x18(%rax)
cmpl $0xffffe000, -0x7c(%rbp) # imm = 0xFFFFE000
je 0x70e20
movsd -0x18(%rbp), %xmm1
cvtsi2sdl -0x7c(%rbp), %xmm0
movsd 0x4cf88(%rip), %xmm2    # 0xbdd88
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x40(%rax)
cmpl $0xfff80000, -0x84(%rbp) # imm = 0xFFF80000
je 0x70eb9
movl -0x70(%rbp), %eax
subl $0x7, %eax
cvtsi2sd %eax, %xmm1
movsd 0x4c086(%rip), %xmm0    # 0xbcec8
mulsd %xmm0, %xmm1
movsd 0x4c082(%rip), %xmm0    # 0xbced0
addsd %xmm0, %xmm1
movsd 0x4cf4e(%rip), %xmm0    # 0xbdda8
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %esi
cvtsi2sdl -0x84(%rbp), %xmm0
movsd 0x4fb6e(%rip), %xmm1    # 0xc09e8
mulsd %xmm1, %xmm0
divsd -0x50(%rbp), %xmm0
movl $0x1, %edx
callq 0x7a2d0
movsd %xmm0, -0x40(%rbp)
movsd -0x18(%rbp), %xmm0
divsd -0x50(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %esi
movl -0x8c(%rbp), %ecx
movl $0x1, %edx
callq 0x7a3f0
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x16(%rax)
movsd 0x4c058(%rip), %xmm0    # 0xbcf48
mulsd -0x28(%rbp), %xmm0
callq 0x7a4a0
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x13(%rax)
movl -0x78(%rbp), %edx
movl $0xe, %eax
movl $0x13, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rdx
imulq $0x60, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x19(%rax)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x70908
cmpl $0x0, -0x64(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9bdd0(%rax)
movl -0x64(%rbp), %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)