// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_ssr2(bamboo::rtcm_t*, int)
static int decode_ssr2(rtcm_t *rtcm, int sys)
{
    double udint,dclk[3];
    int i,j,k,type,sync,iod,nsat,prn,sat,np,offp;
    
    type=getbitu(rtcm->buff,24,12);
    
    if ((nsat=decode_ssr2_head(rtcm,sys,&sync,&iod,&udint,&i))<0) {
        trace(2,"rtcm3 %d length error: len=%d\n",type,rtcm->len);
        return -1;
    }
    switch (sys) {
        case SYS_GPS: np=6; offp=  0; break;
        case SYS_GLO: np=5; offp=  0; break;
        case SYS_GAL: np=6; offp=  0; break;
        case SYS_QZS: np=4; offp=192; break;
        case SYS_CMP: np=6; offp=  1; break;
        case SYS_SBS: np=6; offp=120; break;
        default: return sync?0:10;
    }
    for (j=0;j<nsat&&i+70+np<=rtcm->len*8;j++) {
        prn    =getbitu(rtcm->buff,i,np)+offp; i+=np;
        dclk[0]=getbits(rtcm->buff,i,22)*1E-4; i+=22;
        dclk[1]=getbits(rtcm->buff,i,21)*1E-6; i+=21;
        dclk[2]=getbits(rtcm->buff,i,27)*2E-8; i+=27;
        
        if (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 %d satellite number error: prn=%d\n",type,prn);
            continue;
        }
        rtcm->ssr[sat-1].t0 [1]=rtcm->time;
        rtcm->ssr[sat-1].udi[1]=udint;
        rtcm->ssr[sat-1].iod[1]=iod;
        
        for (k=0;k<3;k++) {
            rtcm->ssr[sat-1].dclk[k]=dclk[k];
        }
        rtcm->ssr[sat-1].update=1;
    }
    return sync?0:10;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl $0x18, %esi
movl $0xc, %edx
callq 0x8bfc0
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x54(%rbp), %rdx
leaq -0x58(%rbp), %rcx
leaq -0x20(%rbp), %r8
leaq -0x44(%rbp), %r9
callq 0x7aeb0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
jge 0x7629f
movl -0x50(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %ecx
movl $0x2, %edi
leaq 0x4aee0(%rip), %rsi     # 0xc116c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x76580
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0x1f, %eax
ja 0x76323
movq -0x78(%rbp), %rax
leaq 0x4a856(%rip), %rcx     # 0xc0b10
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
jmp 0x7633b
movl $0x5, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
jmp 0x7633b
movl $0x6, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
jmp 0x7633b
movl $0x4, -0x68(%rbp)
movl $0xc0, -0x6c(%rbp)
jmp 0x7633b
movl $0x6, -0x68(%rbp)
movl $0x1, -0x6c(%rbp)
jmp 0x7633b
movl $0x6, -0x68(%rbp)
movl $0x78, -0x6c(%rbp)
jmp 0x7633b
movl -0x54(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x76580
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %ecx
xorl %eax, %eax
cmpl -0x5c(%rbp), %ecx
movb %al, -0x79(%rbp)
jge 0x7636d
movl -0x44(%rbp), %eax
addl $0x46, %eax
addl -0x68(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x76379
jmp 0x7656d
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x44(%rbp), %esi
movl -0x68(%rbp), %edx
callq 0x8bfc0
addl -0x6c(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x68(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x44(%rbp), %esi
movl $0x16, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x46aa6(%rip), %xmm1    # 0xbce68
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $0x16, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x44(%rbp), %esi
movl $0x15, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x489d8(%rip), %xmm1    # 0xbedd0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x44(%rbp), %eax
addl $0x15, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x44(%rbp), %esi
movl $0x1b, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x4a5f2(%rip), %xmm1    # 0xc0a20
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x44(%rbp), %eax
addl $0x1b, %eax
movl %eax, -0x44(%rbp)
movl -0x14(%rbp), %edi
movl -0x60(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jne 0x76471
movl -0x50(%rbp), %edx
movl -0x60(%rbp), %ecx
movl $0x2, %edi
leaq 0x4b603(%rip), %rsi     # 0xc1a68
movb $0x0, %al
callq 0x8b980
jmp 0x7655f
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x64(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd %xmm0, 0x68(%rax)
movl -0x58(%rbp), %ecx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x64(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movl %ecx, 0x94(%rax)
movl $0x0, -0x4c(%rbp)
cmpl $0x3, -0x4c(%rbp)
jge 0x7653b
movslq -0x4c(%rbp), %rax
movsd -0x40(%rbp,%rax,8), %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movslq -0x4c(%rbp), %rcx
movsd %xmm0, 0xe8(%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x764f6
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movb $0x1, 0x490(%rax)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x76342
movl -0x54(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)