// File: CMU-SAFARI[P]optimal-seed-solver/readGenerator.cc
// Function: main
int main(int argc, char* argv[]) {\
	if (argc != 6) {
		cout << "usage: >readGenerator refFile readFile chromoNum readLen readNum" << endl;
		return 1;
	}
	ofstream readFile(argv[2]);

	RefDB refDB;
	refDB.loadRefFile(argv[1]);
	refDB.loadChromo(atoi(argv[3]) );

	int readLen = atoi(argv[4]);
	int readNum = atoi(argv[5]);

	srand(1);
	string read;
	int location;

	for (int i = 0; i < readNum; i++) {
		do {
			location = rand() % (refDB.getChromoLength() - readLen);
			read = refDB.getRefSeq(location, readLen);
		}
		while (read.find('N') != string::npos);

//		cout << location << " "<< read << endl;
		readFile << location << " "<< read << endl;
	}

	readFile.close();
}

// Assembly:
subq $0x538, %rsp            # imm = 0x538
movl $0x0, 0x534(%rsp)
movl %edi, 0x530(%rsp)
movq %rsi, 0x528(%rsp)
cmpl $0x6, 0x530(%rsp)
je 0x36dd
movq 0x591e(%rip), %rdi      # 0x8fd0
leaq 0x294b(%rip), %rsi      # 0x6004
callq 0x3240
movq %rax, %rdi
movq 0x58f8(%rip), %rsi      # 0x8fc0
callq 0x3280
movl $0x1, 0x534(%rsp)
jmp 0x39b5
movq 0x528(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x328(%rsp), %rdi
movl $0x10, %edx
callq 0x32b0
leaq 0xc0(%rsp), %rdi
callq 0x3d50
jmp 0x370a
movq 0x528(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x8f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x34a0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x90(%rsp), %rdi
callq 0x39f0
jmp 0x3746
leaq 0xc0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x3e00
jmp 0x375d
leaq 0x90(%rsp), %rdi
callq 0x3180
leaq 0x8f(%rsp), %rdi
callq 0x32a0
movq 0x528(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x33e0
movl %eax, %esi
leaq 0xc0(%rsp), %rdi
callq 0x4280
jmp 0x3799
movq 0x528(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x33e0
movl %eax, 0x88(%rsp)
movq 0x528(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x33e0
movl %eax, 0x84(%rsp)
movl $0x1, %edi
callq 0x3230
leaq 0x60(%rsp), %rdi
callq 0x3380
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x84(%rsp), %eax
jge 0x3982
jmp 0x37f8
callq 0x30c0
movl %eax, 0x20(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x4530
movl %eax, 0x24(%rsp)
jmp 0x3814
movl 0x20(%rsp), %eax
movl 0x24(%rsp), %ecx
movl 0x88(%rsp), %edx
subl %edx, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, 0x5c(%rsp)
movl 0x5c(%rsp), %edx
movl 0x88(%rsp), %ecx
leaq 0x38(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x45a0
jmp 0x384c
leaq 0x60(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x3310
leaq 0x38(%rsp), %rdi
callq 0x3180
leaq 0x60(%rsp), %rdi
movl $0x4e, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x3350
cmpq $-0x1, %rax
jne 0x37f8
movl 0x5c(%rsp), %esi
leaq 0x328(%rsp), %rdi
callq 0x3470
movq %rax, 0x18(%rsp)
jmp 0x389a
movq 0x18(%rsp), %rdi
leaq 0x27f3(%rip), %rsi      # 0x6099
callq 0x3240
movq %rax, 0x10(%rsp)
jmp 0x38b2
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3210
movq %rax, 0x8(%rsp)
jmp 0x38c8
movq 0x8(%rsp), %rdi
movq 0x56ec(%rip), %rsi      # 0x8fc0
callq 0x3280
jmp 0x38db
jmp 0x38dd
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x37e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x39d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x393d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x3180
leaq 0x8f(%rsp), %rdi
callq 0x32a0
jmp 0x39c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x39c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x3180
jmp 0x39c4
leaq 0x328(%rsp), %rdi
callq 0x33a0
jmp 0x3991
leaq 0x60(%rsp), %rdi
callq 0x3180
leaq 0xc0(%rsp), %rdi
callq 0x3db0
leaq 0x328(%rsp), %rdi
callq 0x33c0
movl 0x534(%rsp), %eax
addq $0x538, %rsp            # imm = 0x538
retq
leaq 0xc0(%rsp), %rdi
callq 0x3db0
leaq 0x328(%rsp), %rdi
callq 0x33c0
movq 0xb8(%rsp), %rdi
callq 0x3490
nopl (%rax,%rax)