// File: CMU-SAFARI[P]optimal-seed-solver/testReference.cc
// Function: main
int main(int argc, const char* argv[]) {
	RefDB refDB;
	if (argc != 2) {
		cerr << "Please also put the reference file name" << endl;
		exit(1);
	}

	refDB.loadRefFile(argv[1]);

	int chromo_number = -1;
	int location;
	int length;

	cout << "Num of chromosomes: " << refDB.getNumOfChromo() << endl;

	for (int i = 0; i < refDB.getNumOfChromo(); i++) {
		refDB.loadChromo(i);
		for (int j = 0; j < refDB.getChromoLength(); j++) {
			char base = refDB.getRefBase(j, 0);
			if (base != 'A' && base != 'C' && base != 'G' && base != 'T' && base != 'N') {
				cout << i << "-" << j << ": " << base << endl;
				cout << refDB.getRefSeq(j - 5, 11) << endl;
			}

			if (base == 'N') {
				if (refDB.getRefBase(j+1, 0) != 'N') {
					cout << i << "-" << j << ": N" << endl;
					cout << refDB.getRefSeq(j - 5, 11) << endl;
					j++;
				}
				else if (refDB.getRefBase(j+2, 0) != 'N') {
					cout << i << "-" << j << ": NN" << endl;
					cout << refDB.getRefSeq(j - 5, 12) << endl;
					j = j + 2;
				}
				else if (refDB.getRefBase(j+3, 0) != 'N') {
					cout << i << "-" << j << ": NNN" << endl;
					cout << refDB.getRefSeq(j - 5, 13) << endl;
					j = j + 3;
				}
				else if (refDB.getRefBase(j+4, 0) != 'N') {
					cout << i << "-" << j << ": NNNN" << endl;
					cout << refDB.getRefSeq(j - 5, 14) << endl;
					j = j + 4;
				}
				else if (refDB.getRefBase(j+5, 0) != 'N') {
					cout << i << "-" << j << ": NNNN" << endl;
					cout << refDB.getRefSeq(j - 5, 15) << endl;
					j = j + 5;
				}
				else {
					while (j < refDB.getChromoLength() && refDB.getRefBase(j+1, 0) == 'N' )
						j++;
				}
			}
		}
	
	}

	return 0;
}

