// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %r15d
movl %esi, %r14d
movq %rdi, -0x80(%rbp)
leaq 0x27081(%rip), %rsi     # 0x70590
xorl %ebx, %ebx
movl $0x3, %edi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movq %r14, %rdx
movl $0x6, -0x40(%rbp)
movl $0x8, -0x34(%rbp)
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x4955b
leaq 0x26968(%rip), %rcx     # 0x6feac
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r15d, -0x30(%rbp)
jmpq *%rax
movq $0x0, -0x48(%rbp)
jmp 0x495b6
cmpl $0x10, %edx
je 0x495bf
cmpl $0x20, %edx
jne 0x49982
movl %r15d, -0x30(%rbp)
movl $0xa, -0x34(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x4959c
movq $0x0, -0x48(%rbp)
movl $0xa, -0x34(%rbp)
jmp 0x495b6
movl $0x9, -0x34(%rbp)
movl $0xffffff88, -0x2c(%rbp) # imm = 0xFFFFFF88
movl $0x18, %eax
movq %rax, -0x48(%rbp)
jmp 0x495d9
movq $0x0, -0x48(%rbp)
movl $0x5, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x495d9
movl %r15d, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x4, -0x40(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
movl $0x0, -0x3c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x6f1a8, %r15d         # imm = 0x6F1A8
movl $0x1, %r14d
leaq -0x4c(%rbp), %r12
xorl %r13d, %r13d
movl $0x0, -0x38(%rbp)
movq -0x80(%rbp), %rbx
movq %rdx, -0x88(%rbp)
movl %r14d, %edi
movq %r12, %rsi
callq 0x4d2f2
movq -0x88(%rbp), %rdx
cmpl %edx, %eax
jne 0x4964c
cmpb $0x0, 0x430(%rbx,%r15)
je 0x4964c
incl %r13d
movsd (%rbx,%r15), %xmm0
movsd %xmm0, -0x58(%rbp)
movl 0x30(%rbx,%r15), %eax
movl %eax, -0x3c(%rbp)
movl 0x54(%rbx,%r15), %eax
movl %eax, -0x38(%rbp)
addq $0x498, %r15            # imm = 0x498
incl %r14d
cmpq $0x9b9b0, %r15          # imm = 0x9B9B0
jne 0x4960d
movl -0x38(%rbp), %eax
movl %eax, (%rsp)
movl $0x4, %edi
movq %rbx, %rsi
movl %r13d, %ecx
movl -0x30(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movsd -0x58(%rbp), %xmm0
callq 0x4b64c
movl %eax, %r12d
leaq 0x9f0c4(%rbx), %r13
movl $0x1, %r14d
xorl %r15d, %r15d
movl %r14d, %edi
leaq -0x4c(%rbp), %rsi
callq 0x4d2f2
cmpl -0x88(%rbp), %eax
jne 0x4995f
cmpb $0x0, 0x6f5d8(%rbx,%r15)
je 0x4995f
movl 0x6f1f0(%rbx,%r15), %eax
movl %eax, -0x74(%rbp)
movl 0x6f1f4(%rbx,%r15), %eax
movl %eax, -0x58(%rbp)
movsd 0x6f200(%rbx,%r15), %xmm0
movsd 0x2123c(%rip), %xmm1    # 0x6a920
divsd %xmm1, %xmm0
movsd 0x22588(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movsd 0x6f208(%rbx,%r15), %xmm0
movsd 0x2574e(%rip), %xmm1    # 0x6ee60
divsd %xmm1, %xmm0
addsd 0x2255a(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movsd 0x6f210(%rbx,%r15), %xmm0
divsd 0x25724(%rip), %xmm0    # 0x6ee60
addsd 0x22534(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x30(%rbp)
movsd 0x6f218(%rbx,%r15), %xmm0
movsd 0x234de(%rip), %xmm1    # 0x6cc40
divsd %xmm1, %xmm0
addsd 0x2250a(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x70(%rbp)
movsd 0x6f220(%rbx,%r15), %xmm0
movsd 0x256cc(%rip), %xmm1    # 0x6ee58
divsd %xmm1, %xmm0
addsd 0x224e0(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
movsd 0x6f228(%rbx,%r15), %xmm0
divsd 0x256a2(%rip), %xmm0    # 0x6ee58
addsd 0x224ba(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movsd 0x6f230(%rbx,%r15), %xmm0
divsd 0x21144(%rip), %xmm0    # 0x6a920
addsd 0x22494(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movsd 0x6f238(%rbx,%r15), %xmm0
divsd 0x2343e(%rip), %xmm0    # 0x6cc40
addsd 0x2246e(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movsd 0x6f240(%rbx,%r15), %xmm0
divsd 0x26938(%rip), %xmm0    # 0x70160
addsd 0x22448(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movl -0x4c(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq %r13, %rdi
movl %r12d, %esi
movl -0x40(%rbp), %ebx
movl %ebx, %edx
callq 0x4da98
addl %ebx, %r12d
movq %r13, %rdi
movl %r12d, %esi
movl -0x34(%rbp), %ebx
movl %ebx, %edx
movl -0x74(%rbp), %ecx
callq 0x4da98
addl %ebx, %r12d
movq %r13, %rdi
movl %r12d, %esi
movq -0x48(%rbp), %rbx
movl %ebx, %edx
movl -0x58(%rbp), %ecx
callq 0x4da98
leal (%r12,%rbx), %esi
movq %r13, %rdi
movl $0x16, %edx
movl -0x3c(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x16, %esi
movq %r13, %rdi
movl $0x14, %edx
movl -0x38(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x2a, %esi
movq %r13, %rdi
movl $0x14, %edx
movl -0x30(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x3e, %esi
movq %r13, %rdi
movl $0x15, %edx
movl -0x70(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x53, %esi
movq %r13, %rdi
movl $0x13, %edx
movl -0x6c(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x66, %esi
movq %r13, %rdi
movl $0x13, %edx
movl -0x68(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x79, %esi
movq %r13, %rdi
movl $0x16, %edx
movl -0x64(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0x8f, %esi
movq %r13, %rdi
movl $0x15, %edx
movl -0x60(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r12), %esi
addl $0xa4, %esi
movq %r13, %rdi
movl $0x1b, %edx
movl -0x5c(%rbp), %ecx
callq 0x4db0c
addl %ebx, %r12d
addl $0xbf, %r12d
movq -0x80(%rbp), %rbx
addq $0x498, %r15            # imm = 0x498
incl %r14d
cmpq $0x2c808, %r15          # imm = 0x2C808
jne 0x49695
movl %r12d, 0x9f0bc(%rbx)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq