// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_ssr6(bamboo::rtcm_t*, int)
static int decode_ssr6(rtcm_t *rtcm, int sys)
{
    double udint,hrclk;
    int i,j,type,nsat,sync,iod,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+22+np<=rtcm->len*8;j++) {
        prn  =getbitu(rtcm->buff,i,np)+offp; i+=np;
        hrclk=getbits(rtcm->buff,i,22)*1E-4; i+=22;
        
        if (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 %d satellite number error: prn=%d\n",type,prn);
            continue;
        }
        rtcm->ssr[sat-1].t0 [2]=rtcm->time;
        rtcm->ssr[sat-1].udi[2]=udint;
        rtcm->ssr[sat-1].iod[2]=iod;
        rtcm->ssr[sat-1].hrclk=hrclk;
        rtcm->ssr[sat-1].update=1;
    }
    return sync?0:10;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %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, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x20(%rbp), %r8
leaq -0x2c(%rbp), %r9
callq 0x7aeb0
movl %eax, -0x38(%rbp)
cmpl $0x0, %eax
jge 0x776bc
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %ecx
movl $0x2, %edi
leaq 0x49ac3(%rip), %rsi     # 0xc116c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7790f
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x1f, %eax
ja 0x77740
movq -0x58(%rbp), %rax
leaq 0x49639(%rip), %rcx     # 0xc0d10
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x77758
movl $0x5, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x77758
movl $0x6, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x77758
movl $0x4, -0x4c(%rbp)
movl $0xc0, -0x50(%rbp)
jmp 0x77758
movl $0x6, -0x4c(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x77758
movl $0x6, -0x4c(%rbp)
movl $0x78, -0x50(%rbp)
jmp 0x77758
movl -0x3c(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x7790f
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x38(%rbp), %ecx
movb %al, -0x59(%rbp)
jge 0x7778a
movl -0x2c(%rbp), %eax
addl $0x16, %eax
addl -0x4c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x77796
jmp 0x778fc
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x2c(%rbp), %esi
movl -0x4c(%rbp), %edx
callq 0x8bfc0
addl -0x50(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x2c(%rbp), %esi
movl $0x16, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x45689(%rip), %xmm1    # 0xbce68
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x16, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %edi
movl -0x44(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x48(%rbp)
cmpl $0x0, %eax
jne 0x77822
movl -0x34(%rbp), %edx
movl -0x44(%rbp), %ecx
movl $0x2, %edi
leaq 0x4a252(%rip), %rsi     # 0xc1a68
movb $0x0, %al
callq 0x8b980
jmp 0x778ee
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x48(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movq 0x10(%rcx), %rdx
movq %rdx, 0x20(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x28(%rax)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd %xmm0, 0x70(%rax)
movl -0x40(%rbp), %ecx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x48(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movl %ecx, 0x98(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd %xmm0, 0x100(%rax)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x48(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movb $0x1, 0x490(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x7775f
movl -0x3c(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)