// File: /workspace/github_cpp_makefile_star2_O1/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 0x4fc2d
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 0x4e403
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 0x1ccdf
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 0x1143c
movq -0x80(%rbp), %rax
movsbl (%rax), %esi
leaq 0x4dcfb(%rip), %rdi     # 0x6a8b0
callq 0x1db90
cltq
movl $0x1, -0x60(%rbp,%rax,4)
movq -0x80(%rbp), %rdi
callq 0x4dc92
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 0x1ccb8
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 0x4dc65(%rip), %xmm0    # 0x6a8a8
cvttsd2si %xmm0, %ecx
movb %cl, -0x6(%r12,%rax)
movq (%r14), %rsi
movq %r13, %rdi
callq 0x85c0
movq -0x80(%rbp), %rax
cmpb $0x43, (%rax)
jne 0x1cc6a
cmpb $0x32, -0x2f(%rbp)
jne 0x1cc6a
movb $0x31, -0x2f(%rbp)
cmpb $0x47, (%rax)
jne 0x1cc7c
cmpb $0x32, -0x2f(%rbp)
jne 0x1cc7c
movl $0x57324c, -0x30(%rbp)  # imm = 0x57324C
leaq -0x2f(%rbp), %rdi
xorl %esi, %esi
callq 0x4dfa9
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 0x1cbfc
incl 0x840(%rbx)
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x1ccca
callq 0x85d0
movq %r15, %rdi
callq 0x8460
movq %rax, %r15
cmpq -0x38(%rbp), %rax
jne 0x1cb8b
leaq 0x810(%rbx), %r14
movl $0x9, 0x800(%rbx)
leaq 0x4dbb9(%rip), %rdi     # 0x6a8b0
movl $0x47, %esi
callq 0x1db90
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1cdae
leaq 0x4db9b(%rip), %rdi     # 0x6a8b0
movl $0x43, %esi
callq 0x1db90
cltq
movl $0x1, %r15d
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1cd67
leaq 0x4db7b(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1db90
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1cd67
leaq 0x4db61(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1db90
cltq
xorl %r15d, %r15d
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %r15b
movq %r14, %rdi
movl $0x432, %esi            # imm = 0x432
movl %r15d, %edx
callq 0x3969e
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1ce9a
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4dafb(%rip), %rdi     # 0x6a8b0
movl $0x43, %esi
callq 0x1db90
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1ce44
leaq 0x4dae1(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1db90
cltq
movl $0x1, %edx
cmpl $0x0, -0x60(%rbp,%rax,4)
jne 0x1ce04
leaq 0x4dac2(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1db90
cltq
xorl %edx, %edx
cmpl $0x0, -0x60(%rbp,%rax,4)
setne %dl
movq %r14, %rdi
movl $0x464, %esi            # imm = 0x464
callq 0x3969e
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1ce9a
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4da65(%rip), %rdi     # 0x6a8b0
movl $0x52, %esi
callq 0x1db90
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1cebd
leaq 0x4da4b(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1db90
cltq
movl -0x60(%rbp,%rax,4), %edx
movq %r14, %rdi
movl $0x43c, %esi            # imm = 0x43C
callq 0x3969e
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
jbe 0x1cea2
xorl %r15d, %r15d
jmp 0x1cf27
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
leaq 0x4d9ec(%rip), %rdi     # 0x6a8b0
movl $0x45, %esi
callq 0x1db90
cltq
cmpl $0x0, -0x60(%rbp,%rax,4)
je 0x1cf1c
xorl %r15d, %r15d
movq %r14, %rdi
movl $0x446, %esi            # imm = 0x446
xorl %edx, %edx
callq 0x3969e
movslq 0x800(%rbx), %rdi
movslq 0x9f8c8(%rbx), %rdx
leal (%rdx,%rdi), %eax
cmpl $0x7fc, %eax            # imm = 0x7FC
ja 0x1cf27
addq %rbx, %rdi
leaq 0x9f8d4(%rbx), %rsi
callq 0x84f0
movl 0x9f8c8(%rbx), %eax
addl %eax, 0x800(%rbx)
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 0x1cf3b
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x1cf50
callq 0x85d0
movq %rbx, %rdi
callq 0x8b40