// File: DoubleString[P]RtConverter/src/Encoder/RtcmExEncoder.cpp
// Function: bamboo::RtcmExEncoder::m_encodeRtcmExMsg(char const*, bamboo::gtime_t, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bamboo::RtSatObs, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, bamboo::RtSatObs>>>&)
int RtcmExEncoder::m_encodeRtcmExMsg(const char* sitname,gtime_t tt,map<string, RtSatObs>& obs){
	unsigned int crc;
	int i = 0;
	nbyte = len = nbit = 0;
	setbitu((unsigned char*)buff, i, 8, RTCMEX_PREAMB); i += 8;
	setbitu((unsigned char*)buff, i, 16, 0);        i += 16;
	if(0 == (nbit = m_encodeObsMsg(sitname,tt,obs))){
		nbyte = nbit = len = 0;
		return 0;
	}
	/* padding to align 8 bit boundary */
	for (i = nbit; i % 8; i++) {
		setbitu((unsigned char*)buff, i, 1, 0);
	}
	/* message length (header+data) (bytes) */
	if ((len = i / 8) > sizeof(buff) - 4) {
		nbyte = nbit = len = 0;
		return 0;
	}
	/* message length without header and parity */
	setbitu((unsigned char*)buff, 8, 16, len - 3);

	/* crc-24q */
	crc = rtk_crc24q((unsigned char*)buff, len);
	setbitu((unsigned char*)buff, i, 32, crc);
	/* length total (bytes) */
	nbyte = len + 4;
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq %rdi, -0x50(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, 0x808(%rdi)
movl $0x0, 0x804(%rdi)
movl $0x0, 0x800(%rdi)
movl -0x38(%rbp), %esi
movl $0x8, %edx
movl $0xda, %ecx
callq 0x8c0d0
movq -0x50(%rbp), %rdi
movl -0x38(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %esi
movl $0x10, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movq -0x50(%rbp), %rdi
movl -0x38(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rdx
movsd -0x40(%rbp), %xmm0
callq 0x32610
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x808(%rax)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3251b
movq -0x50(%rbp), %rax
movl $0x0, 0x804(%rax)
movl $0x0, 0x808(%rax)
movl $0x0, 0x800(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x325fc
movq -0x50(%rbp), %rax
movl 0x808(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x32556
movq -0x50(%rbp), %rdi
movl -0x38(%rbp), %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x8c0d0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x32528
movq -0x50(%rbp), %rcx
movl -0x38(%rbp), %eax
movl $0x8, %esi
cltd
idivl %esi
movl %eax, 0x804(%rcx)
cltq
cmpq $0x7fc, %rax            # imm = 0x7FC
jbe 0x325a0
movq -0x50(%rbp), %rax
movl $0x0, 0x804(%rax)
movl $0x0, 0x808(%rax)
movl $0x0, 0x800(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x325fc
movq -0x50(%rbp), %rdi
movl 0x804(%rdi), %ecx
subl $0x3, %ecx
movl $0x8, %esi
movl $0x10, %edx
callq 0x8c0d0
movq -0x50(%rbp), %rdi
movl 0x804(%rdi), %esi
callq 0x8c2d0
movq -0x50(%rbp), %rdi
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %ecx
movl $0x20, %edx
callq 0x8c0d0
movq -0x50(%rbp), %rax
movl 0x804(%rax), %ecx
addl $0x4, %ecx
movl %ecx, 0x800(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)