// File: /workspace/github_cpp_makefile_star2_O2/superyuan[P]refeditor/CLineFields1.cpp
// Function: GenomeLib::toRef(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
GenomePosition GenomeLib::toRef(string name, string position, bool removeb)
{
	GenomePosition gp;
	gp.pos = atoi(position.c_str());
	gp.strand = 1;
	if (gp.pos < 0) {
		gp.pos = -gp.pos;
		gp.strand = -1;
	}
	gp.chrName = name;
	size_t found = gp.chrName.find('.');
	if (found != string::npos) {
		// it is a stripped diploid chromosome
		gp.pos += atoi(gp.chrName.substr(found+1).c_str()) -1;
		gp.chrName = gp.chrName.substr(0, found);
	}
	if (removeb) {
		char last_char=gp.chrName[gp.chrName.length()-1];
		if ((last_char>='0' && last_char<='9')||(last_char>='A' && last_char<='Z')||(gp.chrName=="*")) {
			// read is on reference allele
			gp.allele = 0;
		} else {
			// read is on alternative allele
			gp.allele = gp.chrName[gp.chrName.length()-1]-'a';
			gp.chrName = gp.chrName.substr(0,gp.chrName.length()-1);
		}
		//		if (gp.chrName.length()>MAX_CHR_NAME_LEN) {
		//convert mini chromosome coordinates to normal coordinates
		//			gp.chrName = gp.chrName.substr(0,gp.chrName.length()-3);
		//		}
		//found = gp.chrName.find('b');// remove all 'b' in the chr name
		//while (found != string::npos){
		//	gp.chrName.replace(found,1,"");
		//	found = gp.chrName.find('b');
		//}
	}
	return gp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rsi, %r14
movb $0x0, 0x10(%rdi)
movq (%rdx), %rdi
callq 0x2310
movl %eax, 0x20(%rbx)
movl $0x1, 0x28(%rbx)
testl %eax, %eax
jns 0x4395
negl %eax
movl %eax, 0x20(%rbx)
orl $-0x1, 0x28(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2110
pushq $0x2e
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x22b0
cmpq $-0x1, %rax
je 0x4413
movq %rax, %r14
leaq 0x1(%rax), %rdx
leaq 0x8(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %rbx, %rsi
callq 0x2230
leaq 0x8(%rsp), %r15
movq (%r15), %rdi
callq 0x2310
movl 0x20(%rbx), %ecx
addl %ecx, %eax
decl %eax
movl %eax, 0x20(%rbx)
movq %r15, %rdi
callq 0x2418
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x2230
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
movq %r14, %rdi
callq 0x2418
testb %bpl, %bpl
je 0x448c
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movb -0x1(%rax,%rcx), %al
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
setb %cl
addb $-0x41, %al
cmpb $0x1a, %al
setb %al
orb %cl, %al
jne 0x444a
leaq 0xf60(%rip), %rsi       # 0x539e
movq %rbx, %rdi
callq 0x423c
testb %al, %al
je 0x4450
andl $0x0, 0x24(%rbx)
jmp 0x448c
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movsbl -0x1(%rax,%rcx), %eax
decq %rcx
addl $-0x61, %eax
movl %eax, 0x24(%rbx)
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2230
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
movq %r14, %rdi
callq 0x2418
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x44a0
jmp 0x44a0
jmp 0x44a0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2418
movq %r14, %rdi
callq 0x2380
nop