// File: /workspace/github_cpp_makefile_star2_O1/CMU-SAFARI[P]optimal-seed-solver/testBasicSolver.cc
// Function: main
int main(int argc, const char* argv[]) {
	int frequency;
	map <int, unsigned long long> frequencyCounter;

	BasicSolver solver;

	if (argc != 3) {
		cerr << "USAGE: ./testOptimalSolver <Tree File> <Read File>" << endl;
		exit(1);
	}

	cout << "Loading tree " << argv[1] << " into memory.\n";
	solver.loadTree(argv[1]);
	cout << "Finished loading. \n";

	int seedNum;
	//cout << "Please input number of seeds: ";
	cin >> seedNum;

	int seedLength;

	ifstream readFile;
	readFile.open(argv[2]);
	string read;
	
	char benchFileName[80];
	strcpy(benchFileName, argv[2]);
	char* benchName = strtok(benchFileName, ".");
	
	ofstream output;
	output.open( (string(benchName) + string(".analyzeBasic") ).c_str() );

	while (seedNum > 0) {	
		//cout << "Please input seed length: ";
		cin >> seedLength;
		
		frequencyCounter.clear();

		//Start reading the file
		readFile.clear();
		readFile.seekg(0, ios::beg);

		//Name
		getline(readFile, read);
		//Read
		getline(readFile, read);
		//cout << "DNA: " << read << endl;
		solver.init(read.length(), seedNum, seedLength);

		//Solve
		frequency = solver.solveDNA(read);
		if (frequencyCounter.find(frequency) == frequencyCounter.end() )
			frequencyCounter[frequency] = 1;
		else
			frequencyCounter[frequency]++;

		//Trash
		getline(readFile, read);
		getline(readFile, read);
			
		//Name
		getline(readFile, read);

		while (!readFile.eof()) {
			//Read
			getline(readFile, read);
			//cout << "DNA: " << read << endl;

			//Solve
			if (read.find('N') == string::npos) {
				frequency = solver.solveDNA(read);
				if (frequencyCounter.find(frequency) == frequencyCounter.end() )
					frequencyCounter[frequency] = 1;
				else
					frequencyCounter[frequency]++;
			}

			//Trash
			getline(readFile, read);
			getline(readFile, read);
			
			//Name
			getline(readFile, read);
		}

		cout << "seedNum: " << seedNum << " | seedLength: " << seedLength << endl;
		output << "seedNum: " << seedNum << " | seedLength: " << seedLength << endl;
		for (map<int, unsigned long long>::iterator iter = frequencyCounter.begin(); iter != frequencyCounter.end(); iter++)
			output << iter->first << ": " << iter->second << endl;

		cin >> seedNum;
	}
	
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8e8, %rsp            # imm = 0x8E8
movq %rsi, %r12
movl %edi, %ebx
leaq 0xe0(%rsp), %r14
movl $0x0, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %r14, 0x10(%r14)
movq %r14, 0x18(%r14)
movq %rax, 0x20(%r14)
leaq 0x580(%rsp), %rdi
callq 0x452c
cmpl $0x3, %ebx
jne 0x3f49
movq 0x98d8(%rip), %rbx      # 0xcfc8
leaq 0x5940(%rip), %rsi      # 0x9037
movl $0xd, %edx
movq %rbx, %rdi
callq 0x32d0
movq 0x8(%r12), %r15
testq %r15, %r15
je 0x372a
movq %r15, %rdi
callq 0x3120
movq 0x98ab(%rip), %rdi      # 0xcfc8
movq %r15, %rsi
movq %rax, %rdx
callq 0x32d0
jmp 0x3741
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3410
movq 0x9880(%rip), %rdi      # 0xcfc8
leaq 0x58f6(%rip), %rsi      # 0x9045
movl $0xe, %edx
callq 0x32d0
movq 0x8(%r12), %rsi
leaq 0x108(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x40d8
leaq 0x580(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x4542
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x37a9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x9818(%rip), %rdi      # 0xcfc8
leaq 0x589d(%rip), %rsi      # 0x9054
movl $0x13, %edx
callq 0x32d0
movq 0x9810(%rip), %rdi      # 0xcfd8
leaq 0xc(%rsp), %rsi
callq 0x3170
leaq 0x128(%rsp), %rdi
callq 0x32c0
movq 0x10(%r12), %rsi
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x3180
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x10(%r12), %rsi
leaq 0x530(%rsp), %r15
movq %r15, %rdi
callq 0x3240
leaq 0x5b26(%rip), %rsi      # 0x934f
movq %r15, %rdi
callq 0x33c0
movq %rax, %r15
leaq 0x330(%rsp), %rdi
callq 0x3420
leaq 0xb8(%rsp), %rdi
leaq 0x17(%rsp), %rdx
movq %r15, %rsi
callq 0x40d8
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5802(%rip), %rsi      # 0x9068
leaq 0x5808(%rip), %rdx      # 0x9075
leaq 0x58(%rsp), %rdi
callq 0x4266
leaq 0xc8(%rsp), %r12
movq -0x10(%r12), %rcx
movq -0x8(%r12), %r8
movq 0x60(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r12, %rcx
je 0x38a4
movq 0xc8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x38bf
movl $0xf, %esi
cmpq %r15, 0x58(%rsp)
je 0x38ba
movq 0x68(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x38d3
movq 0x58(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x30e0
jmp 0x38e1
leaq 0x58(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32b0
leaq 0x28(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x3905
movq %rsi, 0x18(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x28(%rsp)
jmp 0x390b
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x20(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x18(%rsp), %rsi
leaq 0x330(%rsp), %rdi
movl $0x10, %edx
callq 0x3050
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x395a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x3971
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb8(%rsp), %rdi
cmpq %r12, %rdi
je 0x398e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x38(%rsp), %r13
leaq 0x98(%rsp), %r15
cmpl $0x0, 0xc(%rsp)
jle 0x3eba
movq 0x962b(%rip), %rdi      # 0xcfd8
leaq 0x10(%rsp), %rsi
callq 0x3170
leaq 0xd8(%rsp), %rdi
callq 0x42f6
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
xorl %esi, %esi
callq 0x3410
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3370
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movl 0x40(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
leaq 0x580(%rsp), %rdi
callq 0x45bc
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x41d6
leaq 0x580(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x45d0
movl %eax, 0x8(%rsp)
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3aa9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xe8(%rsp), %rcx
movq %r14, %rax
testq %rcx, %rcx
je 0x3ad7
movl 0x8(%rsp), %edx
movq %r14, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x3ac0
movq %r14, %rcx
cmpq %r14, %rax
je 0x3aed
movl 0x8(%rsp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %r14, %rax
movq %rax, %rcx
cmpq %r14, %rcx
je 0x3b09
leaq 0xd8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4116
incq (%rax)
jmp 0x3b22
leaq 0xd8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4116
movq $0x1, (%rax)
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x148(%rsp,%rax)
jne 0x3d3e
leaq (%rsp,%rax), %rdi
addq $0x128, %rdi            # imm = 0x128
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq %r13, %rdi
movl $0x4e, %esi
xorl %edx, %edx
callq 0x3340
cmpq $-0x1, %rax
jne 0x3cc4
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x41d6
leaq 0x580(%rsp), %rdi
movq %r15, %rsi
callq 0x45d0
movl %eax, 0x8(%rsp)
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x3c4b
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xe8(%rsp), %rcx
movq %r14, %rax
testq %rcx, %rcx
je 0x3c79
movl 0x8(%rsp), %edx
movq %r14, %rax
xorl %esi, %esi
cmpl %edx, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x3c62
movq %r14, %rcx
cmpq %r14, %rax
je 0x3c8f
movl 0x8(%rsp), %ecx
cmpl 0x20(%rax), %ecx
cmovlq %r14, %rax
movq %rax, %rcx
cmpq %r14, %rcx
je 0x3cab
leaq 0xd8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4116
incq (%rax)
jmp 0x3cc4
leaq 0xd8(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4116
movq $0x1, (%rax)
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
movq 0x128(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %edx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3470
jmp 0x3b97
movl $0x9, %edx
movq 0x927e(%rip), %rdi      # 0xcfc8
leaq 0x5325(%rip), %rsi      # 0x9076
callq 0x32d0
movl 0xc(%rsp), %esi
movq 0x9267(%rip), %rdi      # 0xcfc8
callq 0x3430
movq %rax, %r12
movl $0xf, %edx
movq %rax, %rdi
leaq 0x5308(%rip), %rsi      # 0x9080
callq 0x32d0
movl 0x10(%rsp), %esi
movq %r12, %rdi
callq 0x3430
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movl $0x9, %edx
leaq 0x330(%rsp), %rdi
leaq 0x52af(%rip), %rsi      # 0x9076
callq 0x32d0
movl 0xc(%rsp), %esi
leaq 0x330(%rsp), %rdi
callq 0x3430
movq %rax, %r12
movl $0xf, %edx
movq %rax, %rdi
leaq 0x5291(%rip), %rsi      # 0x9080
callq 0x32d0
movl 0x10(%rsp), %esi
movq %r12, %rdi
callq 0x3430
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq 0xf0(%rsp), %rbp
cmpq %r14, %rbp
je 0x3ea4
movl 0x20(%rbp), %esi
leaq 0x330(%rsp), %rdi
callq 0x3430
movq %rax, %r12
movl $0x2, %edx
movq %rax, %rdi
leaq 0x5564(%rip), %rsi      # 0x93bd
callq 0x32d0
movq 0x28(%rbp), %rsi
movq %r12, %rdi
callq 0x31a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31c0
movq %rbp, %rdi
callq 0x31d0
movq %rax, %rbp
cmpq %r14, %rax
jne 0x3e37
movq 0x912d(%rip), %rdi      # 0xcfd8
leaq 0xc(%rsp), %rsi
callq 0x3170
jmp 0x399b
movq 0x90ff(%rip), %rax      # 0xcfc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x338(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x330(%rsp,%rcx)
callq 0x3210
leaq 0x428(%rsp), %rdi
callq 0x30f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3f0e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x128(%rsp), %rdi
callq 0x30c0
leaq 0x580(%rsp), %rdi
callq 0x453c
leaq 0xd8(%rsp), %rdi
callq 0x4186
xorl %eax, %eax
addq $0x8e8, %rsp            # imm = 0x8E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x90a0(%rip), %rdi      # 0xcff0
leaq 0x50ad(%rip), %rsi      # 0x9004
movl $0x32, %edx
callq 0x32d0
movq 0x9088(%rip), %rdi      # 0xcff0
callq 0x3130
movl $0x1, %edi
callq 0x32f0
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3f9a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x3f9a
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x3fb6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x3fb6
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4080
movq 0xc8(%rsp), %rsi
jmp 0x406f
jmp 0x407d
movq %rax, %rbx
jmp 0x408d
movq %rax, %rbx
jmp 0x40a9
jmp 0x4028
jmp 0x4028
movq %rax, %rbx
leaq 0x118(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x40b6
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x40b6
jmp 0x4028
movq %rax, %rbx
jmp 0x40c3
movq %rax, %rbx
jmp 0x40b6
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4080
movq 0x88(%rsp), %rsi
jmp 0x406f
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x4080
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x4080
jmp 0x407d
jmp 0x407d
movq %rax, %rbx
leaq 0x330(%rsp), %rdi
callq 0x33a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x40a9
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x128(%rsp), %rdi
callq 0x30c0
leaq 0x580(%rsp), %rdi
callq 0x453c
leaq 0xd8(%rsp), %rdi
callq 0x4186
movq %rbx, %rdi
callq 0x3450