// Assembly:
subq $0x508, %rsp            # imm = 0x508
movl $0x0, 0x504(%rsp)
movl %edi, 0x500(%rsp)
movq %rsi, 0x4f8(%rsp)
leaq 0x290(%rsp), %rdi
callq 0x4560
cmpl $0x2, 0x500(%rsp)
je 0x36ae
movq 0x6991(%rip), %rdi      # 0x9ff0
leaq 0x399e(%rip), %rsi      # 0x7004
callq 0x3220
movq %rax, 0x178(%rsp)
jmp 0x3675
movq 0x178(%rsp), %rdi
movq 0x693c(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x368b
movl $0x1, %edi
callq 0x32e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x41db
movq 0x4f8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x168(%rsp)
leaq 0x25f(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0x3440
movq 0x168(%rsp), %rsi
movq 0x170(%rsp), %rdx
leaq 0x260(%rsp), %rdi
callq 0x4200
jmp 0x36f6
leaq 0x290(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x4610
jmp 0x370d
leaq 0x260(%rsp), %rdi
callq 0x3170
leaq 0x25f(%rsp), %rdi
callq 0x3280
movl $0xffffffff, 0x258(%rsp) # imm = 0xFFFFFFFF
movq 0x6897(%rip), %rdi      # 0x9fd0
leaq 0x38ec(%rip), %rsi      # 0x702c
callq 0x3220
movq %rax, 0x160(%rsp)
jmp 0x374f
leaq 0x290(%rsp), %rdi
callq 0x4d60
movl %eax, 0x15c(%rsp)
jmp 0x3765
movl 0x15c(%rsp), %esi
movq 0x160(%rsp), %rdi
callq 0x3330
movq %rax, 0x150(%rsp)
jmp 0x3783
movq 0x150(%rsp), %rdi
movq 0x682e(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3799
movl $0x0, 0x24c(%rsp)
movl 0x24c(%rsp), %eax
movl %eax, 0x148(%rsp)
leaq 0x290(%rsp), %rdi
callq 0x4d60
movl %eax, 0x14c(%rsp)
jmp 0x37c8
movl 0x148(%rsp), %eax
movl 0x14c(%rsp), %ecx
cmpl %ecx, %eax
jae 0x41b4
movl 0x24c(%rsp), %esi
leaq 0x290(%rsp), %rdi
callq 0x4a90
jmp 0x37f4
movl $0x0, 0x248(%rsp)
movl 0x248(%rsp), %eax
movl %eax, 0x140(%rsp)
leaq 0x290(%rsp), %rdi
callq 0x4d40
movl %eax, 0x144(%rsp)
jmp 0x3823
movl 0x140(%rsp), %eax
movl 0x144(%rsp), %ecx
cmpl %ecx, %eax
jae 0x419c
movl 0x248(%rsp), %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0x13f(%rsp)
jmp 0x3858
movb 0x13f(%rsp), %al
movb %al, 0x247(%rsp)
movsbl 0x247(%rsp), %eax
cmpl $0x41, %eax
je 0x3a3f
movsbl 0x247(%rsp), %eax
cmpl $0x43, %eax
je 0x3a3f
movsbl 0x247(%rsp), %eax
cmpl $0x47, %eax
je 0x3a3f
movsbl 0x247(%rsp), %eax
cmpl $0x54, %eax
je 0x3a3f
movsbl 0x247(%rsp), %eax
cmpl $0x4e, %eax
je 0x3a3f
movl 0x24c(%rsp), %esi
movq 0x6707(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0x130(%rsp)
jmp 0x38d8
movq 0x130(%rsp), %rdi
leaq 0x375a(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0x128(%rsp)
jmp 0x38f6
movq 0x128(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0x120(%rsp)
jmp 0x3914
movq 0x120(%rsp), %rdi
leaq 0x3789(%rip), %rsi      # 0x70ac
callq 0x3220
movq %rax, 0x118(%rsp)
jmp 0x3932
movq 0x118(%rsp), %rdi
movsbl 0x247(%rsp), %esi
callq 0x32d0
movq %rax, 0x110(%rsp)
jmp 0x3951
movq 0x110(%rsp), %rdi
movq 0x6660(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3967
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x220(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xb, %ecx
callq 0x4db0
jmp 0x398d
movq 0x663c(%rip), %rdi      # 0x9fd0
leaq 0x220(%rsp), %rsi
callq 0x3200
movq %rax, 0x108(%rsp)
jmp 0x39ab
movq 0x108(%rsp), %rdi
movq 0x6606(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x39c1
leaq 0x220(%rsp), %rdi
callq 0x3170
jmp 0x3a3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
jmp 0x3a07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x3170
leaq 0x25f(%rsp), %rdi
callq 0x3280
jmp 0x41db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x220(%rsp), %rdi
callq 0x3170
jmp 0x41db
movsbl 0x247(%rsp), %eax
cmpl $0x4e, %eax
jne 0x4184
movl 0x248(%rsp), %esi
incl %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0x107(%rsp)
jmp 0x3a71
movb 0x107(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
je 0x3bb4
movl 0x24c(%rsp), %esi
movq 0x653e(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0xf8(%rsp)
jmp 0x3aa1
movq 0xf8(%rsp), %rdi
leaq 0x3591(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0xf0(%rsp)
jmp 0x3abf
movq 0xf0(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0xe8(%rsp)
jmp 0x3add
movq 0xe8(%rsp), %rdi
leaq 0x3557(%rip), %rsi      # 0x7043
callq 0x3220
movq %rax, 0xe0(%rsp)
jmp 0x3afb
movq 0xe0(%rsp), %rdi
movq 0x64b6(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3b11
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x200(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xb, %ecx
callq 0x4db0
jmp 0x3b37
movq 0x6492(%rip), %rdi      # 0x9fd0
leaq 0x200(%rsp), %rsi
callq 0x3200
movq %rax, 0xd8(%rsp)
jmp 0x3b55
movq 0xd8(%rsp), %rdi
movq 0x645c(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3b6b
leaq 0x200(%rsp), %rdi
callq 0x3170
movl 0x248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x248(%rsp)
jmp 0x4182
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x3170
jmp 0x41db
movl 0x248(%rsp), %esi
addl $0x2, %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0xd7(%rsp)
jmp 0x3bd6
movb 0xd7(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
je 0x3d19
movl 0x24c(%rsp), %esi
movq 0x63d9(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0xc8(%rsp)
jmp 0x3c06
movq 0xc8(%rsp), %rdi
leaq 0x342c(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0xc0(%rsp)
jmp 0x3c24
movq 0xc0(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0xb8(%rsp)
jmp 0x3c42
movq 0xb8(%rsp), %rdi
leaq 0x33f6(%rip), %rsi      # 0x7047
callq 0x3220
movq %rax, 0xb0(%rsp)
jmp 0x3c60
movq 0xb0(%rsp), %rdi
movq 0x6351(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3c76
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x1e0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xc, %ecx
callq 0x4db0
jmp 0x3c9c
movq 0x632d(%rip), %rdi      # 0x9fd0
leaq 0x1e0(%rsp), %rsi
callq 0x3200
movq %rax, 0xa8(%rsp)
jmp 0x3cba
movq 0xa8(%rsp), %rdi
movq 0x62f7(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3cd0
leaq 0x1e0(%rsp), %rdi
callq 0x3170
movl 0x248(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x248(%rsp)
jmp 0x4180
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x3170
jmp 0x41db
movl 0x248(%rsp), %esi
addl $0x3, %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0xa7(%rsp)
jmp 0x3d3b
movb 0xa7(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
je 0x3e78
movl 0x24c(%rsp), %esi
movq 0x6274(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0x98(%rsp)
jmp 0x3d6b
movq 0x98(%rsp), %rdi
leaq 0x32c7(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0x90(%rsp)
jmp 0x3d89
movq 0x90(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0x88(%rsp)
jmp 0x3da7
movq 0x88(%rsp), %rdi
leaq 0x3296(%rip), %rsi      # 0x704c
callq 0x3220
movq %rax, 0x80(%rsp)
jmp 0x3dc5
movq 0x80(%rsp), %rdi
movq 0x61ec(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3ddb
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x1c0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xd, %ecx
callq 0x4db0
jmp 0x3e01
movq 0x61c8(%rip), %rdi      # 0x9fd0
leaq 0x1c0(%rsp), %rsi
callq 0x3200
movq %rax, 0x78(%rsp)
jmp 0x3e1c
movq 0x78(%rsp), %rdi
movq 0x6198(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3e2f
leaq 0x1c0(%rsp), %rdi
callq 0x3170
movl 0x248(%rsp), %eax
addl $0x3, %eax
movl %eax, 0x248(%rsp)
jmp 0x417e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x3170
jmp 0x41db
movl 0x248(%rsp), %esi
addl $0x4, %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0x77(%rsp)
jmp 0x3e97
movb 0x77(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
je 0x3fb9
movl 0x24c(%rsp), %esi
movq 0x611b(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0x68(%rsp)
jmp 0x3ec1
movq 0x68(%rsp), %rdi
leaq 0x3174(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0x60(%rsp)
jmp 0x3ed9
movq 0x60(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0x58(%rsp)
jmp 0x3ef1
movq 0x58(%rsp), %rdi
leaq 0x3155(%rip), %rsi      # 0x7052
callq 0x3220
movq %rax, 0x50(%rsp)
jmp 0x3f09
movq 0x50(%rsp), %rdi
movq 0x60ab(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3f1c
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x1a0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xe, %ecx
callq 0x4db0
jmp 0x3f42
movq 0x6087(%rip), %rdi      # 0x9fd0
leaq 0x1a0(%rsp), %rsi
callq 0x3200
movq %rax, 0x48(%rsp)
jmp 0x3f5d
movq 0x48(%rsp), %rdi
movq 0x6057(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x3f70
leaq 0x1a0(%rsp), %rdi
callq 0x3170
movl 0x248(%rsp), %eax
addl $0x4, %eax
movl %eax, 0x248(%rsp)
jmp 0x417c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x3170
jmp 0x41db
movl 0x248(%rsp), %esi
addl $0x5, %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0x47(%rsp)
jmp 0x3fd8
movb 0x47(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
je 0x40fa
movl 0x24c(%rsp), %esi
movq 0x5fda(%rip), %rdi      # 0x9fd0
callq 0x3410
movq %rax, 0x38(%rsp)
jmp 0x4002
movq 0x38(%rsp), %rdi
leaq 0x3033(%rip), %rsi      # 0x7041
callq 0x3220
movq %rax, 0x30(%rsp)
jmp 0x401a
movq 0x30(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3410
movq %rax, 0x28(%rsp)
jmp 0x4032
movq 0x28(%rsp), %rdi
leaq 0x3014(%rip), %rsi      # 0x7052
callq 0x3220
movq %rax, 0x20(%rsp)
jmp 0x404a
movq 0x20(%rsp), %rdi
movq 0x5f6a(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x405d
movl 0x248(%rsp), %edx
addl $-0x5, %edx
leaq 0x180(%rsp), %rdi
leaq 0x290(%rsp), %rsi
movl $0xf, %ecx
callq 0x4db0
jmp 0x4083
movq 0x5f46(%rip), %rdi      # 0x9fd0
leaq 0x180(%rsp), %rsi
callq 0x3200
movq %rax, 0x18(%rsp)
jmp 0x409e
movq 0x18(%rsp), %rdi
movq 0x5f16(%rip), %rsi      # 0x9fc0
callq 0x3260
jmp 0x40b1
leaq 0x180(%rsp), %rdi
callq 0x3170
movl 0x248(%rsp), %eax
addl $0x5, %eax
movl %eax, 0x248(%rsp)
jmp 0x417a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x3170
jmp 0x41db
jmp 0x40fc
movl 0x248(%rsp), %eax
movl %eax, 0x10(%rsp)
leaq 0x290(%rsp), %rdi
callq 0x4d40
movl %eax, 0x14(%rsp)
jmp 0x411a
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xf(%rsp)
jae 0x415b
movl 0x248(%rsp), %esi
incl %esi
leaq 0x290(%rsp), %rdi
xorl %edx, %edx
callq 0x5000
movb %al, 0xe(%rsp)
jmp 0x414a
movb 0xe(%rsp), %al
movsbl %al, %eax
cmpl $0x4e, %eax
sete %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x4165
jmp 0x4178
movl 0x248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x248(%rsp)
jmp 0x40fc
jmp 0x417a
jmp 0x417c
jmp 0x417e
jmp 0x4180
jmp 0x4182
jmp 0x4184
jmp 0x4186
movl 0x248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x248(%rsp)
jmp 0x37ff
jmp 0x419e
movl 0x24c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x37a4
movl $0x0, 0x504(%rsp)
leaq 0x290(%rsp), %rdi
callq 0x45c0
movl 0x504(%rsp), %eax
addq $0x508, %rsp            # imm = 0x508
retq
leaq 0x290(%rsp), %rdi
callq 0x45c0
movq 0x288(%rsp), %rdi
callq 0x3430
nopw %cs:(%rax,%rax)
nop