// File: 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
subq $0x240, %rsp            # imm = 0x240
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, -0x200(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x208(%rbp), %rdx
leaq -0x20c(%rbp), %rcx
leaq -0x28(%rbp), %r8
leaq -0x1f4(%rbp), %r9
callq 0x7aeb0
movl %eax, -0x210(%rbp)
cmpl $0x0, %eax
jge 0x76621
movl -0x200(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0x9f0c0(%rax), %ecx
movl $0x2, %edi
leaq 0x4ab5e(%rip), %rsi     # 0xc116c
movb $0x0, %al
callq 0x8b980
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x76b1c
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x230(%rbp)
subl $0x1f, %eax
ja 0x7675a
movq -0x230(%rbp), %rax
leaq 0x4a54a(%rip), %rcx     # 0xc0b90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, -0x220(%rbp)
movl $0x0, -0x224(%rbp)
leaq 0x4a926(%rip), %rax     # 0xc0f90
movq %rax, -0x20(%rbp)
movl $0x11, -0x228(%rbp)
jmp 0x76775
movl $0x5, -0x220(%rbp)
movl $0x0, -0x224(%rbp)
leaq 0x4a948(%rip), %rax     # 0xc0fe0
movq %rax, -0x20(%rbp)
movl $0x4, -0x228(%rbp)
jmp 0x76775
movl $0x6, -0x220(%rbp)
movl $0x0, -0x224(%rbp)
leaq 0x4a92a(%rip), %rax     # 0xc0ff0
movq %rax, -0x20(%rbp)
movl $0x13, -0x228(%rbp)
jmp 0x76775
movl $0x4, -0x220(%rbp)
movl $0xc0, -0x224(%rbp)
leaq 0x4a94c(%rip), %rax     # 0xc1040
movq %rax, -0x20(%rbp)
movl $0xd, -0x228(%rbp)
jmp 0x76775
movl $0x6, -0x220(%rbp)
movl $0x1, -0x224(%rbp)
leaq 0x4a961(%rip), %rax     # 0xc1080
movq %rax, -0x20(%rbp)
movl $0x9, -0x228(%rbp)
jmp 0x76775
movl $0x6, -0x220(%rbp)
movl $0x78, -0x224(%rbp)
leaq 0x4a966(%rip), %rax     # 0xc10b0
movq %rax, -0x20(%rbp)
movl $0x4, -0x228(%rbp)
jmp 0x76775
movl -0x208(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x76b1c
movl $0x0, -0x1f8(%rbp)
movl -0x1f8(%rbp), %ecx
xorl %eax, %eax
cmpl -0x210(%rbp), %ecx
movb %al, -0x231(%rbp)
jge 0x767bc
movl -0x1f4(%rbp), %eax
addl $0x5, %eax
addl -0x220(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0x231(%rbp)
movb -0x231(%rbp), %al
testb $0x1, %al
jne 0x767cb
jmp 0x76b06
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1f4(%rbp), %esi
movl -0x220(%rbp), %edx
callq 0x8bfc0
addl -0x224(%rbp), %eax
movl %eax, -0x214(%rbp)
movl -0x220(%rbp), %eax
addl -0x1f4(%rbp), %eax
movl %eax, -0x1f4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1f4(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x21c(%rbp)
movl -0x1f4(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x1f4(%rbp)
movl $0x0, -0x1fc(%rbp)
cmpl $0x37, -0x1fc(%rbp)
jge 0x7686c
movslq -0x1fc(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x1f0(%rbp,%rax,8)
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0x7683f
movl $0x0, -0x1fc(%rbp)
movl -0x1fc(%rbp), %ecx
xorl %eax, %eax
cmpl -0x21c(%rbp), %ecx
movb %al, -0x232(%rbp)
jge 0x768ad
movl -0x1f4(%rbp), %eax
addl $0x13, %eax
movq -0x10(%rbp), %rcx
movl 0x9f0c0(%rcx), %ecx
shll $0x3, %ecx
cmpl %ecx, %eax
setle %al
movb %al, -0x232(%rbp)
movb -0x232(%rbp), %al
testb $0x1, %al
jne 0x768bc
jmp 0x76999
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1f4(%rbp), %esi
movl $0x5, %edx
callq 0x8bfc0
movl %eax, -0x204(%rbp)
movl -0x1f4(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x1f4(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1f4(%rbp), %esi
movl $0xe, %edx
callq 0x8c050
cvtsi2sd %eax, %xmm0
movsd 0x46e75(%rip), %xmm1    # 0xbd788
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x1f4(%rbp), %eax
addl $0xe, %eax
movl %eax, -0x1f4(%rbp)
movl -0x204(%rbp), %eax
cmpl -0x228(%rbp), %eax
jg 0x76964
movsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x20(%rbp), %rax
movslq -0x204(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0x1f0(%rbp,%rax,8)
jmp 0x76983
movl -0x200(%rbp), %edx
movl -0x204(%rbp), %ecx
movl $0x2, %edi
leaq 0x4b1d2(%rip), %rsi     # 0xc1b4e
movb $0x0, %al
callq 0x8b980
jmp 0x76985
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0x76876
movl -0x14(%rbp), %edi
movl -0x214(%rbp), %esi
callq 0x8b1b0
movl %eax, -0x218(%rbp)
cmpl $0x0, %eax
jne 0x769d6
movl -0x200(%rbp), %edx
movl -0x214(%rbp), %ecx
movl $0x2, %edi
leaq 0x4b09e(%rip), %rsi     # 0xc1a68
movb $0x0, %al
callq 0x8b980
jmp 0x76af2
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x218(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movq 0x10(%rcx), %rdx
movq %rdx, 0x40(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x48(%rax)
movsd -0x28(%rbp), %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x218(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd %xmm0, 0x80(%rax)
movl -0x20c(%rbp), %ecx
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x218(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x498, %rdx, %rdx      # imm = 0x498
addq %rdx, %rax
movl %ecx, 0xa0(%rax)
movl $0x0, -0x1fc(%rbp)
cmpl $0x37, -0x1fc(%rbp)
jge 0x76acb
movslq -0x1fc(%rbp), %rax
movsd -0x1f0(%rbp,%rax,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x218(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movslq -0x1fc(%rbp), %rcx
movss %xmm0, 0x108(%rax,%rcx,4)
movl -0x1fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1fc(%rbp)
jmp 0x76a6d
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movl -0x218(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movb $0x1, 0x490(%rax)
movl -0x1f8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f8(%rbp)
jmp 0x7677f
movl -0x208(%rbp), %edx
movl $0xa, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
nopl (%rax,%rax)