// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1008(bamboo::rtcm_t*, int)
static int encode_type1008(rtcm_t *rtcm, int sync)
{
    int i=24,j,antsetup=rtcm->sta.antsetup;
    int n=MIN(strlen(rtcm->sta.antdes),31);
    int m=MIN(strlen(rtcm->sta.antsno),31);
    
    trace(3,"encode_type1008: sync=%d\n",sync);
    
    setbitu(rtcm->buff,i,12,1008       ); i+=12; /* message no */
    setbitu(rtcm->buff,i,12,rtcm->staid); i+=12; /* ref station id */
    
    /* antenna descriptor */
    setbitu(rtcm->buff,i,8,n); i+=8;
    for (j=0;j<n;j++) {
        setbitu(rtcm->buff,i,8,rtcm->sta.antdes[j]); i+=8;
    }
    setbitu(rtcm->buff,i,8,antsetup); i+=8; /* antenna setup id */
    
    /* antenna serial number */
    setbitu(rtcm->buff,i,8,m); i+=8;
    for (j=0;j<m;j++) {
        setbitu(rtcm->buff,i,8,rtcm->sta.antsno[j]); i+=8;
    }
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x18, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x6f0f8(%rax), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
addq $0x6ef38, %rdi          # imm = 0x6EF38
addq $0x80, %rdi
callq 0x92e0
cmpq $0x1f, %rax
jae 0x7ef4d
movq -0x8(%rbp), %rdi
addq $0x6ef38, %rdi          # imm = 0x6EF38
addq $0x80, %rdi
callq 0x92e0
movq %rax, -0x28(%rbp)
jmp 0x7ef58
movl $0x1f, %eax
movq %rax, -0x28(%rbp)
jmp 0x7ef58
movq -0x28(%rbp), %rax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x6ef38, %rdi          # imm = 0x6EF38
addq $0xc0, %rdi
callq 0x92e0
cmpq $0x1f, %rax
jae 0x7ef99
movq -0x8(%rbp), %rdi
addq $0x6ef38, %rdi          # imm = 0x6EF38
addq $0xc0, %rdi
callq 0x92e0
movq %rax, -0x30(%rbp)
jmp 0x7efa4
movl $0x1f, %eax
movq %rax, -0x30(%rbp)
jmp 0x7efa4
movq -0x30(%rbp), %rax
movl %eax, -0x20(%rbp)
movl -0xc(%rbp), %edx
movl $0x3, %edi
leaq 0x436f6(%rip), %rsi     # 0xc26b0
movb $0x0, %al
callq 0x8b980
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movl $0xc, %edx
movl $0x3f0, %ecx            # imm = 0x3F0
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movl $0xc, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movl -0x1c(%rbp), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x7f07d
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl 0x6efb8(%rax,%rcx), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7f039
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movl -0x18(%rbp), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movl -0x20(%rbp), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x7f110
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x10(%rbp), %esi
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
movsbl 0x6eff8(%rax,%rcx), %ecx
movl $0x8, %edx
callq 0x8c0d0
movl -0x10(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7f0cc
movl -0x10(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x9f0bc(%rax)
movl $0x1, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)