// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_ssr2(bamboo::rtcm_t*, int, int)
static int encode_ssr2(rtcm_t *rtcm, int sys, int sync)
{
    double udint=0.0;
    int i,j,iod=0,nsat,prn,np,offp,iode,dclk[3];
    
    trace(3,"encode_ssr2: sys=%d sync=%d\n",sys,sync);
    
    switch (sys) {
        case SYS_GPS: np=6; offp=  0; break;
        case SYS_GLO: np=5; offp=  0; break;
        case SYS_GAL: np=6; offp=  0; break;
        case SYS_QZS: np=4; offp=192; break;
        case SYS_CMP: np=6; offp=  1; break;
        case SYS_SBS: np=6; 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[1];
        iod  =rtcm->ssr[j].iod[1];
    }
    /* encode ssr header */
    i=encode_ssr_head(2,rtcm,sys,nsat,sync,iod,udint,0,0,0);
    
    for (j=0;j<MAXRTKSAT;j++) {
        if (satsys(j+1,&prn)!=sys||!rtcm->ssr[j].update) continue;
        
        iode=rtcm->ssr[j].iode;
        
        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 */
        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 $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x3da88(%rip), %rsi     # 0xc2846
xorl %eax, %eax
movl $0x3, %edi
callq 0x8b980
movl -0x14(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x1f, %eax
ja 0x84e4e
movq -0x58(%rbp), %rax
leaq 0x3d14b(%rip), %rcx     # 0xc1f30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x6, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
jmp 0x84e5a
movl $0x5, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
jmp 0x84e5a
movl $0x6, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
jmp 0x84e5a
movl $0x4, -0x38(%rbp)
movl $0xc0, -0x3c(%rbp)
jmp 0x84e5a
movl $0x6, -0x38(%rbp)
movl $0x1, -0x3c(%rbp)
jmp 0x84e5a
movl $0x6, -0x38(%rbp)
movl $0x78, -0x3c(%rbp)
jmp 0x84e5a
movl $0x0, -0x4(%rbp)
jmp 0x85131
movl $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x9b, -0x28(%rbp)
jge 0x84f06
movl -0x28(%rbp), %edi
addl $0x1, %edi
leaq -0x34(%rbp), %rsi
callq 0x8b3b0
cmpl -0x14(%rbp), %eax
jne 0x84eaa
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 0x84eac
jmp 0x84ef8
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 0x68(%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 0x94(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x84e68
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 $0x2, %edi
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x885f0
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
cmpl $0x9b, -0x28(%rbp)
jge 0x8511d
movl -0x28(%rbp), %edi
addl $0x1, %edi
leaq -0x34(%rbp), %rsi
callq 0x8b3b0
cmpl -0x14(%rbp), %eax
jne 0x84f8c
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 0x84f91
jmp 0x8510f
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, -0x40(%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 0x37e8e(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
movsd 0x37e9a(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x4c(%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 0x39db2(%rip), %xmm1    # 0xbedd0
divsd %xmm1, %xmm0
movsd 0x37e56(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%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 0x3cd56(%rip), %xmm1    # 0xc1db8
divsd %xmm1, %xmm0
movsd 0x37e12(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x24(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x34(%rbp), %ecx
subl -0x3c(%rbp), %ecx
callq 0x8c0d0
movl -0x38(%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), %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 -0x48(%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 -0x44(%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 0x84f4a
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9f0bc(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)