// File: 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 %rbx
subq $0x88, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x14(%rbp), %edx
movl $0x3, %edi
leaq 0x432d1(%rip), %rsi     # 0xc26ca
movb $0x0, %al
callq 0x8b980
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x30(%rdx), %ecx
movb %al, -0x45(%rbp)
jge 0x7f422
cmpl $0x40, -0x20(%rbp)
setl %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x7f42b
jmp 0x7f46c
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
leaq -0x28(%rbp), %rsi
callq 0x8b3b0
cmpl $0x4, %eax
je 0x7f458
jmp 0x7f461
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7f407
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl $0x3f2, %edi            # imm = 0x3F2
movl $0x4, %edx
callq 0x87580
movl %eax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x30(%rdx), %ecx
movb %al, -0x46(%rbp)
jge 0x7f4ab
cmpl $0x40, -0x20(%rbp)
setl %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0x7f4b7
jmp 0x7f6a5
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
leaq -0x28(%rbp), %rsi
callq 0x8b3b0
cmpl $0x4, %eax
je 0x7f4e7
jmp 0x7f697
movl -0x24(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x87f70
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x60, %rax, %rax
addq %rax, %rsi
movl -0x2c(%rbp), %edx
leaq -0x30(%rbp), %rcx
leaq -0x34(%rbp), %r8
leaq -0x38(%rbp), %r9
leaq -0x3c(%rbp), %r11
leaq -0x40(%rbp), %r10
leaq -0x44(%rbp), %rax
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0x87ff0
cmpl $0x0, -0x2c(%rbp)
jge 0x7f577
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x28(%rbp), %ecx
movl $0x6, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x30(%rbp), %ecx
movl $0x1, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x2c(%rbp), %ecx
movl $0x5, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x5, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x34(%rbp), %ecx
movl $0x19, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x19, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x38(%rbp), %ecx
movl $0x14, %edx
callq 0x8c1d0
movl -0x18(%rbp), %eax
addl $0x14, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x3c(%rbp), %ecx
movl $0x7, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x40(%rbp), %ecx
movl $0x7, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x18(%rbp), %esi
movl -0x44(%rbp), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x18(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7f490
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9f0bc(%rax)
movl $0x1, %eax
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)