// File: splatlab[P]debgr/main.cc
// Function: main
int main(int argc, char *argv[])
{
	QF cf, last_cf, first_cf, exact_cf;
	QFi cfi;
	QF local_qfs[50];
	int mode = atoi(argv[1]);
	int qbits = atoi(argv[2]);
	int qbits_aux = atoi(argv[3]);
	int numthreads = atoi(argv[4]);
	int num_hash_bits = qbits+8;	  // we use 8 bits for remainders in the main QF
	int num_hash_bits_exact = 2*K;	  // for exact k-mer counting
	int num_hash_bits_aux = 2*(K-1);  // for exact counting.
	string first_ext(".first");
	string last_ext(".last");
	string exact_ext(".exact");
	string ser_ext(".ser");
	string log_ext(".log");
	string cluster_ext(".cluster");
	string freq_ext(".freq");
	struct timeval start1, start2, end1, end2;
	struct timezone tzp;
	uint32_t OVERHEAD_SIZE = 65535;

	for (int i = 5; i < argc; i++) {
		auto* fr = new reader;
		if (getFileReader(mode, argv[i], fr)) {
			file_pointer* fp = new file_pointer;
			fp->mode = mode;
			fp->freader.reset(fr);
			fp->part_buffer = new char[OVERHEAD_SIZE];
			ip_files.push(fp);
			num_files++;
		} else {
			delete fr;
		}
	}

	string ds_file = string(argv[5]) + ser_ext;
	string ds_file_first = string(argv[5]) + first_ext;
	string ds_file_last = string(argv[5]) + last_ext;
	string ds_file_exact = string(argv[5]) + exact_ext;
	string log_file = string(argv[5]) + log_ext;
	string cluster_file = string(argv[5]) + cluster_ext;
	//string freq_file = string(argv[5]) + freq_ext;
	
	uint32_t seed = time(NULL);
	//Initialize the main  QF and aux QFs
	qf_init(&cf, (1ULL<<qbits), num_hash_bits, 0, true, "", seed);
	qf_init(&exact_cf, (1ULL<<qbits), num_hash_bits_exact, 0, true, "", seed);
	qf_init(&first_cf, (1ULL<<qbits_aux), num_hash_bits_aux, 0, true, "", seed);
	qf_init(&last_cf, (1ULL<<qbits_aux), num_hash_bits_aux, 0, true, "", seed);

	boost::thread_group prod_threads;

	for (int i = 0; i < numthreads; i++) {
		qf_init(&local_qfs[i], (1ULL << QBITS_LOCAL_QF), num_hash_bits, 0, true,
						"", seed);
		flush_object* obj = (flush_object*)malloc(sizeof(flush_object));
		obj->local_qf = &local_qfs[i];
		obj->main_qf = &cf;
		obj->first_qf = &first_cf;
		obj->last_qf = &last_cf;
		obj->exact_qf = &exact_cf;
		prod_threads.add_thread(new boost::thread(fastq_to_uint64kmers_prod,
																							obj));
	}

	cout << "Reading from the fastq file and inserting in the QF" << endl;
	gettimeofday(&start1, &tzp);
	prod_threads.join_all();
	qf_serialize(&cf, ds_file.c_str());
	qf_serialize(&exact_cf, ds_file_exact.c_str());
	qf_serialize(&first_cf, ds_file_first.c_str());
	qf_serialize(&last_cf, ds_file_last.c_str());
	gettimeofday(&end1, &tzp);
	print_time_elapsed("", &start1, &end1);

	cout << "Calc freq distribution: " << endl;
	//ofstream freq_file;
	//freq_file.open(freq_file.c_str());
	uint64_t max_cnt = 0;
	qf_iterator(&cf, &cfi, 0);
	gettimeofday(&start2, &tzp);
	do {
		uint64_t key = 0, value = 0, count = 0;
		qfi_get(&cfi, &key, &value, &count);
		//freq_file << key << " " << count << endl;
		if (max_cnt < count)
			max_cnt = count;
	} while (!qfi_next(&cfi));
	gettimeofday(&end2, &tzp);
	print_time_elapsed("", &start2, &end2);

	cout << "Maximum freq: " << max_cnt << endl;
	//freq_file.close();

	cout << "Num distinct elem: " << cf.metadata->ndistinct_elts << endl;
	cout << "Total num elems: " << cf.metadata->nelts << endl;

	//to validate the invertible hashing and exact QF
	qf_iterator(&exact_cf, &cfi, 0);
	do {
		uint64_t key = 0, value = 0, count = 0;
		qfi_get(&cfi, &key, &value, &count);
		//cout << int_to_str_node(HashUtil::hash_64i(key, BITMASK(2*K))) << endl;
	} while (!qfi_next(&cfi));
	cout << "Exact: Num distinct elem: " << exact_cf.metadata->ndistinct_elts << endl;
	cout << "Exact: Total num elems: " << exact_cf.metadata->nelts << endl;

	//to validate the invertible hashing and exact QF
	qf_iterator(&first_cf, &cfi, 0);
	do {
		uint64_t key = 0, value = 0, count = 0;
		qfi_get(&cfi, &key, &value, &count);
		//cout << int_to_str_node(HashUtil::hash_64i(key, BITMASK(2*K))) << endl;
	} while (!qfi_next(&cfi));
	cout << "First: Num distinct elem: " << first_cf.metadata->ndistinct_elts << endl;
	cout << "First: Total num elems: " << first_cf.metadata->nelts << endl;

	//to validate the invertible hashing and exact QF
	qf_iterator(&last_cf, &cfi, 0);
	do {
		uint64_t key = 0, value = 0, count = 0;
		qfi_get(&cfi, &key, &value, &count);
		//cout << int_to_str_node(HashUtil::hash_64i(key, BITMASK(2*K))) << endl;
	} while (!qfi_next(&cfi));
	cout << "Last: Num distinct elem: " << last_cf.metadata->ndistinct_elts << endl;
	cout << "Last: Total num elems: " << last_cf.metadata->nelts << endl;

#ifdef LOG_WAIT_TIME
	ofstream wait_time_log;
	wait_time_log.open(log_file.c_str());
	wait_time_log << "Id\tTotalTimeSingle\tTotalTimeSpinning\tNumLocks\tNumSingleAttempt\tPercentageSpinningTimes"
		<< endl;
	for (uint32_t i=0; i<cf.num_locks; i++)
		wait_time_log << i << "\t" << cf.wait_times[i].total_time_single << "\t\t\t" 
			<< cf.wait_times[i].total_time_spinning << "\t\t\t" 
			<< cf.wait_times[i].locks_taken << "\t\t\t" 
			<< cf.wait_times[i].locks_acquired_single_attempt << "\t\t\t"
			<< ((double)(cf.wait_times[i].locks_taken
									 -cf.wait_times[i].locks_acquired_single_attempt)
					/(double)cf.wait_times[i].locks_taken)*100
			<< endl;
	wait_time_log.close();
#endif

#ifdef LOG_CLUSTER_LENGTH
	ofstream cluster_len_log;
	cluster_len_log.open(cluster_file.c_str());
	cluster_len_log << "StartingIndex\tLength" << endl;
	for (uint32_t i = 0; i < cfi.num_clusters; i++)
		cluster_len_log << cfi.c_info[i].start_index << "\t\t" << 
			cfi.c_info[i].length << endl;
	cluster_len_log.close();

#endif

	//destroy the QF and reclaim the memory
	qf_destroy(&cf, true);
	qf_destroy(&first_cf, true);
	qf_destroy(&last_cf, true);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd20, %rsp            # imm = 0xD20
movl $0x0, -0x90(%rbp)
movl %edi, -0x94(%rbp)
movq %rsi, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x66d0
movl %eax, -0x5e4(%rbp)
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x66d0
movl %eax, -0x5e8(%rbp)
movq -0xa0(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x66d0
movl %eax, -0x5ec(%rbp)
movq -0xa0(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x66d0
movl %eax, -0x5f0(%rbp)
movl -0x5e8(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x5f4(%rbp)
movl $0x38, -0x5f8(%rbp)
movl $0x36, -0x5fc(%rbp)
leaq -0x621(%rbp), %rdi
movq %rdi, -0xb58(%rbp)
callq 0x67b0
movq -0xb58(%rbp), %rdx
leaq 0x13e43(%rip), %rsi     # 0x1c171
leaq -0x620(%rbp), %rdi
callq 0x6600
jmp 0x833c
leaq -0x621(%rbp), %rdi
callq 0x64b0
leaq -0x659(%rbp), %rdi
movq %rdi, -0xb60(%rbp)
callq 0x67b0
movq -0xb60(%rbp), %rdx
leaq 0x13e0f(%rip), %rsi     # 0x1c178
leaq -0x658(%rbp), %rdi
callq 0x6600
jmp 0x8377
leaq -0x659(%rbp), %rdi
callq 0x64b0
leaq -0x681(%rbp), %rdi
movq %rdi, -0xb68(%rbp)
callq 0x67b0
movq -0xb68(%rbp), %rdx
leaq 0x13dda(%rip), %rsi     # 0x1c17e
leaq -0x680(%rbp), %rdi
callq 0x6600
jmp 0x83b2
leaq -0x681(%rbp), %rdi
callq 0x64b0
leaq -0x6a9(%rbp), %rdi
movq %rdi, -0xb70(%rbp)
callq 0x67b0
movq -0xb70(%rbp), %rdx
leaq 0x13da6(%rip), %rsi     # 0x1c185
leaq -0x6a8(%rbp), %rdi
callq 0x6600
jmp 0x83ed
leaq -0x6a9(%rbp), %rdi
callq 0x64b0
leaq -0x6d1(%rbp), %rdi
movq %rdi, -0xb78(%rbp)
callq 0x67b0
movq -0xb78(%rbp), %rdx
leaq 0x13d70(%rip), %rsi     # 0x1c18a
leaq -0x6d0(%rbp), %rdi
callq 0x6600
jmp 0x8428
leaq -0x6d1(%rbp), %rdi
callq 0x64b0
leaq -0x6f9(%rbp), %rdi
movq %rdi, -0xb80(%rbp)
callq 0x67b0
movq -0xb80(%rbp), %rdx
leaq 0x13d3a(%rip), %rsi     # 0x1c18f
leaq -0x6f8(%rbp), %rdi
callq 0x6600
jmp 0x8463
leaq -0x6f9(%rbp), %rdi
callq 0x64b0
leaq -0x721(%rbp), %rdi
movq %rdi, -0xb88(%rbp)
callq 0x67b0
movq -0xb88(%rbp), %rdx
leaq 0x13d08(%rip), %rsi     # 0x1c198
leaq -0x720(%rbp), %rdi
callq 0x6600
jmp 0x849e
leaq -0x721(%rbp), %rdi
callq 0x64b0
movl $0xffff, -0x774(%rbp)   # imm = 0xFFFF
movl $0x5, -0x778(%rbp)
movl -0x778(%rbp), %eax
cmpl -0x94(%rbp), %eax
jge 0x88fb
movl $0x20, %edi
callq 0x6440
movq %rax, -0xb90(%rbp)
jmp 0x84e3
movq -0xb90(%rbp), %rdi
callq 0x6df0
jmp 0x84f1
movq -0xb90(%rbp), %rax
movq %rax, -0x780(%rbp)
movl -0x5e4(%rbp), %edi
movq -0xa0(%rbp), %rax
movslq -0x778(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x780(%rbp), %rdx
callq 0x8130
movb %al, -0xb91(%rbp)
jmp 0x852b
movb -0xb91(%rbp), %al
testb $0x1, %al
jne 0x853a
jmp 0x88c3
movl $0x30, %edi
callq 0x6440
movq %rax, -0xba0(%rbp)
jmp 0x854d
movq -0xba0(%rbp), %rdi
callq 0xaf80
movq -0xba0(%rbp), %rax
movq %rax, -0x788(%rbp)
movl -0x5e4(%rbp), %ecx
movq -0x788(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x788(%rbp), %rdi
movq -0x780(%rbp), %rsi
callq 0xafd0
movl -0x774(%rbp), %eax
movl %eax, %edi
callq 0x6040
movq %rax, -0xba8(%rbp)
jmp 0x85a0
movq -0xba8(%rbp), %rcx
movq -0x788(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0x1feb7(%rip), %rdi     # 0x28470
leaq -0x788(%rbp), %rsi
callq 0xb000
jmp 0x85c7
leaq 0x1ff3a(%rip), %rax     # 0x28508
movq %rax, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x1, -0x7c(%rbp)
movl $0xe, -0x80(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdx
movl -0x7c(%rbp), %ecx
movl -0x80(%rbp), %eax
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xbb0(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0x8635
xorl %eax, %eax
movl %eax, -0xbb4(%rbp)
jmp 0x86ab
cmpl $0x1, -0x4(%rbp)
jne 0x8648
movl $0x1, %eax
movl %eax, -0xbb8(%rbp)
jmp 0x869f
cmpl $0x2, -0x4(%rbp)
jne 0x865b
movl $0x2, %eax
movl %eax, -0xbbc(%rbp)
jmp 0x8693
cmpl $0x4, -0x4(%rbp)
jne 0x866e
movl $0x3, %eax
movl %eax, -0xbc0(%rbp)
jmp 0x8687
movl -0x4(%rbp), %edx
movl $0x5, %eax
movl $0x4, %ecx
cmpl $0x6, %edx
cmovel %ecx, %eax
movl %eax, -0xbc0(%rbp)
movl -0xbc0(%rbp), %eax
movl %eax, -0xbbc(%rbp)
movl -0xbbc(%rbp), %eax
movl %eax, -0xbb8(%rbp)
movl -0xbb8(%rbp), %eax
movl %eax, -0xbb4(%rbp)
movl -0xbb4(%rbp), %eax
movl -0x14(%rbp), %ecx
movl %ecx, -0x1c(%rbp)
decl %eax
movl %eax, %ecx
movq %rcx, -0xbc8(%rbp)
subl $0x4, %eax
ja 0x86de
movq -0xbc8(%rbp), %rax
leaq 0x1398b(%rip), %rcx     # 0x1c060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xbb0(%rbp), %rcx
movl -0x1c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x20(%rbp)
jmp 0x873b
movq -0xbb0(%rbp), %rcx
movl -0x1c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x20(%rbp)
jmp 0x873b
movq -0xbb0(%rbp), %rcx
movl -0x1c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x20(%rbp)
jmp 0x873b
movq -0xbb0(%rbp), %rcx
movl -0x1c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x20(%rbp)
jmp 0x873b
movq -0xbb0(%rbp), %rcx
movl -0x1c(%rbp), %eax
lock
xaddl %eax, (%rcx)
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x68(%rbp)
leaq -0x68(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x54(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax)
leaq -0x54(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x88e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x621(%rbp), %rdi
callq 0x64b0
jmp 0x9928
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x659(%rbp), %rdi
callq 0x64b0
jmp 0x991c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x681(%rbp), %rdi
callq 0x64b0
jmp 0x9910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x6a9(%rbp), %rdi
callq 0x64b0
jmp 0x9904
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x6d1(%rbp), %rdi
callq 0x64b0
jmp 0x98f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x6f9(%rbp), %rdi
callq 0x64b0
jmp 0x98ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x721(%rbp), %rdi
callq 0x64b0
jmp 0x98e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x98d4
movq -0xb90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
callq 0x6400
jmp 0x98d4
movq -0x780(%rbp), %rax
movq %rax, -0xbd0(%rbp)
cmpq $0x0, %rax
je 0x88e3
movq -0xbd0(%rbp), %rdi
callq 0x6400
jmp 0x88e5
jmp 0x88e7
movl -0x778(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x778(%rbp)
jmp 0x84be
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xbe0(%rbp)
leaq -0x7c9(%rbp), %rdi
movq %rdi, -0xbd8(%rbp)
callq 0x67b0
movq -0xbe0(%rbp), %rsi
movq -0xbd8(%rbp), %rdx
leaq -0x7c8(%rbp), %rdi
callq 0x6600
jmp 0x893c
leaq -0x7a8(%rbp), %rdi
leaq -0x7c8(%rbp), %rsi
leaq -0x6a8(%rbp), %rdx
callq 0xb030
jmp 0x8958
leaq -0x7c8(%rbp), %rdi
callq 0x6250
leaq -0x7c9(%rbp), %rdi
callq 0x64b0
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xbf0(%rbp)
leaq -0x811(%rbp), %rdi
movq %rdi, -0xbe8(%rbp)
callq 0x67b0
movq -0xbf0(%rbp), %rsi
movq -0xbe8(%rbp), %rdx
leaq -0x810(%rbp), %rdi
callq 0x6600
jmp 0x89b1
leaq -0x7f0(%rbp), %rdi
leaq -0x810(%rbp), %rsi
leaq -0x620(%rbp), %rdx
callq 0xb030
jmp 0x89cd
leaq -0x810(%rbp), %rdi
callq 0x6250
leaq -0x811(%rbp), %rdi
callq 0x64b0
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc00(%rbp)
leaq -0x859(%rbp), %rdi
movq %rdi, -0xbf8(%rbp)
callq 0x67b0
movq -0xc00(%rbp), %rsi
movq -0xbf8(%rbp), %rdx
leaq -0x858(%rbp), %rdi
callq 0x6600
jmp 0x8a26
leaq -0x838(%rbp), %rdi
leaq -0x858(%rbp), %rsi
leaq -0x658(%rbp), %rdx
callq 0xb030
jmp 0x8a42
leaq -0x858(%rbp), %rdi
callq 0x6250
leaq -0x859(%rbp), %rdi
callq 0x64b0
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc10(%rbp)
leaq -0x8a1(%rbp), %rdi
movq %rdi, -0xc08(%rbp)
callq 0x67b0
movq -0xc10(%rbp), %rsi
movq -0xc08(%rbp), %rdx
leaq -0x8a0(%rbp), %rdi
callq 0x6600
jmp 0x8a9b
leaq -0x880(%rbp), %rdi
leaq -0x8a0(%rbp), %rsi
leaq -0x680(%rbp), %rdx
callq 0xb030
jmp 0x8ab7
leaq -0x8a0(%rbp), %rdi
callq 0x6250
leaq -0x8a1(%rbp), %rdi
callq 0x64b0
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc20(%rbp)
leaq -0x8e9(%rbp), %rdi
movq %rdi, -0xc18(%rbp)
callq 0x67b0
movq -0xc20(%rbp), %rsi
movq -0xc18(%rbp), %rdx
leaq -0x8e8(%rbp), %rdi
callq 0x6600
jmp 0x8b10
leaq -0x8c8(%rbp), %rdi
leaq -0x8e8(%rbp), %rsi
leaq -0x6d0(%rbp), %rdx
callq 0xb030
jmp 0x8b2c
leaq -0x8e8(%rbp), %rdi
callq 0x6250
leaq -0x8e9(%rbp), %rdi
callq 0x64b0
movq -0xa0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xc30(%rbp)
leaq -0x931(%rbp), %rdi
movq %rdi, -0xc28(%rbp)
callq 0x67b0
movq -0xc30(%rbp), %rsi
movq -0xc28(%rbp), %rdx
leaq -0x930(%rbp), %rdi
callq 0x6600
jmp 0x8b85
leaq -0x910(%rbp), %rdi
leaq -0x930(%rbp), %rsi
leaq -0x6f8(%rbp), %rdx
callq 0xb030
jmp 0x8ba1
leaq -0x930(%rbp), %rdi
callq 0x6250
leaq -0x931(%rbp), %rdi
callq 0x64b0
xorl %eax, %eax
movl %eax, %edi
movq %rdi, -0xc38(%rbp)
callq 0x63f0
movl %eax, -0x938(%rbp)
movb -0x5e8(%rbp), %cl
movl $0x1, %esi
shlq %cl, %rsi
movq -0xc38(%rbp), %rcx
movslq -0x5f4(%rbp), %rdx
movl -0x938(%rbp), %edi
movq %rsp, %rax
movl %edi, (%rax)
leaq 0x13f69(%rip), %r9      # 0x1cb66
leaq -0xb8(%rbp), %rdi
movl $0x1, %r8d
callq 0x164c0
jmp 0x8c11
movb -0x5e8(%rbp), %cl
movl $0x1, %esi
shlq %cl, %rsi
movslq -0x5f8(%rbp), %rdx
movl -0x938(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq 0x13f2e(%rip), %r9      # 0x1cb66
xorl %eax, %eax
movl %eax, %ecx
leaq -0x100(%rbp), %rdi
movl $0x1, %r8d
callq 0x164c0
jmp 0x8c50
movb -0x5ec(%rbp), %cl
movl $0x1, %esi
shlq %cl, %rsi
movslq -0x5fc(%rbp), %rdx
movl -0x938(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq 0x13eef(%rip), %r9      # 0x1cb66
xorl %eax, %eax
movl %eax, %ecx
leaq -0xe8(%rbp), %rdi
movl $0x1, %r8d
callq 0x164c0
jmp 0x8c8f
movb -0x5ec(%rbp), %cl
movl $0x1, %esi
shlq %cl, %rsi
movslq -0x5fc(%rbp), %rdx
movl -0x938(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq 0x13eb0(%rip), %r9      # 0x1cb66
xorl %eax, %eax
movl %eax, %ecx
leaq -0xd0(%rbp), %rdi
movl $0x1, %r8d
callq 0x164c0
jmp 0x8cce
leaq -0xa88(%rbp), %rdi
callq 0xb080
jmp 0x8cdc
movl $0x0, -0xa8c(%rbp)
movl -0xa8c(%rbp), %eax
cmpl -0x5f0(%rbp), %eax
jge 0x8ff1
movslq -0xa8c(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x5e0(%rbp,%rax,8), %rdi
movslq -0x5f4(%rbp), %rdx
movl -0x938(%rbp), %ecx
movq %rsp, %rax
movl %ecx, (%rax)
leaq 0x13e42(%rip), %r9      # 0x1cb66
xorl %eax, %eax
movl %eax, %ecx
movl $0x10000, %esi          # imm = 0x10000
movl $0x1, %r8d
callq 0x164c0
jmp 0x8d3a
movl $0x38, %edi
callq 0x65e0
movq %rax, -0xa98(%rbp)
movslq -0xa8c(%rbp), %rax
leaq (%rax,%rax,2), %rax
leaq -0x5e0(%rbp,%rax,8), %rcx
movq -0xa98(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xa98(%rbp), %rax
leaq -0xb8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0xa98(%rbp), %rax
leaq -0xe8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xa98(%rbp), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xa98(%rbp), %rax
leaq -0x100(%rbp), %rcx
movq %rcx, 0x20(%rax)
movl $0x10, %edi
callq 0x6440
movq %rax, -0xc40(%rbp)
jmp 0x8dc3
movq -0xc40(%rbp), %rdi
movq -0xa98(%rbp), %rdx
leaq 0xb68(%rip), %rsi       # 0x9940
xorl %eax, %eax
movl %eax, %ecx
callq 0xb140
jmp 0x8de3
movq -0xc40(%rbp), %rsi
leaq -0xa88(%rbp), %rdi
callq 0xb0d0
jmp 0x8df8
jmp 0x8dfa
movl -0xa8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8c(%rbp)
jmp 0x8ce6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8e40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x7c8(%rbp), %rdi
callq 0x6250
leaq -0x7c9(%rbp), %rdi
callq 0x64b0
jmp 0x98d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8e83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x810(%rbp), %rdi
callq 0x6250
leaq -0x811(%rbp), %rdi
callq 0x64b0
jmp 0x98c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8ec6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x858(%rbp), %rdi
callq 0x6250
leaq -0x859(%rbp), %rdi
callq 0x64b0
jmp 0x98bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8f09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x8a0(%rbp), %rdi
callq 0x6250
leaq -0x8a1(%rbp), %rdi
callq 0x64b0
jmp 0x98b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8f4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x8e8(%rbp), %rdi
callq 0x6250
leaq -0x8e9(%rbp), %rdi
callq 0x64b0
jmp 0x98a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x8f8f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0x930(%rbp), %rdi
callq 0x6250
leaq -0x931(%rbp), %rdi
callq 0x64b0
jmp 0x9898
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x988c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x9880
movq -0xc40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
callq 0x6400
jmp 0x9880
movq 0x1efd0(%rip), %rdi     # 0x27fc8
leaq 0x1319f(%rip), %rsi     # 0x1c19e
callq 0x6420
movq %rax, -0xc48(%rbp)
jmp 0x900d
movq -0xc48(%rbp), %rdi
movq 0x1ef85(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x9022
leaq -0x738(%rbp), %rdi
leaq -0x770(%rbp), %rsi
callq 0x6720
leaq -0xa88(%rbp), %rdi
callq 0xb1c0
jmp 0x9043
leaq -0x7a8(%rbp), %rdi
callq 0x6160
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
callq 0x16d80
jmp 0x9060
leaq -0x880(%rbp), %rdi
callq 0x6160
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
callq 0x16d80
jmp 0x907d
leaq -0x7f0(%rbp), %rdi
callq 0x6160
movq %rax, %rsi
leaq -0xe8(%rbp), %rdi
callq 0x16d80
jmp 0x909a
leaq -0x838(%rbp), %rdi
callq 0x6160
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x16d80
jmp 0x90b7
leaq -0x758(%rbp), %rdi
leaq -0x770(%rbp), %rsi
callq 0x6720
leaq -0xab9(%rbp), %rdi
movq %rdi, -0xc50(%rbp)
callq 0x67b0
movq -0xc50(%rbp), %rdx
leaq 0x13a7b(%rip), %rsi     # 0x1cb66
leaq -0xab8(%rbp), %rdi
callq 0x6600
jmp 0x90f9
leaq -0xab8(%rbp), %rdi
leaq -0x738(%rbp), %rsi
leaq -0x758(%rbp), %rdx
callq 0x6f40
jmp 0x9115
leaq -0xab8(%rbp), %rdi
callq 0x6250
leaq -0xab9(%rbp), %rdi
callq 0x64b0
movq 0x1ee94(%rip), %rdi     # 0x27fc8
leaq 0x13097(%rip), %rsi     # 0x1c1d2
callq 0x6420
movq %rax, -0xc58(%rbp)
jmp 0x9149
movq -0xc58(%rbp), %rdi
movq 0x1ee49(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x915e
movq $0x0, -0xac8(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0xb8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x18fa0
jmp 0x9182
leaq -0x748(%rbp), %rdi
leaq -0x770(%rbp), %rsi
callq 0x6720
movq $0x0, -0xad0(%rbp)
movq $0x0, -0xad8(%rbp)
movq $0x0, -0xae0(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0xad0(%rbp), %rsi
leaq -0xad8(%rbp), %rdx
leaq -0xae0(%rbp), %rcx
callq 0x191a0
jmp 0x91d9
movq -0xac8(%rbp), %rax
cmpq -0xae0(%rbp), %rax
jae 0x923c
movq -0xae0(%rbp), %rax
movq %rax, -0xac8(%rbp)
jmp 0x923c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x922b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0xab8(%rbp), %rdi
callq 0x6250
leaq -0xab9(%rbp), %rdi
callq 0x64b0
jmp 0x9880
jmp 0x923e
leaq -0x130(%rbp), %rdi
callq 0x19250
movl %eax, -0xc5c(%rbp)
jmp 0x9252
movl -0xc5c(%rbp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x9195
leaq -0x768(%rbp), %rdi
leaq -0x770(%rbp), %rsi
callq 0x6720
leaq -0xb01(%rbp), %rdi
movq %rdi, -0xc68(%rbp)
callq 0x67b0
movq -0xc68(%rbp), %rdx
leaq 0x138ca(%rip), %rsi     # 0x1cb66
leaq -0xb00(%rbp), %rdi
callq 0x6600
jmp 0x92aa
leaq -0xb00(%rbp), %rdi
leaq -0x748(%rbp), %rsi
leaq -0x768(%rbp), %rdx
callq 0x6f40
jmp 0x92c6
leaq -0xb00(%rbp), %rdi
callq 0x6250
leaq -0xb01(%rbp), %rdi
callq 0x64b0
movq 0x1ece3(%rip), %rdi     # 0x27fc8
leaq 0x12eff(%rip), %rsi     # 0x1c1eb
callq 0x6420
movq %rax, -0xc70(%rbp)
jmp 0x92fa
movq -0xc70(%rbp), %rdi
movq -0xac8(%rbp), %rsi
callq 0x60d0
movq %rax, -0xc78(%rbp)
jmp 0x9316
movq -0xc78(%rbp), %rdi
movq 0x1ec7c(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x932b
movq 0x1ec96(%rip), %rdi     # 0x27fc8
leaq 0x12ec8(%rip), %rsi     # 0x1c201
callq 0x6420
movq %rax, -0xc80(%rbp)
jmp 0x9347
movq -0xc80(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x60d0
movq %rax, -0xc88(%rbp)
jmp 0x9367
movq -0xc88(%rbp), %rdi
movq 0x1ec2b(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x937c
movq 0x1ec45(%rip), %rdi     # 0x27fc8
leaq 0x12e92(%rip), %rsi     # 0x1c21c
callq 0x6420
movq %rax, -0xc90(%rbp)
jmp 0x9398
movq -0xc90(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x60d0
movq %rax, -0xc98(%rbp)
jmp 0x93b8
movq -0xc98(%rbp), %rdi
movq 0x1ebda(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x93cd
xorl %eax, %eax
movl %eax, %edx
leaq -0x100(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x18fa0
jmp 0x93e6
jmp 0x93e8
movq $0x0, -0xb10(%rbp)
movq $0x0, -0xb18(%rbp)
movq $0x0, -0xb20(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0xb10(%rbp), %rsi
leaq -0xb18(%rbp), %rdx
leaq -0xb20(%rbp), %rcx
callq 0x191a0
jmp 0x942c
jmp 0x942e
leaq -0x130(%rbp), %rdi
callq 0x19250
movl %eax, -0xc9c(%rbp)
jmp 0x9442
movl -0xc9c(%rbp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x93e8
movq 0x1eb6d(%rip), %rdi     # 0x27fc8
leaq 0x12d98(%rip), %rsi     # 0x1c1fa
callq 0x6420
movq %rax, -0xca8(%rbp)
jmp 0x9470
movq -0xca8(%rbp), %rdi
movq -0xf8(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x60d0
movq %rax, -0xcb0(%rbp)
jmp 0x9490
movq -0xcb0(%rbp), %rdi
movq 0x1eb02(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x94a5
movq 0x1eb1c(%rip), %rdi     # 0x27fc8
leaq 0x12d62(%rip), %rsi     # 0x1c215
callq 0x6420
movq %rax, -0xcb8(%rbp)
jmp 0x94c1
movq -0xcb8(%rbp), %rdi
movq -0xf8(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x60d0
movq %rax, -0xcc0(%rbp)
jmp 0x94e1
movq -0xcc0(%rbp), %rdi
movq 0x1eab1(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x94f6
xorl %eax, %eax
movl %eax, %edx
leaq -0xe8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x18fa0
jmp 0x950f
jmp 0x9511
movq $0x0, -0xb28(%rbp)
movq $0x0, -0xb30(%rbp)
movq $0x0, -0xb38(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0xb28(%rbp), %rsi
leaq -0xb30(%rbp), %rdx
leaq -0xb38(%rbp), %rcx
callq 0x191a0
jmp 0x9555
jmp 0x9557
leaq -0x130(%rbp), %rdi
callq 0x19250
movl %eax, -0xcc4(%rbp)
jmp 0x956b
movl -0xcc4(%rbp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x9511
movq 0x1ea44(%rip), %rdi     # 0x27fc8
leaq 0x12ca3(%rip), %rsi     # 0x1c22e
callq 0x6420
movq %rax, -0xcd0(%rbp)
jmp 0x9599
movq -0xcd0(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x60d0
movq %rax, -0xcd8(%rbp)
jmp 0x95b9
movq -0xcd8(%rbp), %rdi
movq 0x1e9d9(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x95ce
movq 0x1e9f3(%rip), %rdi     # 0x27fc8
leaq 0x12c6d(%rip), %rsi     # 0x1c249
callq 0x6420
movq %rax, -0xce0(%rbp)
jmp 0x95ea
movq -0xce0(%rbp), %rdi
movq -0xe0(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x60d0
movq %rax, -0xce8(%rbp)
jmp 0x960a
movq -0xce8(%rbp), %rdi
movq 0x1e988(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x961f
xorl %eax, %eax
movl %eax, %edx
leaq -0xd0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x18fa0
jmp 0x9638
jmp 0x963a
movq $0x0, -0xb40(%rbp)
movq $0x0, -0xb48(%rbp)
movq $0x0, -0xb50(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0xb40(%rbp), %rsi
leaq -0xb48(%rbp), %rdx
leaq -0xb50(%rbp), %rcx
callq 0x191a0
jmp 0x967e
jmp 0x9680
leaq -0x130(%rbp), %rdi
callq 0x19250
movl %eax, -0xcec(%rbp)
jmp 0x9694
movl -0xcec(%rbp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x963a
movq 0x1e91b(%rip), %rdi     # 0x27fc8
leaq 0x12bae(%rip), %rsi     # 0x1c262
callq 0x6420
movq %rax, -0xcf8(%rbp)
jmp 0x96c2
movq -0xcf8(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x60d0
movq %rax, -0xd00(%rbp)
jmp 0x96e2
movq -0xd00(%rbp), %rdi
movq 0x1e8b0(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x96f7
movq 0x1e8ca(%rip), %rdi     # 0x27fc8
leaq 0x12b77(%rip), %rsi     # 0x1c27c
callq 0x6420
movq %rax, -0xd08(%rbp)
jmp 0x9713
movq -0xd08(%rbp), %rdi
movq -0xc8(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x60d0
movq %rax, -0xd10(%rbp)
jmp 0x9733
movq -0xd10(%rbp), %rdi
movq 0x1e85f(%rip), %rsi     # 0x27fa0
callq 0x6490
jmp 0x9748
leaq -0xb8(%rbp), %rdi
movl $0x1, %esi
callq 0x16b10
jmp 0x975b
leaq -0xe8(%rbp), %rdi
movl $0x1, %esi
callq 0x16b10
jmp 0x976e
leaq -0xd0(%rbp), %rdi
movl $0x1, %esi
callq 0x16b10
jmp 0x9781
movl $0x0, -0x90(%rbp)
leaq -0xa88(%rbp), %rdi
callq 0xb280
leaq -0x910(%rbp), %rdi
callq 0x6250
leaq -0x8c8(%rbp), %rdi
callq 0x6250
leaq -0x880(%rbp), %rdi
callq 0x6250
leaq -0x838(%rbp), %rdi
callq 0x6250
leaq -0x7f0(%rbp), %rdi
callq 0x6250
leaq -0x7a8(%rbp), %rdi
callq 0x6250
leaq -0x720(%rbp), %rdi
callq 0x6250
leaq -0x6f8(%rbp), %rdi
callq 0x6250
leaq -0x6d0(%rbp), %rdi
callq 0x6250
leaq -0x6a8(%rbp), %rdi
callq 0x6250
leaq -0x680(%rbp), %rdi
callq 0x6250
leaq -0x658(%rbp), %rdi
callq 0x6250
leaq -0x620(%rbp), %rdi
callq 0x6250
movl -0x90(%rbp), %eax
addq $0xd20, %rsp            # imm = 0xD20
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
jmp 0x9874
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x630(%rbp)
movl %eax, -0x634(%rbp)
leaq -0xb00(%rbp), %rdi
callq 0x6250
leaq -0xb01(%rbp), %rdi
callq 0x64b0
leaq -0xa88(%rbp), %rdi
callq 0xb280
leaq -0x910(%rbp), %rdi
callq 0x6250
leaq -0x8c8(%rbp), %rdi
callq 0x6250
leaq -0x880(%rbp), %rdi
callq 0x6250
leaq -0x838(%rbp), %rdi
callq 0x6250
leaq -0x7f0(%rbp), %rdi
callq 0x6250
leaq -0x7a8(%rbp), %rdi
callq 0x6250
leaq -0x720(%rbp), %rdi
callq 0x6250
leaq -0x6f8(%rbp), %rdi
callq 0x6250
leaq -0x6d0(%rbp), %rdi
callq 0x6250
leaq -0x6a8(%rbp), %rdi
callq 0x6250
leaq -0x680(%rbp), %rdi
callq 0x6250
leaq -0x658(%rbp), %rdi
callq 0x6250
leaq -0x620(%rbp), %rdi
callq 0x6250
movq -0x630(%rbp), %rdi
callq 0x67a0
nopw %cs:(%rax,%rax)