// File: /workspace/github_cpp_makefile_star2_O2/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 $0x228, %rsp            # imm = 0x228
movl %esi, %r14d
movq %rdi, %r13
leaq 0x9f0c4(%rdi), %r12
pushq $0x18
popq %rsi
pushq $0xc
popq %rdx
movq %r12, %rdi
callq 0x459f7
movl %eax, %r15d
leaq -0x48(%rbp), %rdx
leaq -0x60(%rbp), %rcx
leaq -0x98(%rbp), %r8
leaq -0x64(%rbp), %r9
movq %r13, %rdi
movl %r14d, %esi
callq 0x3b973
movl %eax, -0x5c(%rbp)
testl %eax, %eax
js 0x3915f
pushq $0x6
popq %rax
movq %rax, -0x50(%rbp)
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x39182
movl $0x0, -0x30(%rbp)
leaq 0x2baec(%rip), %rcx     # 0x64c2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r15d, -0x34(%rbp)
jmpq *%rax
pushq $0x11
popq %rax
movl %eax, -0x2c(%rbp)
leaq 0x2bc16(%rip), %rax     # 0x64d70
jmp 0x39204
movl 0x9f0c0(%r13), %ecx
leaq 0x2bdd6(%rip), %rsi     # 0x64f43
pushq $0x2
popq %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x455bc
pushq $-0x1
popq %rax
jmp 0x393fc
cmpl $0x10, %r14d
je 0x391e5
cmpl $0x20, %r14d
jne 0x393f0
movl %r15d, -0x34(%rbp)
pushq $0x9
popq %rax
movl %eax, -0x2c(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x30(%rbp)
leaq 0x2bca7(%rip), %rax     # 0x64e50
jmp 0x39204
pushq $0x13
popq %rax
movl %eax, -0x2c(%rbp)
leaq 0x2bc08(%rip), %rax     # 0x64dc0
jmp 0x39204
pushq $0x4
popq %rax
movl %eax, -0x2c(%rbp)
pushq $0x78
popq %rax
movl %eax, -0x30(%rbp)
leaq 0x2b5e3(%rip), %rax     # 0x647b0
jmp 0x39204
pushq $0x4
popq %rax
movl %eax, -0x2c(%rbp)
pushq $0x5
popq %rax
movq %rax, -0x50(%rbp)
leaq 0x2b5bd(%rip), %rax     # 0x647a0
jmp 0x39204
movl %r15d, -0x34(%rbp)
pushq $0xd
popq %rax
movl %eax, -0x2c(%rbp)
movl $0xc0, -0x30(%rbp)
pushq $0x4
popq %rax
movq %rax, -0x50(%rbp)
leaq 0x2bc0c(%rip), %rax     # 0x64e10
movq %rax, -0x40(%rbp)
movl -0x64(%rbp), %r15d
movq -0x50(%rbp), %rax
leal 0x5(%rax), %ecx
movq %rcx, -0x90(%rbp)
leaq 0x10(%r13), %rcx
movq %rcx, -0x80(%rbp)
leaq 0x6f148(%r13), %rcx
movq %rcx, -0x78(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x60(%rbp), %ecx
movl %ecx, -0x54(%rbp)
addl $0x18, %eax
movl %eax, -0x58(%rbp)
xorl %edx, %edx
movq %r14, -0x88(%rbp)
cmpl -0x5c(%rbp), %edx
je 0x393f0
movq -0x90(%rbp), %rax
addl %r15d, %eax
movl 0x9f0c0(%r13), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
jg 0x393f0
movl %edx, -0x44(%rbp)
movq %r12, %rdi
movl %r15d, %esi
movq -0x50(%rbp), %r14
movl %r14d, %edx
callq 0x459f7
movl %eax, -0x38(%rbp)
leal (%r15,%r14), %esi
movq %r12, %rdi
pushq $0x5
popq %rdx
callq 0x459f7
movl %eax, %r14d
xorl %eax, %eax
cmpq $0x37, %rax
je 0x392b4
andq $0x0, -0x250(%rbp,%rax,8)
incq %rax
jmp 0x392a0
movl -0x38(%rbp), %eax
addl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
addl -0x58(%rbp), %r15d
movl %r15d, %ebx
leal -0x13(%rbx), %r15d
subl $0x1, %r14d
jb 0x39356
movl 0x9f0c0(%r13), %eax
shll $0x3, %eax
cmpl %eax, %ebx
jg 0x39356
movq %r12, %rdi
movl %r15d, %esi
pushq $0x5
popq %rdx
callq 0x459f7
movl %eax, %r15d
leal -0xe(%rbx), %esi
movq %r12, %rdi
pushq $0xe
popq %rdx
callq 0x45a39
cmpl -0x2c(%rbp), %r15d
jle 0x39326
pushq $0x2
popq %rdi
leaq 0x2c60e(%rip), %rsi     # 0x65925
movl -0x34(%rbp), %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x455bc
jmp 0x3934e
cvtsi2sd %eax, %xmm0
mulsd 0x28486(%rip), %xmm0    # 0x617b8
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movslq %r15d, %rax
movq -0x40(%rbp), %rcx
movslq (%rcx,%rax,4), %rax
movsd %xmm0, -0x258(%rbp,%rax,8)
addl $0x13, %ebx
jmp 0x392d0
movq -0x88(%rbp), %r14
movl %r14d, %edi
movl -0x38(%rbp), %ebx
movl %ebx, %esi
callq 0x452fd
testl %eax, %eax
je 0x393d0
decl %eax
cltq
imulq $0x498, %rax, %rcx      # imm = 0x498
movq -0x78(%rbp), %rsi
leaq (%rsi,%rcx), %rax
movq -0x80(%rbp), %rdx
movups (%rdx), %xmm0
movups %xmm0, 0x40(%rsi,%rcx)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x80(%rsi,%rcx)
movl -0x54(%rbp), %edx
movl %edx, 0xa0(%rsi,%rcx)
xorl %ecx, %ecx
movl -0x44(%rbp), %edx
cmpq $0x37, %rcx
je 0x393c7
cvtsd2ss -0x250(%rbp,%rcx,8), %xmm0
movss %xmm0, 0x108(%rax,%rcx,4)
incq %rcx
jmp 0x393aa
movb $0x1, 0x490(%rax)
jmp 0x393e9
pushq $0x2
popq %rdi
leaq 0x2c465(%rip), %rsi     # 0x6583f
movl -0x34(%rbp), %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x455bc
movl -0x44(%rbp), %edx
incl %edx
jmp 0x3924f
xorl %ecx, %ecx
cmpl $0x0, -0x48(%rbp)
pushq $0xa
popq %rax
cmovnel %ecx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq