// File: /workspace/github_cpp_makefile_star2_O1/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, %r13d
movq %rdi, %rbx
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movq %rdi, -0x80(%rbp)
movl $0x18, %esi
movl $0xc, %edx
callq 0x4e341
movl %eax, %r14d
leaq -0x48(%rbp), %rdx
leaq -0x70(%rbp), %rcx
leaq -0xa8(%rbp), %r8
leaq -0x4c(%rbp), %r9
movq %rbx, %rdi
movl %r13d, %esi
callq 0x435e1
testl %eax, %eax
js 0x4095a
movl $0x6, %r15d
leal -0x1(%r13), %ecx
cmpl $0x7, %ecx
ja 0x40980
movl $0x0, -0x30(%rbp)
leaq 0x2e202(%rip), %rdx     # 0x6eb3c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl %r14d, -0x34(%rbp)
jmpq *%rcx
movl $0x11, -0x2c(%rbp)
leaq 0x2e32b(%rip), %rcx     # 0x6ec80
jmp 0x40a0e
movl 0x9f0c0(%rbx), %ecx
leaq 0x2e5e0(%rip), %rsi     # 0x6ef47
movl $0x2, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4ded0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x40c5f
cmpl $0x10, %r13d
je 0x409ef
cmpl $0x20, %r13d
jne 0x409a7
movl %r14d, -0x34(%rbp)
movl $0x9, -0x2c(%rbp)
movl $0x1, -0x30(%rbp)
leaq 0x2e3bb(%rip), %rcx     # 0x6ed60
jmp 0x40a0e
xorl %ecx, %ecx
cmpl $0x0, -0x48(%rbp)
jmp 0x40c57
movl $0x13, -0x2c(%rbp)
leaq 0x2e310(%rip), %rcx     # 0x6ecd0
jmp 0x40a0e
movl $0x4, -0x2c(%rbp)
movl $0x78, -0x30(%rbp)
leaq 0x2e419(%rip), %rcx     # 0x6edf0
jmp 0x40a0e
movl $0x4, -0x2c(%rbp)
movl $0x5, %r15d
leaq 0x2e3f3(%rip), %rcx     # 0x6ede0
jmp 0x40a0e
movl %r14d, -0x34(%rbp)
movl $0xd, -0x2c(%rbp)
movl $0xc0, -0x30(%rbp)
movl $0x4, %r15d
leaq 0x2e312(%rip), %rcx     # 0x6ed20
movq %rcx, -0x40(%rbp)
movl -0x4c(%rbp), %r14d
testl %eax, %eax
je 0x40c4d
leal 0x5(%r15), %ecx
movq %rcx, -0xa0(%rbp)
leaq 0x10(%rbx), %rcx
movq %rcx, -0x98(%rbp)
leaq 0x6f148(%rbx), %rcx
movq %rcx, -0x90(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl -0x70(%rbp), %ecx
movl %ecx, -0x68(%rbp)
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
movl %ecx, -0x6c(%rbp)
leal 0x18(%r15), %eax
movl %eax, -0x64(%rbp)
xorl %edx, %edx
movq %r13, -0x58(%rbp)
movq %r15, -0x78(%rbp)
movq %rbx, -0x60(%rbp)
movq -0x80(%rbp), %r12
movq -0xa0(%rbp), %rax
addl %r14d, %eax
movl 0x9f0c0(%rbx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x40c4d
movl %edx, -0x44(%rbp)
movq -0x80(%rbp), %r13
movq %r13, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x4e341
movl %eax, %ebx
leal (%r14,%r15), %esi
movq %r13, %rdi
movl $0x5, %edx
callq 0x4e341
movq %r15, %r13
movl %eax, %r15d
movl $0x1b8, %edx            # imm = 0x1B8
leaq -0x260(%rbp), %rdi
xorl %esi, %esi
callq 0x8390
testl %r15d, %r15d
jle 0x40b97
addl -0x64(%rbp), %r14d
movl %r14d, %r13d
movl %ebx, %ecx
leal -0x13(%r13), %r14d
movq -0x60(%rbp), %rax
movl 0x9f0c0(%rax), %eax
shll $0x3, %eax
cmpl %eax, %r13d
jg 0x40b8d
movq %r12, %rdi
movl %r14d, %esi
movl $0x5, %edx
callq 0x4e341
movl %eax, %r14d
leal -0xe(%r13), %esi
movq %r12, %rdi
movl $0xe, %edx
callq 0x4e390
cmpl -0x2c(%rbp), %r14d
jle 0x40b4c
movl $0x2, %edi
leaq 0x2edec(%rip), %rsi     # 0x6f929
movl -0x34(%rbp), %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x4ded0
jmp 0x40b77
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x2ac65(%rip), %xmm0    # 0x6b7c0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movslq %r14d, %rax
movq -0x40(%rbp), %rcx
movslq (%rcx,%rax,4), %rax
movsd %xmm0, -0x268(%rbp,%rax,8)
addl $0x13, %r13d
decl %r15d
movl %ebx, %ecx
jne 0x40aed
addl $-0x13, %r13d
movl %r13d, %r14d
movq -0x58(%rbp), %r13
movq -0x78(%rbp), %r15
jmp 0x40ba7
addl %r13d, %r14d
addl $0x5, %r14d
movq %r13, %r15
movq -0x58(%rbp), %r13
movl %ebx, %ecx
addl -0x30(%rbp), %ecx
movl %r13d, %edi
movl %ecx, %ebx
movl %ecx, %esi
callq 0x4dbc5
testl %eax, %eax
je 0x40c23
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 0x40bfc
movb $0x1, 0x490(%rax)
jmp 0x40c3b
movl $0x2, %edi
leaq 0x2ec14(%rip), %rsi     # 0x6f843
movl -0x34(%rbp), %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4ded0
movl -0x44(%rbp), %edx
movq -0x60(%rbp), %rbx
incl %edx
cmpl -0x6c(%rbp), %edx
jne 0x40a7f
xorl %ecx, %ecx
cmpl $0x0, -0x48(%rbp)
movl %r14d, -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