// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_ssr1(bamboo::rtcm_t*, int, int)
static int encode_ssr1(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,deph[3],ddeph[3];
    
    trace(3,"encode_ssr1: 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(1,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;      /* sbas/bds: toe/t0 modulo */
        iodcrc=rtcm->ssr[j].iodcrc;  /* sbas/bds: iod crc */
        
        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);
        
        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 radial */
        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 */
    }
    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, %r15d
movl %esi, %r14d
movq %rdi, -0x70(%rbp)
leaq 0x279a1(%rip), %rsi     # 0x704f6
xorl %ebx, %ebx
movl $0x3, %edi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movq %r14, %rdx
movl $0x8, -0x34(%rbp)
movl $0x6, -0x40(%rbp)
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x48ba1
leaq 0x272c2(%rip), %rcx     # 0x6fe4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r15d, -0x30(%rbp)
jmpq *%rax
movq $0x0, -0x48(%rbp)
jmp 0x48c05
cmpl $0x10, %edx
je 0x48c0e
cmpl $0x20, %edx
jne 0x48f00
movl %r15d, -0x30(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movl $0x18, %eax
movq %rax, -0x48(%rbp)
movl $0xa, -0x34(%rbp)
jmp 0x48c28
movq $0x0, -0x48(%rbp)
movl $0xa, -0x34(%rbp)
jmp 0x48c05
movl $0xffffff88, -0x2c(%rbp) # imm = 0xFFFFFF88
movl $0x18, %eax
movq %rax, -0x48(%rbp)
movl $0x9, -0x34(%rbp)
jmp 0x48c28
movq $0x0, -0x48(%rbp)
movl $0x5, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x48c28
movl %r15d, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
movl $0x4, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x6f1a8, %r15d         # imm = 0x6F1A8
movl $0x1, %r12d
leaq -0x4c(%rbp), %r13
xorl %r14d, %r14d
movl $0x0, -0x38(%rbp)
movq -0x70(%rbp), %rbx
movq %rdx, -0x78(%rbp)
movl %r12d, %edi
movq %r13, %rsi
callq 0x4d2f2
movq -0x78(%rbp), %rdx
cmpl %edx, %eax
jne 0x48c95
cmpb $0x0, 0x430(%rbx,%r15)
je 0x48c95
incl %r14d
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 %r12d
cmpq $0x9b9b0, %r15          # imm = 0x9B9B0
jne 0x48c59
movl -0x38(%rbp), %eax
movl %eax, (%rsp)
movl $0x1, %r12d
movl $0x1, %edi
movq %rbx, %rsi
movl %r14d, %ecx
movl -0x30(%rbp), %r8d
movl -0x3c(%rbp), %r9d
movsd -0x58(%rbp), %xmm0
callq 0x4b64c
movl %eax, %r13d
leaq 0x9f0c4(%rbx), %r14
xorl %r15d, %r15d
movl %r12d, %edi
leaq -0x4c(%rbp), %rsi
callq 0x4d2f2
cmpl -0x78(%rbp), %eax
jne 0x48edd
cmpb $0x0, 0x6f5d8(%rbx,%r15)
je 0x48edd
movl 0x6f1f0(%rbx,%r15), %eax
movl %eax, -0x68(%rbp)
movl 0x6f1f4(%rbx,%r15), %eax
movl %eax, -0x58(%rbp)
movsd 0x6f200(%rbx,%r15), %xmm0
divsd 0x21bf6(%rip), %xmm0    # 0x6a920
movsd 0x22f46(%rip), %xmm1    # 0x6bc78
addsd %xmm1, %xmm0
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movsd 0x6f208(%rbx,%r15), %xmm0
movsd 0x2610c(%rip), %xmm1    # 0x6ee60
divsd %xmm1, %xmm0
addsd 0x22f18(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movsd 0x6f210(%rbx,%r15), %xmm0
divsd 0x260e2(%rip), %xmm0    # 0x6ee60
addsd 0x22ef2(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x30(%rbp)
movsd 0x6f218(%rbx,%r15), %xmm0
divsd 0x23e9c(%rip), %xmm0    # 0x6cc40
addsd 0x22ecc(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movsd 0x6f220(%rbx,%r15), %xmm0
movsd 0x2608e(%rip), %xmm1    # 0x6ee58
divsd %xmm1, %xmm0
addsd 0x22ea2(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movsd 0x6f228(%rbx,%r15), %xmm0
divsd 0x26064(%rip), %xmm0    # 0x6ee58
addsd 0x22e7c(%rip), %xmm0    # 0x6bc78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x5c(%rbp)
movl -0x4c(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq %r14, %rdi
movl %r13d, %esi
movl -0x40(%rbp), %ebx
movl %ebx, %edx
callq 0x4da98
addl %ebx, %r13d
movq %r14, %rdi
movl %r13d, %esi
movl -0x34(%rbp), %ebx
movl %ebx, %edx
movl -0x68(%rbp), %ecx
callq 0x4da98
addl %ebx, %r13d
movq %r14, %rdi
movl %r13d, %esi
movq -0x48(%rbp), %rbx
movl %ebx, %edx
movl -0x58(%rbp), %ecx
callq 0x4da98
leal (%rbx,%r13), %esi
movq %r14, %rdi
movl $0x16, %edx
movl -0x3c(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r13), %esi
addl $0x16, %esi
movq %r14, %rdi
movl $0x14, %edx
movl -0x38(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r13), %esi
addl $0x2a, %esi
movq %r14, %rdi
movl $0x14, %edx
movl -0x30(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r13), %esi
addl $0x3e, %esi
movq %r14, %rdi
movl $0x15, %edx
movl -0x64(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r13), %esi
addl $0x53, %esi
movq %r14, %rdi
movl $0x13, %edx
movl -0x60(%rbp), %ecx
callq 0x4db0c
leal (%rbx,%r13), %esi
addl $0x66, %esi
movq %r14, %rdi
movl $0x13, %edx
movl -0x5c(%rbp), %ecx
callq 0x4db0c
addl %ebx, %r13d
addl $0x79, %r13d
movq -0x70(%rbp), %rbx
addq $0x498, %r15            # imm = 0x498
incl %r12d
cmpq $0x2c808, %r15          # imm = 0x2C808
jne 0x48cde
movl %r13d, 0x9f0bc(%rbx)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq