// File: /workspace/github_cpp_makefile_star2_O1/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1011(bamboo::rtcm_t*, int)
static int encode_type1011(rtcm_t *rtcm, int sync)
{
    int i,j,nsat=0,sat,prn,fcn;
    int code1,pr1,ppr1,lock1,amb,code2,pr21,ppr2,lock2;
    
    trace(3,"encode_type1011: 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(1011,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,
                    NULL,&code2,&pr21,&ppr2,&lock2,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, 2,code2); i+= 2;
        setbits(rtcm->buff,i,14,pr21 ); i+=14;
        setbits(rtcm->buff,i,20,ppr2 ); i+=20;
        setbitu(rtcm->buff,i, 7,lock2); i+= 7;
    }
    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 %esi, %r14d
movq %rdi, %rbx
leaq 0x2a734(%rip), %rsi     # 0x703f4
xorl %r15d, %r15d
movl $0x3, %edi
movl %r14d, %edx
xorl %eax, %eax
callq 0x4ded0
movq %rbx, -0x38(%rbp)
cmpl $0x0, 0x30(%rbx)
movl %r14d, -0x40(%rbp)
jle 0x45d32
xorl %r15d, %r15d
movl $0x10, %ebx
movl $0x1, %r12d
movq -0x38(%rbp), %r13
movl %r15d, %r14d
movq 0x38(%r13), %rax
movzbl (%rax,%rbx), %edi
leaq -0x30(%rbp), %rsi
callq 0x4dc2a
xorl %r15d, %r15d
cmpl $0x4, %eax
sete %r15b
addl %r14d, %r15d
movslq 0x30(%r13), %rax
cmpl $0x40, %r15d
setb %cl
cmpq %rax, %r12
jge 0x45d34
addq $0x60, %rbx
incq %r12
cmpl $0x40, %r15d
jb 0x45cf2
jmp 0x45d34
movb $0x1, %cl
movb %cl, -0x29(%rbp)
movl $0x3f3, %edi            # imm = 0x3F3
movq -0x38(%rbp), %r13
movq %r13, %rsi
movl $0x4, %edx
movl -0x40(%rbp), %ecx
movl %r15d, %r8d
callq 0x4b5ce
movl %eax, %r14d
cmpl $0x0, 0x30(%r13)
jle 0x45ef0
cmpb $0x0, -0x29(%rbp)
je 0x45ef0
leaq 0x9f0c4(%r13), %rax
movq %rax, -0x40(%rbp)
movl $0x1, %r12d
leaq -0x30(%rbp), %r15
xorl %ebx, %ebx
movq 0x38(%r13), %rax
movzbl 0x10(%rax,%rbx), %r13d
movl %r13d, %edi
movq %r15, %rsi
callq 0x4dc2a
cmpl $0x4, %eax
jne 0x45ed2
movl %r13d, %edi
movq -0x38(%rbp), %r15
movq %r15, %rsi
callq 0x4bbd0
movl %eax, %r13d
movq 0x38(%r15), %rsi
addq %rbx, %rsi
movq %r15, %rdi
movl %eax, %edx
leaq -0x60(%rbp), %rcx
leaq -0x5c(%rbp), %r8
leaq -0x58(%rbp), %r9
xorl %r15d, %r15d
pushq %r15
leaq -0x44(%rbp), %rax
pushq %rax
leaq -0x48(%rbp), %rax
pushq %rax
leaq -0x4c(%rbp), %rax
pushq %rax
leaq -0x50(%rbp), %rax
pushq %rax
pushq %r15
leaq -0x64(%rbp), %rax
pushq %rax
leaq -0x54(%rbp), %rax
pushq %rax
callq 0x4bc25
addq $0x40, %rsp
testl %r13d, %r13d
cmovlel %r15d, %r13d
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %r15
movq %r15, %rdi
movl %r14d, %esi
movl $0x6, %edx
callq 0x4e403
leal 0x6(%r14), %esi
movl -0x60(%rbp), %ecx
movq %r15, %rdi
movl $0x1, %edx
callq 0x4e403
leal 0x7(%r14), %esi
movq %r15, %rdi
movl $0x5, %edx
movl %r13d, %ecx
callq 0x4e403
leal 0xc(%r14), %esi
movl -0x5c(%rbp), %ecx
movq %r15, %rdi
movl $0x19, %edx
callq 0x4e403
leal 0x25(%r14), %esi
movl -0x58(%rbp), %ecx
movq %r15, %rdi
movl $0x14, %edx
callq 0x4e47b
leal 0x39(%r14), %esi
movl -0x54(%rbp), %ecx
movq %r15, %rdi
movl $0x7, %edx
callq 0x4e403
leal 0x40(%r14), %esi
movl -0x50(%rbp), %ecx
movq %r15, %rdi
movl $0x2, %edx
callq 0x4e403
leal 0x42(%r14), %esi
movl -0x4c(%rbp), %ecx
movq %r15, %rdi
movl $0xe, %edx
callq 0x4e47b
leal 0x50(%r14), %esi
movl -0x48(%rbp), %ecx
movq %r15, %rdi
movl $0x14, %edx
callq 0x4e47b
leal 0x64(%r14), %esi
movl -0x44(%rbp), %ecx
movq %r15, %rdi
leaq -0x30(%rbp), %r15
movl $0x7, %edx
callq 0x4e403
addl $0x6b, %r14d
movq -0x38(%rbp), %r13
movslq 0x30(%r13), %rax
cmpq %rax, %r12
setl %al
addq $0x60, %rbx
incq %r12
testb %al, -0x29(%rbp)
jne 0x45d82
movl %r14d, 0x9f0bc(%r13)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq