// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x25688(%rip), %rsi     # 0x664d6
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r14d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x455bc
pushq $0x8
popq %rsi
pushq $0x6
popq %rdx
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x40e94
leaq 0x25115(%rip), %rcx     # 0x65f8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r12d, -0x44(%rbp)
jmpq *%rax
movl %esi, -0x2c(%rbp)
movl %edx, -0x34(%rbp)
movq $0x0, -0x58(%rbp)
jmp 0x40ef8
cmpl $0x10, %r14d
je 0x40f01
cmpl $0x20, %r14d
jne 0x411f6
movl %r12d, -0x44(%rbp)
movl %edx, -0x34(%rbp)
pushq $-0x1
popq %rax
movl %eax, -0x30(%rbp)
pushq $0x18
popq %rax
movq %rax, -0x58(%rbp)
pushq $0xa
jmp 0x40ee1
movl %edx, -0x34(%rbp)
movq $0x0, -0x58(%rbp)
pushq $0xa
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x40ef8
movl %edx, -0x34(%rbp)
pushq $-0x78
popq %rax
movl %eax, -0x30(%rbp)
pushq $0x18
popq %rax
movq %rax, -0x58(%rbp)
pushq $0x9
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x40f1d
movl %esi, -0x2c(%rbp)
movq $0x0, -0x58(%rbp)
pushq $0x5
popq %rax
movl %eax, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
jmp 0x40f1d
movl %r12d, -0x44(%rbp)
movl %esi, -0x2c(%rbp)
movq $0x0, -0x58(%rbp)
movl $0xffffff40, -0x30(%rbp) # imm = 0xFFFFFF40
pushq $0x4
popq %rax
movl %eax, -0x34(%rbp)
movq %rbx, -0x78(%rbp)
leaq 0x6f1a8(%rbx), %r15
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorl %r13d, %r13d
leaq -0x5c(%rbp), %rbx
movl $0x0, -0x48(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
imulq $0x498, %r13, %r12      # imm = 0x498
incq %r13
addq %r15, %r12
cmpq $0x9c, %r13
je 0x40fa9
movl %r13d, %edi
movq %rbx, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x40f7d
cmpb $0x0, 0x430(%r12)
jne 0x40f89
incq %r13
addq $0x498, %r12            # imm = 0x498
jmp 0x40f59
incl -0x50(%rbp)
movsd (%r12), %xmm0
movsd %xmm0, -0x40(%rbp)
movl 0x30(%r12), %eax
movl %eax, -0x4c(%rbp)
movl 0x54(%r12), %eax
movl %eax, -0x48(%rbp)
jmp 0x40f4c
movl -0x48(%rbp), %eax
movl %eax, (%rsp)
pushq $0x1
popq %rdi
movq -0x78(%rbp), %rbx
movq %rbx, %rsi
movl %r14d, %edx
movl -0x50(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl -0x4c(%rbp), %r9d
movsd -0x40(%rbp), %xmm0
callq 0x437dc
movl %eax, %r12d
leaq 0x9f0c4(%rbx), %rax
movq %rax, -0x40(%rbp)
leaq 0x6f1f0(%rbx), %r15
xorl %ebx, %ebx
imulq $0x498, %rbx, %r13      # imm = 0x498
incq %rbx
addq %r15, %r13
cmpq $0x9c, %rbx
je 0x411e5
movl %ebx, %edi
leaq -0x5c(%rbp), %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x4101c
cmpb $0x0, 0x3e8(%r13)
jne 0x41028
incq %rbx
addq $0x498, %r13            # imm = 0x498
jmp 0x40ff5
movl (%r13), %eax
movl %eax, -0x6c(%rbp)
movl 0x4(%r13), %eax
movl %eax, -0x50(%rbp)
movsd 0x10(%r13), %xmm0
divsd 0x1f8cc(%rip), %xmm0    # 0x60910
movsd 0x20c2c(%rip), %xmm1    # 0x61c78
addsd %xmm1, %xmm0
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x4c(%rbp)
movsd 0x18(%r13), %xmm0
movsd 0x236a6(%rip), %xmm1    # 0x64710
divsd %xmm1, %xmm0
addsd 0x20c02(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x48(%rbp)
movsd 0x20(%r13), %xmm0
divsd 0x23680(%rip), %xmm0    # 0x64710
addsd 0x20be0(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x44(%rbp)
movsd 0x28(%r13), %xmm0
divsd 0x21b8e(%rip), %xmm0    # 0x62c40
addsd 0x20bbe(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movsd 0x30(%r13), %xmm0
movsd 0x23644(%rip), %xmm1    # 0x64718
divsd %xmm1, %xmm0
addsd 0x20b98(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movsd 0x38(%r13), %xmm0
divsd 0x2361e(%rip), %xmm0    # 0x64718
addsd 0x20b76(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %ecx
addl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rdi
movl %r12d, %esi
movl -0x34(%rbp), %r13d
movl %r13d, %edx
callq 0x45a69
addl %r13d, %r12d
movq -0x40(%rbp), %r13
movq %r13, %rdi
movl %r12d, %esi
movl -0x2c(%rbp), %edx
movl -0x6c(%rbp), %ecx
callq 0x45a69
addl -0x2c(%rbp), %r12d
movq %r13, %rdi
movl %r12d, %esi
movq -0x58(%rbp), %r13
movl %r13d, %edx
movl -0x50(%rbp), %ecx
callq 0x45a69
leal (%r12,%r13), %esi
movq -0x40(%rbp), %rdi
pushq $0x16
popq %rdx
movl -0x4c(%rbp), %ecx
callq 0x45ae0
leal (%r12,%r13), %esi
addl $0x16, %esi
movq -0x40(%rbp), %rdi
pushq $0x14
popq %rdx
movl -0x48(%rbp), %ecx
callq 0x45ae0
leal (%r12,%r13), %esi
addl $0x2a, %esi
movq -0x40(%rbp), %rdi
pushq $0x14
popq %rdx
movl -0x44(%rbp), %ecx
callq 0x45ae0
leal (%r12,%r13), %esi
addl $0x3e, %esi
movq -0x40(%rbp), %rdi
pushq $0x15
popq %rdx
movl -0x68(%rbp), %ecx
callq 0x45ae0
leal (%r12,%r13), %esi
addl $0x53, %esi
movq -0x40(%rbp), %rdi
pushq $0x13
popq %rdx
movl -0x64(%rbp), %ecx
callq 0x45ae0
leal (%r12,%r13), %esi
addl $0x66, %esi
movq -0x40(%rbp), %rdi
pushq $0x13
popq %rdx
movl -0x60(%rbp), %ecx
callq 0x45ae0
addl %r13d, %r12d
addl $0x79, %r12d
jmp 0x40fe8
movq -0x78(%rbp), %rax
movl %r12d, 0x9f0bc(%rax)
pushq $0x1
popq %rax
movl %eax, %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq