// File: CMU-SAFARI[P]optimal-seed-solver/analyzeBasic.cc
// Function: AnalyzeBasic::generateHash(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
void AnalyzeBasic::generateHash(string refName, unsigned int seedLength) {
	refDB.loadRefFile(refName);

	this->seedLength = seedLength;

	string seed = string(seedLength, 'N');
	
	freqTable.resize( (1 << (2 * seedLength) ), 0);

	for (unsigned int chromoCount = 0; chromoCount < refDB.getNumOfChromo(); chromoCount++) {
		refDB.loadChromo(chromoCount);
		for (unsigned int refPos = 0; refPos < refDB.getChromoLength() - seedLength; refPos++) {
			seed = refDB.getRefSeq(refPos, seedLength);
			if (seed.find('N') == string::npos && seed.find('M') == string::npos && seed.find('R') == string::npos) {
				unsigned int hash = hashGen.calculateHash(seed, seed.length() );
				freqTable[hash]++;
			}
		}
	}	
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movl %edx, 0xd4(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x3140
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x8160
jmp 0x61fe
leaq 0xb0(%rsp), %rdi
callq 0x31b0
movq 0x38(%rsp), %rax
movl 0xd4(%rsp), %ecx
movl %ecx, 0x270(%rax)
movl 0xd4(%rsp), %eax
movq %rax, 0x28(%rsp)
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x3570
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rcx
leaq 0x80(%rsp), %rdi
movl $0x4e, %edx
callq 0x6890
jmp 0x6256
leaq 0x7f(%rsp), %rdi
callq 0x3300
movq 0x38(%rsp), %rdi
addq $0x278, %rdi            # imm = 0x278
movb 0xd4(%rsp), %cl
addb %cl, %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, %esi
movl $0x0, 0x78(%rsp)
leaq 0x78(%rsp), %rdx
callq 0x6910
jmp 0x6292
movl $0x0, 0x74(%rsp)
movq 0x38(%rsp), %rdi
movl 0x74(%rsp), %eax
movl %eax, 0x20(%rsp)
callq 0x88b0
movl %eax, 0x24(%rsp)
jmp 0x62b2
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
cmpl %ecx, %eax
jae 0x648a
movq 0x38(%rsp), %rdi
movl 0x74(%rsp), %esi
callq 0x85e0
jmp 0x62d2
movl $0x0, 0x70(%rsp)
movq 0x38(%rsp), %rdi
movl 0x70(%rsp), %eax
movl %eax, 0x18(%rsp)
callq 0x8890
movl %eax, 0x1c(%rsp)
jmp 0x62f2
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
subl 0xd4(%rsp), %ecx
cmpl %ecx, %eax
jae 0x6478
movq 0x38(%rsp), %rsi
movl 0x70(%rsp), %edx
movl 0xd4(%rsp), %ecx
leaq 0x50(%rsp), %rdi
callq 0x8900
jmp 0x6325
leaq 0x80(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3380
leaq 0x50(%rsp), %rdi
callq 0x31b0
leaq 0x80(%rsp), %rdi
movl $0x4e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33c0
cmpq $-0x1, %rax
jne 0x6466
leaq 0x80(%rsp), %rdi
movl $0x4d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33c0
cmpq $-0x1, %rax
jne 0x6466
leaq 0x80(%rsp), %rdi
movl $0x52, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x33c0
cmpq $-0x1, %rax
jne 0x6466
movq 0x38(%rsp), %rax
addq $0x268, %rax            # imm = 0x268
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x3460
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movl %eax, %edx
callq 0x9d60
movl %eax, 0x14(%rsp)
jmp 0x63d8
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, 0x4c(%rsp)
addq $0x278, %rdi            # imm = 0x278
movl 0x4c(%rsp), %eax
movl %eax, %esi
callq 0x69d0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x6466
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x31b0
jmp 0x649f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x7f(%rsp), %rdi
callq 0x3300
jmp 0x649f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa8(%rsp)
movl %eax, 0xa4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x31b0
jmp 0x649f
jmp 0x6468
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x62da
jmp 0x647a
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x629a
leaq 0x80(%rsp), %rdi
callq 0x31b0
addq $0xe8, %rsp
retq
movq 0xa8(%rsp), %rdi
callq 0x3560
nopl (%rax)