// File: /workspace/github_cpp_makefile_star2_O3/DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1009(bamboo::rtcm_t*, int)
static int encode_type1009(rtcm_t *rtcm, int sync)
{
    int i,j,nsat=0,sat,prn,fcn;
    int code1,pr1,ppr1,lock1,amb;
    
    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(1009,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,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;
    }
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x30(%rdi)
movl %esi, -0x38(%rbp)
jle 0x44f92
xorl %r8d, %r8d
movl $0x10, %r12d
movl $0x1, %r13d
leaq -0x2c(%rbp), %r14
movl %r8d, %r15d
movq 0x38(%rbx), %rax
movzbl (%rax,%r12), %edi
movq %r14, %rsi
callq 0x4d2f2
xorl %r8d, %r8d
cmpl $0x4, %eax
sete %r8b
addl %r15d, %r8d
movslq 0x30(%rbx), %rax
cmpl $0x40, %r8d
setb %r15b
cmpq %rax, %r13
jge 0x44f98
addq $0x60, %r12
incq %r13
cmpl $0x40, %r8d
jb 0x44f51
jmp 0x44f98
movb $0x1, %r15b
xorl %r8d, %r8d
movl $0x3f1, %edi            # imm = 0x3F1
movq %rbx, %rsi
movl $0x4, %edx
movl -0x38(%rbp), %ecx
callq 0x4ac42
movq %rax, -0x38(%rbp)
cmpl $0x0, 0x30(%rbx)
jle 0x450f2
testb %r15b, %r15b
je 0x450f2
leaq 0x9f0c4(%rbx), %rax
movq %rax, -0x58(%rbp)
leaq -0x2c(%rbp), %r14
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rbx, -0x50(%rbp)
movq 0x38(%rbx), %rax
movzbl 0x10(%rax,%r12), %r13d
movl %r13d, %edi
movq %r14, %rsi
callq 0x4d2f2
cmpl $0x4, %eax
jne 0x450de
movl %r13d, %edi
movq %rbx, %rsi
callq 0x4b23d
movl %eax, %r13d
movq 0x38(%rbx), %rsi
addq %r12, %rsi
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rsp)
movups %xmm0, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
leaq -0x5c(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq -0x3c(%rbp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movl %r13d, %edx
leaq -0x48(%rbp), %rcx
leaq -0x44(%rbp), %r8
leaq -0x40(%rbp), %r9
callq 0x4b292
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
movl -0x2c(%rbp), %ecx
movq -0x58(%rbp), %r14
movq %r14, %rdi
movq -0x38(%rbp), %rbx
movl %ebx, %esi
movl $0x6, %edx
callq 0x4da98
leal 0x6(%rbx), %esi
movl -0x48(%rbp), %ecx
movq %r14, %rdi
movl $0x1, %edx
callq 0x4da98
leal 0x7(%rbx), %esi
movq %r14, %rdi
movl $0x5, %edx
movl %r13d, %ecx
callq 0x4da98
leal 0xc(%rbx), %esi
movl -0x44(%rbp), %ecx
movq %r14, %rdi
movl $0x19, %edx
callq 0x4da98
leal 0x25(%rbx), %esi
movl -0x40(%rbp), %ecx
movq %r14, %rdi
movl $0x14, %edx
callq 0x4db0c
leal 0x39(%rbx), %esi
movl -0x3c(%rbp), %ecx
movq %r14, %rdi
leaq -0x2c(%rbp), %r14
movl $0x7, %edx
callq 0x4da98
addl $0x40, %ebx
movq %rbx, -0x38(%rbp)
movq -0x50(%rbp), %rbx
incq %r15
movslq 0x30(%rbx), %rax
addq $0x60, %r12
cmpq %rax, %r15
jl 0x44fdd
movq -0x38(%rbp), %rax
movl %eax, 0x9f0bc(%rbx)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq