// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r14
movsd %xmm0, -0x38(%rbp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
xorps %xmm1, %xmm1
movups %xmm1, -0x54(%rbp)
movaps %xmm1, -0x60(%rbp)
leaq -0x84(%rbp), %r13
movq %rdx, %rdi
movq %r13, %rsi
callq 0x4f2b1
leaq 0x3(%rbx), %rdi
movl $0x4, %edx
movq %r12, %rsi
callq 0x8350
movl (%r13), %ecx
movq %rbx, %rdi
movl $0x38, %esi
movl $0x10, %edx
callq 0x4da98
movl $0x0, 0x840(%rbx)
movq %r15, 0x820(%rbx)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x828(%rbx)
movq 0x18(%r14), %r15
addq $0x8, %r14
movq %r14, -0x38(%rbp)
cmpq %r14, %r15
je 0x1c666
leaq -0x30(%rbp), %r13
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x111e0
movq -0x80(%rbp), %rax
movsbl (%rax), %esi
leaq 0x4e377(%rip), %rdi     # 0x6a8b0
callq 0x1d54b
cltq
movl $0x1, -0x60(%rbp,%rax,4)
movq -0x80(%rbp), %rdi
callq 0x4d35a
movq 0x848(%rbx), %rcx
movslq 0x840(%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x5, %rdx
movb %al, 0x10(%rcx,%rdx)
testb %al, %al
je 0x1c63f
leaq 0xe8(%r15), %r14
movl $0x18, %r12d
movsd -0x80(%r15,%r12,8), %xmm0
movslq 0x840(%rbx), %rax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq 0x848(%rbx), %rax
movsd %xmm0, -0xa0(%rax,%r12,8)
movsd -0x68(%r15,%r12,8), %xmm0
movsd %xmm0, -0x88(%rax,%r12,8)
movsd -0x50(%r15,%r12,8), %xmm0
mulsd 0x4e2e1(%rip), %xmm0    # 0x6a8a8
cvttsd2si %xmm0, %ecx
movb %cl, -0x6(%r12,%rax)
movq (%r14), %rsi
movq %r13, %rdi
callq 0x85c0
movq -0x80(%rbp), %rax
movb (%rax), %al
movl %eax, %edx
xorb $0x43, %dl
movb -0x2f(%rbp), %cl
xorb $0x32, %cl
orb %cl, %dl
jne 0x1c5f6
movb $0x31, -0x2f(%rbp)
jmp 0x1c603
xorb $0x47, %al
orb %cl, %al
jne 0x1c603
movl $0x57324c, -0x30(%rbp)  # imm = 0x57324C
leaq -0x2f(%rbp), %rdi
xorl %esi, %esi
callq 0x4d636
movslq 0x840(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
addq 0x848(%rbx), %rcx
movb %al, (%r12,%rcx)
addq $0x20, %r14
incq %r12
cmpq $0x1b, %r12
jne 0x1c580
incl 0x840(%rbx)
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x1c651
callq 0x85d0
movq %r15, %rdi
callq 0x8460
movq %rax, %r15
cmpq -0x38(%rbp), %rax
jne 0x1c50f
leaq 0x810(%rbx), %r14
movl $0x9, 0x800(%rbx)
leaq 0x4e232(%rip), %rdi     # 0x6a8b0
movl $0x47, %esi
callq 0x1d54b
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1c735
leaq 0x4e214(%rip), %rdi     # 0x6a8b0
movl $0x43, %esi
callq 0x1d54b
cltq
movl $0x1, %r15d
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1c6ee
leaq 0x4e1f4(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1d54b
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1c6ee
leaq 0x4e1da(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1d54b
cltq
xorl %r15d, %r15d
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %r15b
movq %r14, %rdi
movl $0x432, %esi            # imm = 0x432
movl %r15d, %edx
callq 0x3904f
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1c821
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4e174(%rip), %rdi     # 0x6a8b0
movl $0x43, %esi
callq 0x1d54b
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1c7cb
leaq 0x4e15a(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1d54b
cltq
movl $0x1, %edx
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1c78b
leaq 0x4e13b(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1d54b
cltq
xorl %edx, %edx
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %dl
movq %r14, %rdi
movl $0x464, %esi            # imm = 0x464
callq 0x3904f
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1c821
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4e0de(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1d54b
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1c844
leaq 0x4e0c4(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1d54b
cltq
movl -0x60(%rbp,%rax,4), %edx
movq %r14, %rdi
movl $0x43c, %esi            # imm = 0x43C
callq 0x3904f
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
jbe 0x1c829
xorl %r15d, %r15d
jmp 0x1c8b9
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4e065(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1d54b
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1c8ae
xorl %r15d, %r15d
movq %r14, %rdi
movl $0x446, %esi            # imm = 0x446
xorl %edx, %edx
callq 0x3904f
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1c8b9
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %r15d
addl 0x800(%rbx), %r15d
movl %r15d, 0x800(%rbx)
jmp 0x1c8b5
movl 0x800(%rbx), %r15d
shll $0x3, %r15d
movl %r15d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c8cd
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x1c8e2
callq 0x85d0
movq %rbx, %rdi
callq 0x8b30
nop