// File: DoubleString[P]RtConverter/src/Rtklib/rtcm3e.cpp
// Function: bamboo::encode_type1006(bamboo::rtcm_t*, int)
static int encode_type1006(rtcm_t *rtcm, int sync)
{
    double *p=rtcm->sta.pos;
    int i=24,hgt=0;
    
    trace(3,"encode_type1006: sync=%d\n",sync);
    
    if (0.0<=rtcm->sta.hgt&&rtcm->sta.hgt<=6.5535) {
        hgt=ROUND(rtcm->sta.hgt/0.0001);
    }
    else {
        trace(2,"antenna height error: h=%.4f\n",rtcm->sta.hgt);
    }
    setbitu(rtcm->buff,i,12,1006       ); i+=12; /* message no */
    setbitu(rtcm->buff,i,12,rtcm->staid); i+=12; /* ref station id */
    setbitu(rtcm->buff,i, 6,0          ); i+= 6; /* itrf realization year */
    setbitu(rtcm->buff,i, 1,1          ); i+= 1; /* gps indicator */
    setbitu(rtcm->buff,i, 1,1          ); i+= 1; /* glonass indicator */
    setbitu(rtcm->buff,i, 1,0          ); i+= 1; /* galileo indicator */
    setbitu(rtcm->buff,i, 1,0          ); i+= 1; /* ref station indicator */
    set38bits(rtcm->buff,i,p[0]/0.0001 ); i+=38; /* antenna ref point ecef-x */
    setbitu(rtcm->buff,i, 1,1          ); i+= 1; /* oscillator indicator */
    setbitu(rtcm->buff,i, 1,0          ); i+= 1; /* reserved */
    set38bits(rtcm->buff,i,p[1]/0.0001 ); i+=38; /* antenna ref point ecef-y */
    setbitu(rtcm->buff,i, 2,0          ); i+= 2; /* quarter cycle indicator */
    set38bits(rtcm->buff,i,p[2]/0.0001 ); i+=38; /* antenna ref point ecef-z */
    setbitu(rtcm->buff,i,16,hgt        ); i+=16; /* antenna height */
    rtcm->nbit=i;
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x6ef38, %rax          # imm = 0x6EF38
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x18(%rbp)
movl $0x18, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0xc(%rbp), %edx
movl $0x3, %edi
leaq 0x43bae(%rip), %rsi     # 0xc265e
movb $0x0, %al
callq 0x8b980
movq -0x8(%rbp), %rax
movsd 0x6f138(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x7eb14
movq -0x8(%rbp), %rax
movsd 0x432c8(%rip), %xmm0    # 0xc1da0
ucomisd 0x6f138(%rax), %xmm0
jb 0x7eb14
movq -0x8(%rbp), %rax
movsd 0x6f138(%rax), %xmm0
movsd 0x3e372(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
movsd 0x3e37e(%rip), %xmm1    # 0xbce80
addsd %xmm1, %xmm0
callq 0x9c90
cvttsd2si %xmm0, %eax
movl %eax, -0x20(%rbp)
jmp 0x7eb33
movq -0x8(%rbp), %rax
movsd 0x6f138(%rax), %xmm0
movl $0x2, %edi
leaq 0x43b4c(%rip), %rsi     # 0xc2678
movb $0x1, %al
callq 0x8b980
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0xc, %edx
movl $0x3ee, %ecx            # imm = 0x3EE
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movl $0xc, %edx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0xc, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x6, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x3e21b(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
callq 0x87ee0
movl -0x1c(%rbp), %eax
addl $0x26, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd 0x3e1a4(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
callq 0x87ee0
movl -0x1c(%rbp), %eax
addl $0x26, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x3e150(%rip), %xmm1    # 0xbce68
divsd %xmm1, %xmm0
callq 0x87ee0
movl -0x1c(%rbp), %eax
addl $0x26, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x9f0c4, %rdi          # imm = 0x9F0C4
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %ecx
movl $0x10, %edx
callq 0x8c0d0
movl -0x1c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x9f0bc(%rax)
movl $0x1, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)