// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_ssr4(bamboo::rtcm_t*, int, int)
static int encode_ssr4(rtcm_t *rtcm, int sys, int sync)
{
    double udint=0.0;
    int i,j,iod=0,nsat,prn,iode,iodcrc,refd=0,np,ni,nj,offp;
    int deph[3],ddeph[3],dclk[3];
    
    trace(3,"encode_ssr4: sys=%d sync=%d\n",sys,sync);
    
    switch (sys) {
        case SYS_GPS: np=6; ni= 8; nj= 0; offp=  0; break;
        case SYS_GLO: np=5; ni= 8; nj= 0; offp=  0; break;
        case SYS_GAL: np=6; ni=10; nj= 0; offp=  0; break;
        case SYS_QZS: np=4; ni= 8; nj= 0; offp=192; break;
        case SYS_CMP: np=6; ni=10; nj=24; offp=  1; break;
        case SYS_SBS: np=6; ni= 9; nj=24; offp=120; break;
        default: return 0;
    }
    /* number of satellites */
    for (j=nsat=0;j<MAXRTKSAT;j++) {
        if (satsys(j+1,&prn)!=sys||!rtcm->ssr[j].update) continue;
        nsat++;
        udint=rtcm->ssr[j].udi[0];
        iod  =rtcm->ssr[j].iod[0];
        refd =rtcm->ssr[j].refd;
    }
    /* encode ssr header */
    i=encode_ssr_head(4,rtcm,sys,nsat,sync,iod,udint,refd,0,0);
    
    for (j=0;j<MAXRTKSAT;j++) {
        if (satsys(j+1,&prn)!=sys||!rtcm->ssr[j].update) continue;
        
        iode=rtcm->ssr[j].iode;
        iodcrc=rtcm->ssr[j].iodcrc;
        
        deph [0]=ROUND(rtcm->ssr[j].deph [0]/1E-4);
        deph [1]=ROUND(rtcm->ssr[j].deph [1]/4E-4);
        deph [2]=ROUND(rtcm->ssr[j].deph [2]/4E-4);
        ddeph[0]=ROUND(rtcm->ssr[j].ddeph[0]/1E-6);
        ddeph[1]=ROUND(rtcm->ssr[j].ddeph[1]/4E-6);
        ddeph[2]=ROUND(rtcm->ssr[j].ddeph[2]/4E-6);
        dclk [0]=ROUND(rtcm->ssr[j].dclk [0]/1E-4);
        dclk [1]=ROUND(rtcm->ssr[j].dclk [1]/1E-6);
        dclk [2]=ROUND(rtcm->ssr[j].dclk [2]/1E-8);
        
        setbitu(rtcm->buff,i,np,prn-offp); i+=np; /* satellite id */
        setbitu(rtcm->buff,i,ni,iode    ); i+=ni; /* iode */
        setbitu(rtcm->buff,i,nj,iodcrc  ); i+=nj; /* iodcrc */
        setbits(rtcm->buff,i,22,deph [0]); i+=22; /* delta raidal */
        setbits(rtcm->buff,i,20,deph [1]); i+=20; /* delta along-track */
        setbits(rtcm->buff,i,20,deph [2]); i+=20; /* delta cross-track */
        setbits(rtcm->buff,i,21,ddeph[0]); i+=21; /* dot delta radial */
        setbits(rtcm->buff,i,19,ddeph[1]); i+=19; /* dot delta along-track */
        setbits(rtcm->buff,i,19,ddeph[2]); i+=19; /* dot delta cross-track */
        setbits(rtcm->buff,i,22,dclk [0]); i+=22; /* delta clock c0 */
        setbits(rtcm->buff,i,21,dclk [1]); i+=21; /* delta clock c1 */
        setbits(rtcm->buff,i,27,dclk [2]); i+=27; /* delta clock c2 */
    }
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x3d2a8(%rip), %rsi     # 0xc2880
xorl %eax, %eax
movl $0x3, %edi
callq 0x8b980
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x80(%rbp)
subl $0x1f, %eax
ja 0x856c6
movq -0x80(%rbp), %rax
leaq 0x3ca2d(%rip), %rcx     # 0xc2030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, -0x44(%rbp)
movl $0x8, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x856d2
movl $0x5, -0x44(%rbp)
movl $0x8, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x856d2
movl $0x6, -0x44(%rbp)
movl $0xa, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
jmp 0x856d2
movl $0x4, -0x44(%rbp)
movl $0x8, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0xc0, -0x50(%rbp)
jmp 0x856d2
movl $0x6, -0x44(%rbp)
movl $0xa, -0x48(%rbp)
movl $0x18, -0x4c(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x856d2
movl $0x6, -0x44(%rbp)
movl $0x9, -0x48(%rbp)
movl $0x18, -0x4c(%rbp)
movl $0x78, -0x50(%rbp)
jmp 0x856d2
movl $0x0, -0x4(%rbp)
jmp 0x85c9f
movl $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x9b, -0x28(%rbp)
jge 0x8579f
movl -0x28(%rbp), %edi
addl $0x1, %edi
leaq -0x34(%rbp), %rsi
callq 0x8b3b0
cmpl -0x14(%rbp), %eax
jne 0x85722
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
cmpb $0x0, 0x490(%rax)
jne 0x85724
jmp 0x85791
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0x60(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movl 0x90(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movl 0xb4(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x856e0
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x30(%rbp), %ecx
movl -0x18(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movsd -0x20(%rbp), %xmm0
movl -0x40(%rbp), %eax
movl $0x4, %edi
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x885f0
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x9b, -0x28(%rbp)
jge 0x85c8b
movl -0x28(%rbp), %edi
addl $0x1, %edi
leaq -0x34(%rbp), %rsi
callq 0x8b3b0
cmpl -0x14(%rbp), %eax
jne 0x85825
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
cmpb $0x0, 0x490(%rax)
jne 0x8582a
jmp 0x85c7d
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movl 0xa8(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movl 0xac(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xb8(%rax), %xmm0
movsd 0x375d4(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
movsd 0x375e0(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xc0(%rax), %xmm0
movsd 0x3b140(%rip), %xmm1    # 0xc0a18
divsd %xmm1, %xmm0
movsd 0x3759c(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xc8(%rax), %xmm0
movsd 0x3b0fc(%rip), %xmm1    # 0xc0a18
divsd %xmm1, %xmm0
movsd 0x37558(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xd0(%rax), %xmm0
movsd 0x39470(%rip), %xmm1    # 0xbedd0
divsd %xmm1, %xmm0
movsd 0x37514(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xd8(%rax), %xmm0
movsd 0x3b06c(%rip), %xmm1    # 0xc0a10
divsd %xmm1, %xmm0
movsd 0x374d0(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xe0(%rax), %xmm0
movsd 0x3b028(%rip), %xmm1    # 0xc0a10
divsd %xmm1, %xmm0
movsd 0x3748c(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xe8(%rax), %xmm0
movsd 0x3743c(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
movsd 0x37448(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xf0(%rax), %xmm0
movsd 0x39360(%rip), %xmm1    # 0xbedd0
divsd %xmm1, %xmm0
movsd 0x37404(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x70(%rbp)
movq -0x10(%rbp), %rax
addq $0x6f148, %rax          # imm = 0x6F148
movslq -0x28(%rbp), %rcx
imulq $0x498, %rcx, %rcx      # imm = 0x498
addq %rcx, %rax
movsd 0xf8(%rax), %xmm0
movsd 0x3c304(%rip), %xmm1    # 0xc1db8
divsd %xmm1, %xmm0
movsd 0x373c0(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x34(%rbp), %ecx
subl -0x50(%rbp), %ecx
callq 0x8c0d0
movl -0x44(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x48(%rbp), %edx
movl -0x38(%rbp), %ecx
callq 0x8c0d0
movl -0x48(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x3c(%rbp), %ecx
callq 0x8c0d0
movl -0x4c(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x5c(%rbp), %ecx
movl $0x16, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x16, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x58(%rbp), %ecx
movl $0x14, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x54(%rbp), %ecx
movl $0x14, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x68(%rbp), %ecx
movl $0x15, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x15, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x64(%rbp), %ecx
movl $0x13, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x13, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x60(%rbp), %ecx
movl $0x13, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x13, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x74(%rbp), %ecx
movl $0x16, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x16, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x70(%rbp), %ecx
movl $0x15, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x15, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x6c(%rbp), %ecx
movl $0x1b, %edx
callq 0x8c1d0
movl -0x24(%rbp), %eax
addl $0x1b, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x857e3
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9f0bc(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax,%rax)