// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdx, -0xb0(%rbp)
movq %rsi, -0xc0(%rbp)
movq %rdi, -0xa8(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0xb8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
callq 0x99f0
movq -0xb0(%rbp), %rdi
callq 0x3100
movq %rax, %rdi
callq 0x33e0
movq -0xa8(%rbp), %rdi
movl %eax, 0x20(%rdi)
movl $0x1, 0x28(%rdi)
cmpl $0x0, 0x20(%rdi)
jge 0x8cf7
movq -0xa8(%rbp), %rax
xorl %ecx, %ecx
subl 0x20(%rax), %ecx
movl %ecx, 0x20(%rax)
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0xc0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
callq 0x3040
jmp 0x8d0c
movq -0xa8(%rbp), %rdi
movl $0x2e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3360
movq %rax, -0x38(%rbp)
cmpq $-0x1, -0x38(%rbp)
je 0x8ddd
movq -0xa8(%rbp), %rsi
movq -0x38(%rbp), %rdx
incq %rdx
leaq -0x58(%rbp), %rdi
movq $-0x1, %rcx
callq 0x3280
jmp 0x8d50
leaq -0x58(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3100
movq %rax, %rdi
callq 0x33e0
movq -0xc8(%rbp), %rdi
movl %eax, %edx
movq -0xa8(%rbp), %rax
movl 0x20(%rax), %esi
movl %edx, %ecx
movl %esi, %edx
leal -0x1(%rcx,%rdx), %ecx
movl %ecx, 0x20(%rax)
callq 0x3518
movq -0xa8(%rbp), %rsi
movq -0x38(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x78(%rbp), %rdi
callq 0x3280
jmp 0x8da5
movq -0xa8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3320
leaq -0x78(%rbp), %rdi
callq 0x3518
jmp 0x8ddd
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x9a10
jmp 0x8f21
testb $0x1, -0x19(%rbp)
je 0x8efb
movq -0xa8(%rbp), %rdi
callq 0x33c0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x34f0
movq %rax, -0xd0(%rbp)
jmp 0x8e0e
movq -0xd0(%rbp), %rax
movb (%rax), %al
movb %al, -0x79(%rbp)
movsbl -0x79(%rbp), %eax
cmpl $0x30, %eax
jl 0x8e2c
movsbl -0x79(%rbp), %eax
cmpl $0x39, %eax
jle 0x8e65
movsbl -0x79(%rbp), %eax
cmpl $0x41, %eax
jl 0x8e3e
movsbl -0x79(%rbp), %eax
cmpl $0x5a, %eax
jle 0x8e65
movq -0xa8(%rbp), %rdi
leaq 0x360e(%rip), %rsi      # 0xc45a
callq 0x89a0
movb %al, -0xd1(%rbp)
jmp 0x8e59
movb -0xd1(%rbp), %al
testb $0x1, %al
jne 0x8e65
jmp 0x8e78
movq -0xa8(%rbp), %rax
movl $0x0, 0x24(%rax)
jmp 0x8ef9
movq -0xa8(%rbp), %rdi
callq 0x33c0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x34f0
movq %rax, -0xe0(%rbp)
jmp 0x8e9f
movq -0xa8(%rbp), %rdi
movq -0xe0(%rbp), %rax
movsbl (%rax), %eax
addl $-0x61, %eax
movl %eax, 0x24(%rdi)
callq 0x33c0
movq -0xa8(%rbp), %rsi
movq %rax, %rcx
decq %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0xa0(%rbp), %rdi
callq 0x3280
jmp 0x8eda
movq -0xa8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3320
leaq -0xa0(%rbp), %rdi
callq 0x3518
jmp 0x8efb
movb $0x1, -0x1a(%rbp)
testb $0x1, -0x1a(%rbp)
jne 0x8f11
movq -0xa8(%rbp), %rdi
callq 0x9a10
movq -0xb8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x3450
nopw (%rax,%rax)