// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3.cpp
// Function: bamboo::decode_ssr3(bamboo::rtcm_t*, int)
static int decode_ssr3(rtcm_t *rtcm, int sys)
{
    const int *codes;
    double udint,bias,cbias[MAXCODE];
    int i,j,k,type,mode,sync,iod,nsat,prn,sat,nbias,np,offp,ncode;
    
    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; codes=codes_gps; ncode=17; break;
        case SYS_GLO: np=5; offp=  0; codes=codes_glo; ncode= 4; break;
        case SYS_GAL: np=6; offp=  0; codes=codes_gal; ncode=19; break;
        case SYS_QZS: np=4; offp=192; codes=codes_qzs; ncode=13; break;
        case SYS_CMP: np=6; offp=  1; codes=codes_bds; ncode= 9; break;
        case SYS_SBS: np=6; offp=120; codes=codes_sbs; ncode= 4; break;
        default: return sync?0:10;
    }
    for (j=0;j<nsat&&i+5+np<=rtcm->len*8;j++) {
        prn  =getbitu(rtcm->buff,i,np)+offp; i+=np;
        nbias=getbitu(rtcm->buff,i, 5);      i+= 5;
        
        for (k=0;k<MAXCODE;k++) cbias[k]=0.0;
        for (k=0;k<nbias&&i+19<=rtcm->len*8;k++) {
            mode=getbitu(rtcm->buff,i, 5);      i+= 5;
            bias=getbits(rtcm->buff,i,14)*0.01; i+=14;
            if (mode<=ncode) {
                cbias[codes[mode]-1]=(float)bias;
            }
            else {
                trace(2,"rtcm3 %d not supported mode: mode=%d\n",type,mode);
            }
        }
        if (!(sat=satno(sys,prn))) {
            trace(2,"rtcm3 %d satellite number error: prn=%d\n",type,prn);
            continue;
        }
        rtcm->ssr[sat-1].t0 [4]=rtcm->time;
        rtcm->ssr[sat-1].udi[4]=udint;
        rtcm->ssr[sat-1].iod[4]=iod;
        
        for (k=0;k<MAXCODE;k++) {
            rtcm->ssr[sat-1].cbias[k]=(float)cbias[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 $0x238, %rsp            # imm = 0x238
movl %esi, %r14d
movq %rdi, %rbx
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movq %rdi, -0x80(%rbp)
movl $0x18, %esi
movl $0xc, %edx
callq 0x4d9d6
movl %eax, %r15d
leaq -0x4c(%rbp), %rdx
leaq -0x6c(%rbp), %rcx
leaq -0xa8(%rbp), %r8
leaq -0x70(%rbp), %r9
movq %rbx, %rdi
movl %r14d, %esi
callq 0x42d40
movl %eax, -0x44(%rbp)
testl %eax, %eax
js 0x402ab
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x402d1
movl $0x0, -0x30(%rbp)
leaq 0x2e8ae(%rip), %rcx     # 0x6eb3c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r15d, -0x34(%rbp)
jmpq *%rax
movl $0x11, -0x2c(%rbp)
leaq 0x2e9d7(%rip), %rax     # 0x6ec80
jmp 0x40321
movl 0x9f0c0(%rbx), %ecx
leaq 0x2ec8f(%rip), %rsi     # 0x6ef47
movl $0x2, %edi
movl %r15d, %edx
xorl %eax, %eax
callq 0x4d55d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x405a3
cmpl $0x10, %r14d
je 0x40343
cmpl $0x20, %r14d
jne 0x40595
movl %r15d, -0x34(%rbp)
movl $0x9, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
leaq 0x2ea66(%rip), %rax     # 0x6ed60
jmp 0x40321
movl $0x13, -0x2c(%rbp)
leaq 0x2e9c6(%rip), %rax     # 0x6ecd0
jmp 0x40321
movl $0x4, -0x2c(%rbp)
movl $0x78, -0x30(%rbp)
leaq 0x2eacf(%rip), %rax     # 0x6edf0
movq %rax, -0x40(%rbp)
movl $0x6, %r15d
jmp 0x40366
movl $0x4, -0x2c(%rbp)
movl $0x5, %r15d
leaq 0x2ea9f(%rip), %rax     # 0x6ede0
jmp 0x40362
movl %r15d, -0x34(%rbp)
movl $0xd, -0x2c(%rbp)
movl $0xc0, -0x30(%rbp)
movl $0x4, %r15d
leaq 0x2e9be(%rip), %rax     # 0x6ed20
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x40595
movl -0x70(%rbp), %r13d
leal 0x5(%r15), %eax
movq %rax, -0xa0(%rbp)
leaq 0x10(%rbx), %rax
movq %rax, -0x98(%rbp)
leaq 0x6f148(%rbx), %rax
movq %rax, -0x90(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x68(%rbp)
leal 0x18(%r15), %eax
movl %eax, -0x64(%rbp)
xorl %edx, %edx
movq %r14, -0x58(%rbp)
movq %r15, -0x78(%rbp)
movq %rbx, -0x60(%rbp)
movq -0x80(%rbp), %r12
movq -0xa0(%rbp), %rax
addl %r13d, %eax
movl 0x9f0c0(%rbx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x40595
movl %edx, -0x48(%rbp)
movq -0x80(%rbp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x4d9d6
movl %eax, %ebx
leal (%r15,%r13), %esi
movq %r14, %rdi
movl $0x5, %edx
callq 0x4d9d6
movq %r15, %r14
movl %eax, %r15d
movl $0x1b8, %edx            # imm = 0x1B8
leaq -0x260(%rbp), %rdi
xorl %esi, %esi
callq 0x8390
testl %r15d, %r15d
jle 0x404df
addl -0x64(%rbp), %r13d
movl %r13d, %r14d
movl %ebx, %ecx
leal -0x13(%r14), %r13d
movq -0x60(%rbp), %rax
movl 0x9f0c0(%rax), %eax
shll $0x3, %eax
cmpl %eax, %r14d
jg 0x404d5
movq %r12, %rdi
movl %r13d, %esi
movl $0x5, %edx
callq 0x4d9d6
movl %eax, %r13d
leal -0xe(%r14), %esi
movq %r12, %rdi
movl $0xe, %edx
callq 0x4da25
cmpl -0x2c(%rbp), %r13d
jle 0x40494
movl $0x2, %edi
leaq 0x2f4a4(%rip), %rsi     # 0x6f929
movl -0x34(%rbp), %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x4d55d
jmp 0x404bf
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x2b31d(%rip), %xmm0    # 0x6b7c0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movslq %r13d, %rax
movq -0x40(%rbp), %rcx
movslq (%rcx,%rax,4), %rax
movsd %xmm0, -0x268(%rbp,%rax,8)
addl $0x13, %r14d
decl %r15d
movl %ebx, %ecx
jne 0x40435
addl $-0x13, %r14d
movl %r14d, %r13d
movq -0x58(%rbp), %r14
movq -0x78(%rbp), %r15
jmp 0x404ef
addl %r14d, %r13d
addl $0x5, %r13d
movq %r14, %r15
movq -0x58(%rbp), %r14
movl %ebx, %ecx
addl -0x30(%rbp), %ecx
movl %r14d, %edi
movl %ecx, %ebx
movl %ecx, %esi
callq 0x4d28d
testl %eax, %eax
je 0x4056b
decl %eax
cltq
imulq $0x498, %rax, %rcx      # imm = 0x498
movq -0x90(%rbp), %rsi
leaq (%rsi,%rcx), %rax
movq -0x98(%rbp), %rdx
movups (%rdx), %xmm0
movups %xmm0, 0x40(%rsi,%rcx)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, 0x80(%rsi,%rcx)
movl -0x68(%rbp), %edx
movl %edx, 0xa0(%rsi,%rcx)
xorl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsd2ss -0x260(%rbp,%rcx,8), %xmm0
movss %xmm0, 0x108(%rax,%rcx,4)
incq %rcx
cmpq $0x37, %rcx
jne 0x40544
movb $0x1, 0x490(%rax)
jmp 0x40583
movl $0x2, %edi
leaq 0x2f2cc(%rip), %rsi     # 0x6f843
movl -0x34(%rbp), %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4d55d
movl -0x48(%rbp), %edx
movq -0x60(%rbp), %rbx
incl %edx
cmpl -0x44(%rbp), %edx
jne 0x403c7
xorl %ecx, %ecx
cmpl $0x0, -0x4c(%rbp)
movl $0xa, %eax
cmovnel %ecx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq