// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1010(bamboo::rtcm_t*, int)
static int encode_type1010(rtcm_t *rtcm, int sync)
{
    int i,j,nsat=0,sat,prn,fcn;
    int code1,pr1,ppr1,lock1,amb,cnr1;
    
    trace(3,"encode_type1010: sync=%d\n",sync);
    
    for (j=0;j<rtcm->obs.n&&nsat<MAXOBS;j++) {
        sat=rtcm->obs.data[j].sat;
        if (satsys(sat,&prn)!=SYS_GLO) continue;
        nsat++;
    }
    /* encode header */
    i=encode_head(1010,rtcm,SYS_GLO,sync,nsat);
    
    for (j=0;j<rtcm->obs.n&&nsat<MAXOBS;j++) {
        sat=rtcm->obs.data[j].sat;
        if (satsys(sat,&prn)!=SYS_GLO) continue;
        fcn=fcn_glo(sat,rtcm);
        
        /* generate obs field data glonass */
        gen_obs_glo(rtcm,rtcm->obs.data+j,fcn,&code1,&pr1,&ppr1,&lock1,&amb,
                    &cnr1,NULL,NULL,NULL,NULL,NULL);
        
        if (fcn<0) fcn=0;
        setbitu(rtcm->buff,i, 6,prn  ); i+= 6;
        setbitu(rtcm->buff,i, 1,code1); i+= 1;
        setbitu(rtcm->buff,i, 5,fcn  ); i+= 5;
        setbitu(rtcm->buff,i,25,pr1  ); i+=25;
        setbits(rtcm->buff,i,20,ppr1 ); i+=20;
        setbitu(rtcm->buff,i, 7,lock1); i+= 7;
        setbitu(rtcm->buff,i, 7,amb  ); i+= 7;
        setbitu(rtcm->buff,i, 8,cnr1 ); i+= 8;
    }
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, %edx
movq %rdi, %rbx
leaq 0x2a954(%rip), %rsi     # 0x703da
xorl %r15d, %r15d
movl $0x3, %edi
movl %edx, -0x38(%rbp)
xorl %eax, %eax
callq 0x4ded0
cmpl $0x0, 0x30(%rbx)
jle 0x45aef
xorl %r15d, %r15d
movl $0x10, %r12d
movl $0x1, %r14d
movl %r15d, %r13d
movq 0x38(%rbx), %rax
movzbl (%rax,%r12), %edi
leaq -0x30(%rbp), %rsi
callq 0x4dc2a
xorl %r15d, %r15d
cmpl $0x4, %eax
sete %r15b
addl %r13d, %r15d
movslq 0x30(%rbx), %rax
cmpl $0x40, %r15d
setb %r13b
cmpq %rax, %r14
jge 0x45af2
addq $0x60, %r12
incq %r14
cmpl $0x40, %r15d
jb 0x45aad
jmp 0x45af2
movb $0x1, %r13b
movl $0x3f2, %edi            # imm = 0x3F2
movq %rbx, %rsi
movl $0x4, %edx
movl -0x38(%rbp), %ecx
movl %r15d, %r8d
callq 0x4b5ce
movl %eax, %r14d
cmpl $0x0, 0x30(%rbx)
jle 0x45c8c
testb %r13b, %r13b
je 0x45c8c
leaq 0x9f0c4(%rbx), %rax
movq %rax, -0x38(%rbp)
movl $0x1, %r12d
xorl %r15d, %r15d
movb %r13b, -0x29(%rbp)
movq %rbx, -0x58(%rbp)
movq 0x38(%rbx), %rax
movzbl 0x10(%rax,%r15), %r13d
movl %r13d, %edi
leaq -0x30(%rbp), %rsi
callq 0x4dc2a
cmpl $0x4, %eax
jne 0x45c6e
movl %r13d, %edi
movq %rbx, %rsi
callq 0x4bbd0
movl %eax, %r13d
movq 0x38(%rbx), %rsi
addq %r15, %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
leaq -0x3c(%rbp), %rax
movq %rax, 0x10(%rsp)
leaq -0x40(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq -0x44(%rbp), %rax
movq %rax, (%rsp)
movq $0x0, 0x38(%rsp)
movq %rbx, %rdi
movl %r13d, %edx
leaq -0x50(%rbp), %rcx
leaq -0x4c(%rbp), %r8
leaq -0x48(%rbp), %r9
callq 0x4bc25
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %esi
movl $0x6, %edx
callq 0x4e403
leal 0x6(%r14), %esi
movl -0x50(%rbp), %ecx
movq %rbx, %rdi
movl $0x1, %edx
callq 0x4e403
leal 0x7(%r14), %esi
movq %rbx, %rdi
movl $0x5, %edx
movl %r13d, %ecx
callq 0x4e403
leal 0xc(%r14), %esi
movl -0x4c(%rbp), %ecx
movq %rbx, %rdi
movl $0x19, %edx
callq 0x4e403
leal 0x25(%r14), %esi
movl -0x48(%rbp), %ecx
movq %rbx, %rdi
movl $0x14, %edx
callq 0x4e47b
leal 0x39(%r14), %esi
movl -0x44(%rbp), %ecx
movq %rbx, %rdi
movl $0x7, %edx
callq 0x4e403
leal 0x40(%r14), %esi
movl -0x40(%rbp), %ecx
movq %rbx, %rdi
movl $0x7, %edx
callq 0x4e403
leal 0x47(%r14), %esi
movl -0x3c(%rbp), %ecx
movq %rbx, %rdi
movq -0x58(%rbp), %rbx
movl $0x8, %edx
callq 0x4e403
addl $0x4f, %r14d
movslq 0x30(%rbx), %rax
cmpq %rax, %r12
setl %al
addq $0x60, %r15
incq %r12
movb -0x29(%rbp), %r13b
testb %r13b, %al
jne 0x45b3c
movl %r14d, 0x9f0bc(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq