// File: DoubleString[P]RtConverter/src/Encoder/RtcmExEncoder.cpp
// Function: bamboo::RtcmExEncoder::m_encodeObsMsg(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_encodeObsMsg(const char* sitname,gtime_t tt,map<string, RtSatObs>& obs_in){
	int isys,ifreq,gotobs[MAXSYS] = { 0 },lsync,wk;
	char code[8];
	time2gpst(tt,&wk);
	strncpy(buff + 3,sitname,4);
	setbitu((unsigned char*)buff, 7 * 8, 16, wk); /*set the gps week here*/
	m_rtcm.obs.n = 0;
	m_rtcm.time = tt;
	map<string,RtSatObs>::iterator mapItr;
	for(mapItr = obs_in.begin();mapItr != obs_in.end();++mapItr){
		string cprn = (*mapItr).first;
		RtSatObs& obs = (*mapItr).second;
		isys = index_string(SYS, cprn[0]);
		gotobs[isys] = 1;
		m_rtcm.obs.data[m_rtcm.obs.n].sat = satid2no(cprn.c_str());
		if(m_rtcm.obs.data[m_rtcm.obs.n].sat == 0) continue;
		for(ifreq = 0;ifreq < MAXFREQ;ifreq++){
			m_rtcm.obs.data[m_rtcm.obs.n].L[ifreq] = obs.obs[ifreq];
			m_rtcm.obs.data[m_rtcm.obs.n].P[ifreq] = obs.obs[MAXFREQ + ifreq];
			m_rtcm.obs.data[m_rtcm.obs.n].SNR[ifreq] = static_cast<unsigned char>(obs.snr[ifreq] / 0.25);
			strcpy(code, obs.fob[MAXFREQ + ifreq].c_str());
			if (cprn[0] == 'C' && code[1] == '2')
				code[1] = '1';
			if (cprn[0] == 'G' && code[1] == '2')
				strcpy(code, "L2W");
			m_rtcm.obs.data[m_rtcm.obs.n].code[ifreq] = obs2code(code + 1, NULL);
		}
		m_rtcm.obs.n++;
	}
	nbyte = 3 + 4 + 2; // pre,len,sitname
	/////////////////// GPS /////////////////
	if (gotobs[index_string(SYS, 'G')]) {
		lsync = gotobs[index_string(SYS, 'C')] || gotobs[index_string(SYS, 'R')] || gotobs[index_string(SYS, 'E')];
		gen_rtcm3(&m_rtcm, 1074, lsync);
		if(nbyte + m_rtcm.nbyte >  sizeof(buff) - 4) return 0;
		memcpy(buff + nbyte, m_rtcm.buff, m_rtcm.nbyte);
		nbyte = nbyte + m_rtcm.nbyte;
	}
	////////////////// BDS ////////////////
	if (gotobs[index_string(SYS, 'C')]) {
		lsync = gotobs[index_string(SYS, 'R')] || gotobs[index_string(SYS, 'E')];
		gen_rtcm3(&m_rtcm, 1124, lsync);
		if(nbyte + m_rtcm.nbyte >  sizeof(buff) - 4) return 0;
		memcpy(buff + nbyte, m_rtcm.buff, m_rtcm.nbyte);
		nbyte = nbyte + m_rtcm.nbyte;
	}
	//////////////////// GLO ////////////////
	if (gotobs[index_string(SYS, 'R')]) {
		lsync = gotobs[index_string(SYS, 'E')];
		gen_rtcm3(&m_rtcm, 1084, lsync);
		if(nbyte + m_rtcm.nbyte >  sizeof(buff) - 4) return 0;
		memcpy(buff + nbyte, m_rtcm.buff, m_rtcm.nbyte);
		nbyte = nbyte + m_rtcm.nbyte;
	}
	if (gotobs[index_string(SYS, 'E')]) {
		gen_rtcm3(&m_rtcm, 1094, 0);
		if(nbyte + m_rtcm.nbyte >  sizeof(buff) - 4) return 0;
		memcpy(buff + nbyte, m_rtcm.buff, m_rtcm.nbyte);
		nbyte = nbyte + m_rtcm.nbyte;
	}
	return nbyte * 8;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x93d0
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x80(%rbp), %rdi
movsd -0x78(%rbp), %xmm0
leaq -0x68(%rbp), %rsi
callq 0x8e540
movq -0xd8(%rbp), %rdi
addq $0x3, %rdi
movq -0x28(%rbp), %rsi
movl $0x4, %edx
callq 0x93b0
movq -0xd8(%rbp), %rdi
movl -0x68(%rbp), %ecx
movl $0x38, %esi
movl $0x10, %edx
callq 0x8c0d0
movq -0xd8(%rbp), %rax
movl $0x0, 0x840(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x820(%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x828(%rax)
leaq -0x88(%rbp), %rdi
callq 0x32e00
movq -0x30(%rbp), %rdi
callq 0x32e20
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x30(%rbp), %rdi
callq 0x32e80
movq %rax, -0x98(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x32e50
testb $0x1, %al
jne 0x3271c
jmp 0x32a2a
leaq -0x88(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x32eb0
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x92d0
movq -0xf0(%rbp), %rdi
callq 0x32eb0
movq -0xe8(%rbp), %rdi
addq $0x20, %rax
movq %rax, -0xc0(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x9eb0
movq %rax, -0xe0(%rbp)
jmp 0x32775
movq -0xe0(%rbp), %rax
movsbl (%rax), %esi
leaq 0x8a672(%rip), %rdi     # 0xbcdf8
callq 0x340b0
movl %eax, -0xf4(%rbp)
jmp 0x32793
movl -0xf4(%rbp), %eax
movl %eax, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movl $0x1, -0x60(%rbp,%rax,4)
leaq -0xb8(%rbp), %rdi
callq 0x92b0
movq %rax, %rdi
callq 0x8b510
movl %eax, -0xf8(%rbp)
jmp 0x327c4
movq -0xd8(%rbp), %rcx
movl -0xf8(%rbp), %eax
movb %al, %dl
movq 0x848(%rcx), %rax
movslq 0x840(%rcx), %rsi
imulq $0x60, %rsi, %rsi
addq %rsi, %rax
movb %dl, 0x10(%rax)
movq 0x848(%rcx), %rax
movslq 0x840(%rcx), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x3283b
movl $0x4, -0xd0(%rbp)
jmp 0x329fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x9480
jmp 0x32de7
movl $0x0, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jge 0x329dd
movq -0xd8(%rbp), %rsi
movq -0xc0(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x848(%rsi), %rax
movslq 0x840(%rsi), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movsd %xmm0, 0x20(%rax,%rcx,8)
movq -0xc0(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd 0x18(%rax,%rcx,8), %xmm0
movq 0x848(%rsi), %rax
movslq 0x840(%rsi), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movsd %xmm0, 0x38(%rax,%rcx,8)
movq -0xc0(%rbp), %rcx
movslq -0x38(%rbp), %rax
movsd 0x30(%rcx,%rax,8), %xmm0
movsd 0x8a525(%rip), %xmm1    # 0xbcdf0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %ecx
movb %cl, %dl
movq 0x848(%rsi), %rcx
movslq 0x840(%rsi), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x5, %rsi
addq %rsi, %rcx
movb %dl, 0x12(%rax,%rcx)
movq -0xc0(%rbp), %rcx
movslq -0x38(%rbp), %rax
shlq $0x5, %rax
leaq 0xa8(%rax,%rcx), %rdi
callq 0x92b0
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x96f0
xorl %eax, %eax
movl %eax, %esi
leaq -0xb8(%rbp), %rdi
callq 0x9eb0
movq %rax, -0x100(%rbp)
jmp 0x32933
movq -0x100(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x43, %eax
jne 0x3294f
movsbl -0x6f(%rbp), %eax
cmpl $0x32, %eax
jne 0x3294f
movb $0x31, -0x6f(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xb8(%rbp), %rdi
callq 0x9eb0
movq %rax, -0x108(%rbp)
jmp 0x32968
movq -0x108(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x47, %eax
jne 0x32990
movsbl -0x6f(%rbp), %eax
cmpl $0x32, %eax
jne 0x32990
leaq -0x70(%rbp), %rdi
leaq 0x8a475(%rip), %rsi     # 0xbce00
callq 0x96f0
leaq -0x6f(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8baf0
movb %al, -0x109(%rbp)
jmp 0x329a5
movb -0x109(%rbp), %dl
movq -0xd8(%rbp), %rcx
movq 0x848(%rcx), %rax
movslq 0x840(%rcx), %rcx
imulq $0x60, %rcx, %rcx
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movb %dl, 0x18(%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x32842
movq -0xd8(%rbp), %rax
movl 0x840(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x840(%rax)
movl $0x0, -0xd0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x9480
movl -0xd0(%rbp), %eax
testl %eax, %eax
je 0x32a17
jmp 0x32a15
jmp 0x32a19
jmp 0x32a19
leaq -0x88(%rbp), %rdi
callq 0x32ee0
jmp 0x326f0
movq -0xd8(%rbp), %rax
movl $0x9, 0x800(%rax)
leaq 0x8a3b6(%rip), %rdi     # 0xbcdf8
movl $0x47, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x32b5c
leaq 0x8a398(%rip), %rdi     # 0xbcdf8
movl $0x43, %esi
callq 0x340b0
movslq %eax, %rcx
movb $0x1, %al
cmpl $0x0, -0x60(%rbp,%rcx,4)
movb %al, -0x10a(%rbp)
jne 0x32ac0
leaq 0x8a375(%rip), %rdi     # 0xbcdf8
movl $0x52, %esi
callq 0x340b0
movslq %eax, %rcx
movb $0x1, %al
cmpl $0x0, -0x60(%rbp,%rcx,4)
movb %al, -0x10a(%rbp)
jne 0x32ac0
leaq 0x8a352(%rip), %rdi     # 0xbcdf8
movl $0x45, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %al
movb %al, -0x10a(%rbp)
movq -0xd8(%rbp), %rdi
movb -0x10a(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x64(%rbp)
addq $0x810, %rdi            # imm = 0x810
movl -0x64(%rbp), %edx
movl $0x432, %esi            # imm = 0x432
callq 0x6b5c0
movq -0xd8(%rbp), %rcx
movl 0x800(%rcx), %eax
addl 0x9f8c8(%rcx), %eax
cltq
cmpq $0x7fc, %rax            # imm = 0x7FC
jbe 0x32b12
movl $0x0, -0x4(%rbp)
jmp 0x32ddb
movq -0xd8(%rbp), %rax
movslq 0x800(%rax), %rcx
movq %rax, %rdi
addq %rcx, %rdi
movq %rax, %rsi
addq $0x810, %rsi            # imm = 0x810
addq $0x9f0c4, %rsi          # imm = 0x9F0C4
movslq 0x9f8c8(%rax), %rdx
callq 0x9610
movq -0xd8(%rbp), %rax
movl 0x800(%rax), %ecx
addl 0x9f8c8(%rax), %ecx
movl %ecx, 0x800(%rax)
leaq 0x8a295(%rip), %rdi     # 0xbcdf8
movl $0x43, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x32c5a
leaq 0x8a277(%rip), %rdi     # 0xbcdf8
movl $0x52, %esi
callq 0x340b0
movslq %eax, %rcx
movb $0x1, %al
cmpl $0x0, -0x60(%rbp,%rcx,4)
movb %al, -0x10b(%rbp)
jne 0x32bbe
leaq 0x8a254(%rip), %rdi     # 0xbcdf8
movl $0x45, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %al
movb %al, -0x10b(%rbp)
movq -0xd8(%rbp), %rdi
movb -0x10b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x64(%rbp)
addq $0x810, %rdi            # imm = 0x810
movl -0x64(%rbp), %edx
movl $0x464, %esi            # imm = 0x464
callq 0x6b5c0
movq -0xd8(%rbp), %rcx
movl 0x800(%rcx), %eax
addl 0x9f8c8(%rcx), %eax
cltq
cmpq $0x7fc, %rax            # imm = 0x7FC
jbe 0x32c10
movl $0x0, -0x4(%rbp)
jmp 0x32ddb
movq -0xd8(%rbp), %rax
movslq 0x800(%rax), %rcx
movq %rax, %rdi
addq %rcx, %rdi
movq %rax, %rsi
addq $0x810, %rsi            # imm = 0x810
addq $0x9f0c4, %rsi          # imm = 0x9F0C4
movslq 0x9f8c8(%rax), %rdx
callq 0x9610
movq -0xd8(%rbp), %rax
movl 0x800(%rax), %ecx
addl 0x9f8c8(%rax), %ecx
movl %ecx, 0x800(%rax)
leaq 0x8a197(%rip), %rdi     # 0xbcdf8
movl $0x52, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x32d20
leaq 0x8a179(%rip), %rdi     # 0xbcdf8
movl $0x45, %esi
callq 0x340b0
movq -0xd8(%rbp), %rdi
cltq
movl -0x60(%rbp,%rax,4), %eax
movl %eax, -0x64(%rbp)
addq $0x810, %rdi            # imm = 0x810
movl -0x64(%rbp), %edx
movl $0x43c, %esi            # imm = 0x43C
callq 0x6b5c0
movq -0xd8(%rbp), %rcx
movl 0x800(%rcx), %eax
addl 0x9f8c8(%rcx), %eax
cltq
cmpq $0x7fc, %rax            # imm = 0x7FC
jbe 0x32cd6
movl $0x0, -0x4(%rbp)
jmp 0x32ddb
movq -0xd8(%rbp), %rax
movslq 0x800(%rax), %rcx
movq %rax, %rdi
addq %rcx, %rdi
movq %rax, %rsi
addq $0x810, %rsi            # imm = 0x810
addq $0x9f0c4, %rsi          # imm = 0x9F0C4
movslq 0x9f8c8(%rax), %rdx
callq 0x9610
movq -0xd8(%rbp), %rax
movl 0x800(%rax), %ecx
addl 0x9f8c8(%rax), %ecx
movl %ecx, 0x800(%rax)
leaq 0x8a0d1(%rip), %rdi     # 0xbcdf8
movl $0x45, %esi
callq 0x340b0
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x32dc8
movq -0xd8(%rbp), %rdi
addq $0x810, %rdi            # imm = 0x810
movl $0x446, %esi            # imm = 0x446
xorl %edx, %edx
callq 0x6b5c0
movq -0xd8(%rbp), %rcx
movl 0x800(%rcx), %eax
addl 0x9f8c8(%rcx), %eax
cltq
cmpq $0x7fc, %rax            # imm = 0x7FC
jbe 0x32d7e
movl $0x0, -0x4(%rbp)
jmp 0x32ddb
movq -0xd8(%rbp), %rax
movslq 0x800(%rax), %rcx
movq %rax, %rdi
addq %rcx, %rdi
movq %rax, %rsi
addq $0x810, %rsi            # imm = 0x810
addq $0x9f0c4, %rsi          # imm = 0x9F0C4
movslq 0x9f8c8(%rax), %rdx
callq 0x9610
movq -0xd8(%rbp), %rax
movl 0x800(%rax), %ecx
addl 0x9f8c8(%rax), %ecx
movl %ecx, 0x800(%rax)
movq -0xd8(%rbp), %rax
movl 0x800(%rax), %eax
shll $0x3, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xc8(%rbp), %rdi
callq 0x9d20
nopw %cs:(%rax,%rax)
nopl (%rax)