// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r12d
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x2530d(%rip), %rsi     # 0x66536
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r14d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x455bc
pushq $0x6
popq %rdx
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x41269
leaq 0x24d5d(%rip), %rcx     # 0x65fac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r12d, -0x48(%rbp)
jmpq *%rax
movq %rdx, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x412ae
cmpl $0x10, %r14d
je 0x4129c
cmpl $0x20, %r14d
jne 0x414a0
movl %r12d, -0x48(%rbp)
movq %rdx, -0x38(%rbp)
pushq $-0x1
jmp 0x41296
movl $0x0, -0x2c(%rbp)
pushq $0x5
jmp 0x412a9
movq %rdx, -0x38(%rbp)
pushq $-0x78
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x412ae
movl %r12d, -0x48(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
pushq $0x4
popq %rax
movq %rax, -0x38(%rbp)
movq %rbx, -0x68(%rbp)
leaq 0x6f1b0(%rbx), %r15
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
xorl %ebx, %ebx
leaq -0x5c(%rbp), %r13
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x50(%rbp)
imulq $0x498, %rbx, %r12      # imm = 0x498
incq %rbx
addq %r15, %r12
cmpq $0x9c, %rbx
je 0x41329
movl %ebx, %edi
movq %r13, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x41305
cmpb $0x0, 0x428(%r12)
jne 0x41311
incq %rbx
addq $0x498, %r12            # imm = 0x498
jmp 0x412e2
incl -0x50(%rbp)
movsd (%r12), %xmm0
movsd %xmm0, -0x58(%rbp)
movl 0x2c(%r12), %eax
movl %eax, -0x3c(%rbp)
jmp 0x412d5
andl $0x0, (%rsp)
pushq $0x2
popq %rdi
movq -0x68(%rbp), %rbx
movq %rbx, %rsi
movl %r14d, %edx
movl -0x50(%rbp), %ecx
movl -0x48(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movsd -0x58(%rbp), %xmm0
callq 0x437dc
movq %rax, -0x58(%rbp)
leaq 0x9f0c4(%rbx), %rax
movq %rax, -0x50(%rbp)
leaq 0x6f230(%rbx), %r13
xorl %r15d, %r15d
leaq -0x5c(%rbp), %r12
imulq $0x498, %r15, %rbx      # imm = 0x498
incq %r15
addq %r13, %rbx
cmpq $0x9c, %r15
je 0x4148e
movl %r15d, %edi
movq %r12, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x4139f
cmpb $0x0, 0x3a8(%rbx)
jne 0x413ab
incq %r15
addq $0x498, %rbx            # imm = 0x498
jmp 0x41379
movsd (%rbx), %xmm0
movsd 0x8(%rbx), %xmm1
movsd %xmm1, -0x48(%rbp)
divsd 0x1f54f(%rip), %xmm0    # 0x60910
movsd 0x208af(%rip), %xmm1    # 0x61c78
addsd %xmm1, %xmm0
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movsd -0x48(%rbp), %xmm0
divsd 0x2185a(%rip), %xmm0    # 0x62c40
addsd 0x2088a(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%rbp)
movsd 0x10(%rbx), %xmm0
divsd 0x24801(%rip), %xmm0    # 0x65c08
addsd 0x20869(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq -0x58(%rbp), %rbx
movq -0x50(%rbp), %rdi
movl %ebx, %esi
movq -0x38(%rbp), %rdx
callq 0x45a69
movq -0x38(%rbp), %rax
leal (%rbx,%rax), %esi
movq -0x50(%rbp), %rdi
pushq $0x16
popq %rdx
movl -0x3c(%rbp), %ecx
callq 0x45ae0
movq -0x38(%rbp), %rax
leal (%rbx,%rax), %esi
addl $0x16, %esi
movq -0x50(%rbp), %rdi
pushq $0x15
popq %rdx
movl -0x48(%rbp), %ecx
callq 0x45ae0
movq -0x38(%rbp), %rax
leal (%rbx,%rax), %esi
addl $0x2b, %esi
movq -0x50(%rbp), %rdi
pushq $0x1b
popq %rdx
movl -0x60(%rbp), %ecx
callq 0x45ae0
movq -0x38(%rbp), %rax
addl %eax, %ebx
addl $0x46, %ebx
movq %rbx, -0x58(%rbp)
jmp 0x4136c
movq -0x68(%rbp), %rax
movq -0x58(%rbp), %rcx
movl %ecx, 0x9f0bc(%rax)
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq