// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_ssr6(bamboo::rtcm_t*, int, int)
static int encode_ssr6(rtcm_t *rtcm, int sys, int sync)
{
    double udint=0.0;
    int i,j,nsat,iod=0,prn,hrclk,np,offp;
    
    trace(3,"encode_ssr6: 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[2];
        iod  =rtcm->ssr[j].iod[2];
    }
    /* encode ssr header */
    i=encode_ssr_head(6,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;
        
        hrclk=ROUND(rtcm->ssr[j].hrclk/1E-4);
        
        setbitu(rtcm->buff,i,np,prn-offp); i+=np; /* satellite id */
        setbits(rtcm->buff,i,22,hrclk   ); i+=22; /* high rate clock corr */
    }
    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 0x246ef(%rip), %rsi     # 0x665aa
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 0x41efb
leaq 0x2414b(%rip), %rcx     # 0x6602c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movl %r12d, -0x3c(%rbp)
jmpq *%rax
movq %rdx, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x41f40
cmpl $0x10, %r14d
je 0x41f2e
cmpl $0x20, %r14d
jne 0x420b0
movl %r12d, -0x3c(%rbp)
movq %rdx, -0x38(%rbp)
pushq $-0x1
jmp 0x41f28
movl $0x0, -0x2c(%rbp)
pushq $0x5
jmp 0x41f3b
movq %rdx, -0x38(%rbp)
pushq $-0x78
popq %rax
movl %eax, -0x2c(%rbp)
jmp 0x41f40
movl %r12d, -0x3c(%rbp)
movl $0xffffff40, -0x2c(%rbp) # imm = 0xFFFFFF40
pushq $0x4
popq %rax
movq %rax, -0x38(%rbp)
movq %rbx, -0x60(%rbp)
leaq 0x6f1b8(%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 0x41fbb
movl %r12d, %edi
movq %rbx, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x41f98
cmpb $0x0, 0x420(%r13)
jne 0x41fa4
incq %r12
addq $0x498, %r13            # imm = 0x498
jmp 0x41f75
incl -0x50(%rbp)
movsd (%r13), %xmm0
movsd %xmm0, -0x48(%rbp)
movl 0x28(%r13), %eax
movl %eax, -0x30(%rbp)
jmp 0x41f68
andl $0x0, (%rsp)
pushq $0x6
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 0x4209e
movl %r15d, %edi
movq %r12, %rsi
callq 0x45362
cmpl %r14d, %eax
jne 0x4202d
cmpb $0x0, (%rbx)
jne 0x42039
incq %r15
addq $0x498, %rbx            # imm = 0x498
jmp 0x4200b
movsd -0x390(%rbx), %xmm0
divsd 0x1e8c7(%rip), %xmm0    # 0x60910
addsd 0x1fc27(%rip), %xmm0    # 0x61c78
callq 0x8ac0
cvttsd2si %xmm0, %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 $0x16
popq %rdx
movl -0x30(%rbp), %ecx
callq 0x45ae0
movq -0x38(%rbp), %rax
addl %eax, %ebx
addl $0x16, %ebx
movq %rbx, -0x48(%rbp)
jmp 0x41ffe
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