// File: ratulSharker[P]Havec/src/common.cpp
// Function: fullHasher(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
unsigned long long fullHasher(std::string khmer,unsigned int whichHashFunc){

	unsigned char map_byte = two_bit_repr[whichHashFunc]; // A T G C
	unsigned long long hashed_val = 0;
	
	//decide the hash values
	unsigned char hashA = ((map_byte & 0XC0)>>6),
				  hashT = ((map_byte & 0X30)>>4),
				  hashG = ((map_byte & 0X0C)>>2),
				  hashC = ((map_byte & 0X03));
	
	neucleotide_status = NEUCLEOTIDE_CHAIN_IS_OK;//at first assume every neucleotide is ok
	
	for(unsigned int i=0;i < khmer.length() &&
						(neucleotide_status != N_FOUND_IN_NEUCLEOTIDE);i++){
		//iterate through each & every char
		switch(toupper(khmer[i])){
			case 'A': //A = whichHashFunc % 4
				hashed_val = (hashed_val << 2) | hashA;
				break;

			case 'T'://T = (whichHashFunc + 1) % 4
				hashed_val = (hashed_val << 2) | hashT;
				break;

			case 'G'://G = (whichHashFunc + 2) % 4
				hashed_val = (hashed_val << 2) | hashG;
				break;

			case 'C'://C = (whichHashFunc + 3) % 4
				hashed_val = (hashed_val << 2) | hashC;
				break;
			
			default://N found no need to compute further
				neucleotide_status = N_FOUND_IN_NEUCLEOTIDE;
				return 0; //now check at the call side of full hasher
				break;
				
		}
	}
	
	return hashed_val;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x30(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x7261(%rip), %rax      # 0x17360
movb (%rax,%rcx), %al
movb %al, -0x15(%rbp)
movq $0x0, -0x20(%rbp)
movzbl -0x15(%rbp), %eax
andl $0xc0, %eax
sarl $0x6, %eax
movb %al, -0x21(%rbp)
movzbl -0x15(%rbp), %eax
andl $0x30, %eax
sarl $0x4, %eax
movb %al, -0x22(%rbp)
movzbl -0x15(%rbp), %eax
andl $0xc, %eax
sarl $0x2, %eax
movb %al, -0x23(%rbp)
movzbl -0x15(%rbp), %eax
andl $0x3, %eax
movb %al, -0x24(%rbp)
movl $0x8, 0x722e(%rip)      # 0x17378
movl $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rdi
movl -0x28(%rbp), %eax
movq %rax, -0x40(%rbp)
callq 0x34c0
movq -0x40(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x31(%rbp)
jae 0x1017f
cmpl $0x7, 0x71ff(%rip)      # 0x17378
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x1018b
jmp 0x1023b
movq -0x30(%rbp), %rdi
movl -0x28(%rbp), %eax
movl %eax, %esi
callq 0x35e0
movsbl (%rax), %edi
callq 0x3590
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x13, %eax
ja 0x10217
movq -0x48(%rbp), %rax
leaq 0x162e(%rip), %rcx      # 0x117e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
shlq $0x2, %rax
movzbl -0x21(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1022b
movq -0x20(%rbp), %rax
shlq $0x2, %rax
movzbl -0x22(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1022b
movq -0x20(%rbp), %rax
shlq $0x2, %rax
movzbl -0x23(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1022b
movq -0x20(%rbp), %rax
shlq $0x2, %rax
movzbl -0x24(%rbp), %ecx
orq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1022b
movl $0x7, 0x7157(%rip)      # 0x17378
movq $0x0, -0x8(%rbp)
jmp 0x10243
jmp 0x1022d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x10151
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)