// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_ssr5(bamboo::rtcm_t*, int, int)
static int encode_ssr5(rtcm_t *rtcm, int sys, int sync)
{
    double udint=0.0;
    int i,j,nsat,iod=0,prn,ura,np,offp;
    
    trace(3,"encode_ssr5: 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[3];
        iod  =rtcm->ssr[j].iod[3];
    }
    /* encode ssr header */
    i=encode_ssr_head(5,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;
        
        ura=rtcm->ssr[j].ura;
        setbitu(rtcm->buff,i,np,prn-offp); i+=np; /* satellite id */
        setbitu(rtcm->buff,i, 6,ura     ); i+= 6; /* ssr ura */
    }
    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, %r15d
movl %esi, %r14d
movq %rdi, -0x50(%rbp)
leaq 0x26bf8(%rip), %rsi     # 0x705ad
xorl %ebx, %ebx
movl $0x3, %edi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x4d55d
movl $0x6, %eax
movq %rax, -0x58(%rbp)
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x499f8
leaq 0x264ea(%rip), %rcx     # 0x6fecc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r15d, -0x48(%rbp)
jmpq *%rax
movl $0x0, -0x2c(%rbp)
jmp 0x49a40
cmpl $0x10, %r14d
je 0x49a2c
cmpl $0x20, %r14d
jne 0x49b8b
movl %r15d, -0x48(%rbp)
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x49a40
movl $0x0, -0x2c(%rbp)
movl $0x5, %eax
jmp 0x49a3c
movl $0xffffff88, -0x2c(%rbp) # imm = 0xFFFFFF88
jmp 0x49a40
movl %r15d, -0x48(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
movl $0x4, %eax
movq %rax, -0x58(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x6f1c0, %ebx          # imm = 0x6F1C0
movl $0x1, %r13d
leaq -0x34(%rbp), %r15
xorl %r12d, %r12d
movl %r13d, %edi
movq %r15, %rsi
callq 0x4d2f2
cmpl %r14d, %eax
jne 0x49a93
movq -0x50(%rbp), %rax
cmpb $0x0, 0x418(%rax,%rbx)
je 0x49a93
incl %r12d
movsd (%rax,%rbx), %xmm0
movsd %xmm0, -0x40(%rbp)
movl 0x24(%rax,%rbx), %eax
movl %eax, -0x30(%rbp)
addq $0x498, %rbx            # imm = 0x498
incl %r13d
cmpq $0x9b9c8, %rbx          # imm = 0x9B9C8
jne 0x49a61
movl $0x0, (%rsp)
movl $0x5, %edi
movq -0x50(%rbp), %r13
movq %r13, %rsi
movl %r14d, %edx
movl %r12d, %ecx
movl -0x48(%rbp), %r8d
movl -0x30(%rbp), %r9d
movsd -0x40(%rbp), %xmm0
callq 0x4b64c
movq %rax, -0x40(%rbp)
leaq 0x9f0c4(%r13), %rax
movq %rax, -0x48(%rbp)
movl $0x1, %r12d
xorl %ebx, %ebx
leaq -0x34(%rbp), %r15
movq %r14, -0x60(%rbp)
movl %r12d, %edi
movq %r15, %rsi
callq 0x4d2f2
cmpl %r14d, %eax
jne 0x49b64
cmpb $0x0, 0x6f5d8(%r13,%rbx)
je 0x49b64
movq -0x50(%rbp), %rax
movl 0x6f1f8(%rax,%rbx), %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %r15
movl %r15d, %esi
movq -0x58(%rbp), %r14
movl %r14d, %edx
callq 0x4da98
leal (%r15,%r14), %esi
movq %r13, %rdi
movl $0x6, %edx
movl -0x30(%rbp), %ecx
movq -0x50(%rbp), %r13
callq 0x4da98
addl %r14d, %r15d
addl $0x6, %r15d
movq %r15, -0x40(%rbp)
leaq -0x34(%rbp), %r15
movq -0x60(%rbp), %r14
addq $0x498, %rbx            # imm = 0x498
incl %r12d
cmpq $0x2c808, %rbx          # imm = 0x2C808
jne 0x49af0
movq -0x40(%rbp), %rax
movl %eax, 0x9f0bc(%r13)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq