// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x248d8(%rip), %rsi     # 0x6658d
xorl %r15d, %r15d
pushq $0x3
popq %rdi
movl %r14d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x455bc
pushq $0x6
popq %rdx
leal -0x1(%r14), %eax
cmpl $0x7, %eax
ja 0x41cf5
leaq 0x24331(%rip), %rcx     # 0x6600c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r12d, -0x3c(%rbp)
jmpq *%rax
movq %rdx, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x41d3a
cmpl $0x10, %r14d
je 0x41d28
cmpl $0x20, %r14d
jne 0x41e88
movl %r12d, -0x3c(%rbp)
movq %rdx, -0x38(%rbp)
pushq $-0x1
jmp 0x41d22
movl $0x0, -0x2c(%rbp)
pushq $0x5
jmp 0x41d35
movq %rdx, -0x38(%rbp)
pushq $-0x78
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x41d3a
movl %r12d, -0x3c(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
pushq $0x4
popq %rax
movq %rax, -0x38(%rbp)
movq %rbx, -0x60(%rbp)
leaq 0x6f1c0(%rbx), %r15
xorl %r12d, %r12d
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
leaq -0x54(%rbp), %rbx
movl $0x0, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
imulq $0x498, %r12, %r13      # imm = 0x498
incq %r12
addq %r15, %r13
cmpq $0x9c, %r12
je 0x41db5
movl %r12d, %edi
movq %rbx, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x41d92
cmpb $0x0, 0x418(%r13)
jne 0x41d9e
incq %r12
addq $0x498, %r13            # imm = 0x498
jmp 0x41d6f
incl -0x50(%rbp)
movsd (%r13), %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0x24(%r13), %eax
movl %eax, -0x30(%rbp)
jmp 0x41d62
andl $0x0, (%rsp)
pushq $0x5
popq %rdi
movq -0x60(%rbp), %rbx
movq %rbx, %rsi
movl %r14d, %edx
movl -0x50(%rbp), %ecx
movl -0x3c(%rbp), %r8d
movl -0x30(%rbp), %r9d
movsd -0x48(%rbp), %xmm0
callq 0x437dc
movq %rax, -0x48(%rbp)
leaq 0x9f0c4(%rbx), %rax
movq %rax, -0x50(%rbp)
leaq 0x6f5d8(%rbx), %r13
xorl %r15d, %r15d
leaq -0x54(%rbp), %r12
imulq $0x498, %r15, %rbx      # imm = 0x498
incq %r15
addq %r13, %rbx
cmpq $0x9c, %r15
je 0x41e76
movl %r15d, %edi
movq %r12, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x41e23
cmpb $0x0, (%rbx)
jne 0x41e2f
incq %r15
addq $0x498, %rbx            # imm = 0x498
jmp 0x41e05
movl -0x3e0(%rbx), %eax
movl %eax, -0x30(%rbp)
movl -0x54(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movq -0x48(%rbp), %rbx
movq -0x50(%rbp), %rdi
movl %ebx, %esi
movq -0x38(%rbp), %rdx
callq 0x45a69
movq -0x38(%rbp), %rax
leal (%rbx,%rax), %esi
movq -0x50(%rbp), %rdi
pushq $0x6
popq %rdx
movl -0x30(%rbp), %ecx
callq 0x45a69
movq -0x38(%rbp), %rax
addl %eax, %ebx
addl $0x6, %ebx
movq %rbx, -0x48(%rbp)
jmp 0x41df8
movq -0x60(%rbp), %rax
movq -0x48(%rbp), %rcx
movl %ecx, 0x9f0bc(%rax)
pushq $0x1
popq %r15
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq