// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movq %rdi, %r13
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
pushq $0x18
popq %rsi
pushq $0xc
popq %rdx
movq %rdi, -0x80(%rbp)
callq 0x459f7
movl %eax, %r14d
leaq -0x34(%rbp), %rdx
leaq -0x4c(%rbp), %rcx
leaq -0x88(%rbp), %r8
leaq -0x50(%rbp), %r9
movq %r13, %rdi
movl %ebx, %esi
callq 0x3b973
movl %eax, -0x48(%rbp)
testl %eax, %eax
js 0x38edd
pushq $0x6
popq %r15
leal -0x1(%rbx), %eax
cmpl $0x7, %eax
ja 0x38f00
movl $0x0, -0x2c(%rbp)
leaq 0x2bd44(%rip), %rcx     # 0x64c0c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rbx, -0x40(%rbp)
movl %r14d, -0x30(%rbp)
jmpq *%rax
pushq $0x78
jmp 0x38f18
movl 0x9f0c0(%r13), %ecx
leaq 0x2c058(%rip), %rsi     # 0x64f43
pushq $0x2
popq %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x455bc
pushq $-0x1
popq %rax
jmp 0x390bc
cmpl $0x10, %ebx
je 0x38f22
cmpl $0x20, %ebx
jne 0x390b0
movl %r14d, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x38f35
pushq $0x5
jmp 0x38f33
movl %r14d, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
movl $0xc0, -0x2c(%rbp)
pushq $0x4
popq %r15
movl -0x50(%rbp), %r14d
leal 0x46(%r15), %eax
movq %rax, -0x78(%rbp)
leaq 0x10(%r13), %rax
movq %rax, -0x70(%rbp)
leaq 0x6f148(%r13), %rax
movq %rax, -0x68(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x44(%rbp)
xorl %ebx, %ebx
movq %r13, -0x58(%rbp)
movq -0x80(%rbp), %r12
cmpl -0x48(%rbp), %ebx
je 0x390b0
movq -0x78(%rbp), %rax
addl %r14d, %eax
movl 0x9f0c0(%r13), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x390b0
movq %r12, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x459f7
movl %eax, %r13d
addl -0x2c(%rbp), %r13d
leal (%r14,%r15), %esi
movq %r12, %rdi
pushq $0x16
popq %rdx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x2794d(%rip), %xmm0    # 0x60910
movsd %xmm0, -0xa0(%rbp)
leal (%r14,%r15), %esi
addl $0x16, %esi
movq %r12, %rdi
pushq $0x15
popq %rdx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x29c57(%rip), %xmm0    # 0x62c40
movsd %xmm0, -0x98(%rbp)
leal (%r14,%r15), %esi
addl $0x2b, %esi
movq %r12, %rdi
pushq $0x1b
popq %rdx
callq 0x45a39
cvtsi2sd %eax, %xmm0
mulsd 0x2b711(%rip), %xmm0    # 0x64720
movsd %xmm0, -0x90(%rbp)
movq -0x40(%rbp), %rdi
movl %r13d, %esi
callq 0x452fd
testl %eax, %eax
je 0x39087
decl %eax
cltq
imulq $0x498, %rax, %rcx      # imm = 0x498
movq -0x68(%rbp), %rsi
leaq (%rsi,%rcx), %rax
movq -0x70(%rbp), %rdx
movups (%rdx), %xmm0
movups %xmm0, 0x10(%rsi,%rcx)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x68(%rsi,%rcx)
movl -0x44(%rbp), %edx
movl %edx, 0x94(%rsi,%rcx)
xorl %ecx, %ecx
movq -0x58(%rbp), %r13
cmpq $0x3, %rcx
je 0x3907e
movsd -0xa0(%rbp,%rcx,8), %xmm0
movsd %xmm0, 0xe8(%rax,%rcx,8)
incq %rcx
jmp 0x39061
movb $0x1, 0x490(%rax)
jmp 0x390a2
pushq $0x2
popq %rdi
leaq 0x2c7ae(%rip), %rsi     # 0x6583f
movl -0x30(%rbp), %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x455bc
movq -0x58(%rbp), %r13
addl %r15d, %r14d
addl $0x46, %r14d
incl %ebx
jmp 0x38f71
xorl %ecx, %ecx
cmpl $0x0, -0x34(%rbp)
pushq $0xa
popq %rax
cmovnel %ecx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq