// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %edx, %r12d
movl %esi, %ebx
movq %rdi, %r14
leaq 0x26c96(%rip), %rsi     # 0x70556
xorl %r15d, %r15d
movl $0x3, %edi
movl %ebx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x4ded0
movl $0x6, %eax
movq %rax, -0x50(%rbp)
leal -0x1(%rbx), %eax
cmpl $0x7, %eax
movq %rbx, -0x58(%rbp)
ja 0x49906
leaq 0x2657c(%rip), %rcx     # 0x6fe6c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r12d, -0x38(%rbp)
jmpq *%rax
movl $0x0, -0x2c(%rbp)
jmp 0x4994c
cmpl $0x10, %ebx
je 0x49938
cmpl $0x20, %ebx
jne 0x49b42
movl %r12d, -0x38(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4994c
movl $0x0, -0x2c(%rbp)
movl $0x5, %eax
jmp 0x49948
movl $0xffffff88, -0x2c(%rbp) # imm = 0xFFFFFF88
jmp 0x4994c
movl %r12d, -0x38(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
movl $0x4, %eax
movq %rax, -0x50(%rbp)
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x6f1b0, %ebx          # imm = 0x6F1B0
movl $0x1, %r12d
leaq -0x3c(%rbp), %r13
movl $0x0, -0x30(%rbp)
movl %r12d, %edi
movq %r13, %rsi
callq 0x4dc2a
cmpl -0x58(%rbp), %eax
jne 0x4999e
cmpb $0x0, 0x428(%r14,%rbx)
je 0x4999e
incl %r15d
movsd (%r14,%rbx), %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0x2c(%r14,%rbx), %eax
movl %eax, -0x30(%rbp)
addq $0x498, %rbx            # imm = 0x498
incl %r12d
cmpq $0x9b9b8, %rbx          # imm = 0x9B9B8
jne 0x4996d
movl $0x0, (%rsp)
movl $0x2, %edi
movq %r14, %rsi
movq -0x58(%rbp), %rdx
movl %r15d, %ecx
movq %rdx, %r13
movl -0x38(%rbp), %r8d
movl -0x30(%rbp), %r9d
movsd -0x48(%rbp), %xmm0
callq 0x4bffb
movq %rax, -0x48(%rbp)
movq %r14, -0x68(%rbp)
leaq 0x9f0c4(%r14), %rax
movq %rax, -0x70(%rbp)
movl $0x1, %r12d
xorl %r14d, %r14d
leaq -0x3c(%rbp), %r15
movl %r12d, %edi
movq %r15, %rsi
callq 0x4dc2a
cmpl %r13d, %eax
jne 0x49b17
movq -0x68(%rbp), %rbx
cmpb $0x0, 0x6f5d8(%rbx,%r14)
je 0x49b17
movsd 0x6f230(%rbx,%r14), %xmm0
movsd 0x6f238(%rbx,%r14), %xmm1
movsd %xmm1, -0x38(%rbp)
divsd 0x20edc(%rip), %xmm0    # 0x6a920
movsd 0x2222c(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x30(%rbp)
movsd -0x38(%rbp), %xmm0
divsd 0x231d7(%rip), %xmm0    # 0x6cc40
addsd 0x22207(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movsd 0x6f240(%rbx,%r14), %xmm0
divsd 0x266d1(%rip), %xmm0    # 0x70160
addsd 0x221e1(%rip), %xmm0    # 0x6bc78
callq 0x8ad0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movl -0x3c(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq -0x70(%rbp), %r13
movq %r13, %rdi
movq -0x48(%rbp), %r15
movl %r15d, %esi
movq -0x50(%rbp), %rbx
movl %ebx, %edx
callq 0x4e403
leal (%r15,%rbx), %esi
movq %r13, %rdi
movl $0x16, %edx
movl -0x30(%rbp), %ecx
callq 0x4e47b
leal (%r15,%rbx), %esi
addl $0x16, %esi
movq %r13, %rdi
movl $0x15, %edx
movl -0x38(%rbp), %ecx
callq 0x4e47b
leal (%r15,%rbx), %esi
addl $0x2b, %esi
movq %r13, %rdi
movq -0x58(%rbp), %r13
movl $0x1b, %edx
movl -0x5c(%rbp), %ecx
callq 0x4e47b
addl %ebx, %r15d
addl $0x46, %r15d
movq %r15, -0x48(%rbp)
leaq -0x3c(%rbp), %r15
addq $0x498, %r14            # imm = 0x498
incl %r12d
cmpq $0x2c808, %r14          # imm = 0x2C808
jne 0x499fc
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %ecx, 0x9f0bc(%rax)
movl $0x1, %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq