// File: auton1[P]motiflocation/motiflocation.cpp
// Function: main
int main(int argc, char* argv[])
{
	int i;
	unsigned int ui;
	char filename1[255], outfilename[255];
	string startstr = "";
	string chrom_str = "";
	DNA SequenceSet1;
	bool f1 = false, f2 = false;
	int allowed_mutations = 0;
	bool chosen_chr = false;
	bool output_seqlen = false;
	bool uppercase_only = false, lowercase_only = false;
	bool KG_ref = false;

	for(i = 0; i < argc; i++)
	{
		if(*argv[i] == '-')
		{ 
			if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-?") == 0) || (strcmp(argv[i], "-help") == 0)) 
			{
				print_help();
				exit (0);
			}
			if(strcmp(argv[i], "-file1") == 0) { strcpy(filename1 , argv[i+1]); f1 = true; }
			if(strcmp(argv[i], "-out") == 0) { strcpy(outfilename , argv[i+1]); f2 = true; }
			if(strcmp(argv[i], "-startstr") == 0) startstr = argv[i+1];
			if(strcmp(argv[i], "-chrom") == 0) {chrom_str = argv[i+1]; chosen_chr = true; }
			if(strcmp(argv[i], "-mutations") == 0) allowed_mutations = atoi(argv[i+1]);
			if(strcmp(argv[i], "-outputseqlen") == 0) output_seqlen = true;
			if(strcmp(argv[i], "-uppercase_only") == 0) uppercase_only = true;
			if(strcmp(argv[i], "-lowercase_only") == 0) lowercase_only = true;
			if(strcmp(argv[i], "-1000G_ref") == 0) KG_ref = true;
		}
	}

	if (chosen_chr == false)
	{
		chrom_str = "n.a";
	}

	if (!((f1 == true) && (f2 == true)))
	{
		cout << "Missing input parameter" << endl;
		print_help();
		exit(0);
	}

	
	std::transform(startstr.begin(), startstr.end(), startstr.begin(), ToLower());

	motif my_motif = motif(startstr);

	cout << "\nReading in Files" << endl;
	if ((strstr( filename1, ".fa" ) != NULL) || (strstr( filename1, ".fa.gz" ) != NULL))
	{
		cout << "File 1 Fasta file" << endl;
		if (chosen_chr == false)
			SequenceSet1.readFASTA(filename1, uppercase_only, lowercase_only, KG_ref);
		else
			SequenceSet1.readFASTA(filename1, chrom_str, uppercase_only, lowercase_only, KG_ref);
	}
	else
	{
		cout << "Appears to not be a fasta file? Should end in .fa" << endl;
		exit(0);
	}

	cout << "Finished reading files\n" << endl;
	for (unsigned int ui=0; ui<SequenceSet1.sequence.size(); ui++)
		cout << "Read " << SequenceSet1.sequence[ui].size() << " bases in " << SequenceSet1.header[ui] << endl;

	cout << "Searching for motif" << endl;
	vector<string> chroms;
	vector<int> positions;
	vector<int> seqnum;
	vector<string> revchroms;
	vector<int> reverse_positions;
	vector<int> revseqnum;

	for (unsigned int ui=0; ui<SequenceSet1.sequence.size(); ui++)
	{
		vector<int> tmp_positions;
		tmp_positions = my_motif.returnMotifLocations(SequenceSet1.sequence[ui].c_str(), my_motif.sequence.c_str(), allowed_mutations);
		vector<string> tmp_chroms(tmp_positions.size(), SequenceSet1.header[ui]);
		positions.insert( positions.end(), tmp_positions.begin(), tmp_positions.end() );
		chroms.insert(chroms.end(), tmp_chroms.begin(), tmp_chroms.end() );
		vector<int> tmp_seqnum(tmp_positions.size(), ui);
		seqnum.insert( seqnum.end(), tmp_seqnum.begin(), tmp_seqnum.end());
	}

	cout << "Searching for reverse complement" << endl;
	for (unsigned int ui=0; ui<SequenceSet1.sequence.size(); ui++)
	{
		vector<int> tmp_positions;
		tmp_positions = my_motif.returnMotifLocations(SequenceSet1.sequence[ui].c_str(), my_motif.complement.c_str(), allowed_mutations);
		vector<string> tmp_chroms(tmp_positions.size(), SequenceSet1.header[ui]);
		reverse_positions.insert( reverse_positions.end(), tmp_positions.begin(), tmp_positions.end() );
		revchroms.insert(revchroms.end(), tmp_chroms.begin(), tmp_chroms.end() );
		vector<int> tmp_seqnum(tmp_positions.size(), ui);
		revseqnum.insert( revseqnum.end(), tmp_seqnum.begin(), tmp_seqnum.end());
	}


	ofstream out_file;
	out_file.open(outfilename);
	//out_file << "chrom\tchromStart\tchromEnd\tstrand\tsequence" << endl;
	int plus = startstr.length();
	for (ui=0; ui < positions.size(); ui++)
	{
		out_file << chroms[ui] << "\t" << positions[ui] << "\t" << positions[ui] + plus << "\t+\t" << SequenceSet1.sequence[seqnum[ui]].substr(positions[ui], plus);
		if (output_seqlen == true)
			out_file << "\t" << SequenceSet1.sequence[seqnum[ui]].size();
		out_file << endl;
	}

	for (ui=0; ui < reverse_positions.size(); ui++)
	{
		out_file << revchroms[ui] << "\t" << reverse_positions[ui] << "\t" << reverse_positions[ui] + plus << "\t-\t" << SequenceSet1.sequence[revseqnum[ui]].substr(reverse_positions[ui], plus);
		if (output_seqlen == true)
			out_file << "\t" << SequenceSet1.sequence[revseqnum[ui]].size();
		out_file << endl;
	}
	out_file.close();
	
	return 1;
}

// Assembly:
subq $0xab8, %rsp            # imm = 0xAB8
movl $0x0, 0xab4(%rsp)
movl %edi, 0xab0(%rsp)
movq %rsi, 0xaa8(%rsp)
leaq 0x87f(%rsp), %rdi
movq %rdi, 0x248(%rsp)
callq 0x4610
movq 0x248(%rsp), %rdx
leaq 0xc836(%rip), %rsi      # 0x1114b
leaq 0x880(%rsp), %rdi
callq 0x6300
jmp 0x4924
leaq 0x87f(%rsp), %rdi
callq 0x4380
leaq 0x847(%rsp), %rdi
movq %rdi, 0x240(%rsp)
callq 0x4610
movq 0x240(%rsp), %rdx
leaq 0xc7f6(%rip), %rsi      # 0x1114b
leaq 0x848(%rsp), %rdi
callq 0x6300
jmp 0x4964
leaq 0x847(%rsp), %rdi
callq 0x4380
leaq 0x7e8(%rsp), %rdi
callq 0xbc80
jmp 0x4980
movb $0x0, 0x7e7(%rsp)
movb $0x0, 0x7e6(%rsp)
movl $0x0, 0x7e0(%rsp)
movb $0x0, 0x7df(%rsp)
movb $0x0, 0x7de(%rsp)
movb $0x0, 0x7dd(%rsp)
movb $0x0, 0x7dc(%rsp)
movb $0x0, 0x7db(%rsp)
movl $0x0, 0xaa4(%rsp)
movl 0xaa4(%rsp), %eax
cmpl 0xab0(%rsp), %eax
jge 0x4d5b
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x4d43
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc5e7(%rip), %rsi      # 0x11004
callq 0x4460
cmpl $0x0, %eax
je 0x4a75
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc5c5(%rip), %rsi      # 0x11007
callq 0x4460
cmpl $0x0, %eax
je 0x4a75
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc5a3(%rip), %rsi      # 0x1100a
callq 0x4460
cmpl $0x0, %eax
jne 0x4b01
callq 0x6230
jmp 0x4a7c
xorl %edi, %edi
callq 0x43c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x87f(%rsp), %rdi
callq 0x4380
jmp 0x6216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x847(%rsp), %rdi
callq 0x4380
jmp 0x6209
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x61fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x61ef
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc4f4(%rip), %rsi      # 0x11010
callq 0x4460
cmpl $0x0, %eax
jne 0x4b54
leaq 0x9a0(%rsp), %rdi
movq 0xaa8(%rsp), %rax
movl 0xaa4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4310
movb $0x1, 0x7e7(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc4a8(%rip), %rsi      # 0x11017
callq 0x4460
cmpl $0x0, %eax
jne 0x4ba7
leaq 0x8a0(%rsp), %rdi
movq 0xaa8(%rsp), %rax
movl 0xaa4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4310
movb $0x1, 0x7e6(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc45a(%rip), %rsi      # 0x1101c
callq 0x4460
cmpl $0x0, %eax
jne 0x4bf2
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
leaq 0x880(%rsp), %rdi
callq 0x4430
jmp 0x4bf0
jmp 0x4bf2
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc419(%rip), %rsi      # 0x11026
callq 0x4460
cmpl $0x0, %eax
jne 0x4c43
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq 0x8(%rax,%rcx,8), %rsi
leaq 0x848(%rsp), %rdi
callq 0x4430
jmp 0x4c3b
movb $0x1, 0x7df(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc3cf(%rip), %rsi      # 0x1102d
callq 0x4460
cmpl $0x0, %eax
jne 0x4c8d
movq 0xaa8(%rsp), %rax
movl 0xaa4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x4520
movl %eax, 0x7e0(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc390(%rip), %rsi      # 0x11038
callq 0x4460
cmpl $0x0, %eax
jne 0x4cba
movb $0x1, 0x7de(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc371(%rip), %rsi      # 0x11046
callq 0x4460
cmpl $0x0, %eax
jne 0x4ce7
movb $0x1, 0x7dd(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc354(%rip), %rsi      # 0x11056
callq 0x4460
cmpl $0x0, %eax
jne 0x4d14
movb $0x1, 0x7dc(%rsp)
movq 0xaa8(%rsp), %rax
movslq 0xaa4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc337(%rip), %rsi      # 0x11066
callq 0x4460
cmpl $0x0, %eax
jne 0x4d41
movb $0x1, 0x7db(%rsp)
jmp 0x4d43
jmp 0x4d45
movl 0xaa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xaa4(%rsp)
jmp 0x49ce
movb 0x7df(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4d84
leaq 0xc2fe(%rip), %rsi      # 0x11071
leaq 0x848(%rsp), %rdi
callq 0x4430
jmp 0x4d82
jmp 0x4d84
movb 0x7e7(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x4da6
movb 0x7e6(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x4de7
movq 0x1222b(%rip), %rdi     # 0x16fd8
leaq 0xc2c1(%rip), %rsi      # 0x11075
callq 0x4320
movq %rax, 0x238(%rsp)
jmp 0x4dc3
movq 0x238(%rsp), %rdi
movq 0x121f6(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x4dd9
callq 0x6230
jmp 0x4de0
xorl %edi, %edi
callq 0x43c0
leaq 0x880(%rsp), %rdi
movq %rdi, 0x228(%rsp)
callq 0x42c0
movq 0x228(%rsp), %rdi
movq %rax, 0x7d0(%rsp)
callq 0x41f0
movq 0x228(%rsp), %rdi
movq %rax, 0x7c8(%rsp)
callq 0x42c0
movq %rax, 0x7c0(%rsp)
movq 0x7d0(%rsp), %rdi
movq 0x7c8(%rsp), %rsi
movq 0x7c0(%rsp), %rdx
callq 0x63c0
movq %rax, 0x230(%rsp)
jmp 0x4e55
movq 0x230(%rsp), %rax
movq %rax, 0x7b0(%rsp)
leaq 0x710(%rsp), %rdi
leaq 0x880(%rsp), %rsi
callq 0x4150
jmp 0x4e7c
leaq 0x730(%rsp), %rdi
leaq 0x710(%rsp), %rsi
callq 0xad70
jmp 0x4e93
leaq 0x710(%rsp), %rdi
callq 0x4220
movq 0x12131(%rip), %rdi     # 0x16fd8
leaq 0xc1df(%rip), %rsi      # 0x1108d
callq 0x4320
movq %rax, 0x220(%rsp)
jmp 0x4ebd
movq 0x220(%rsp), %rdi
movq 0x120fc(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x4ed3
leaq 0x9a0(%rsp), %rdi
leaq 0xc204(%rip), %rsi      # 0x110e6
callq 0x4080
cmpq $0x0, %rax
jne 0x4f0b
leaq 0x9a0(%rsp), %rdi
leaq 0xc1a3(%rip), %rsi      # 0x1109f
callq 0x4080
cmpq $0x0, %rax
je 0x5015
movq 0x120c6(%rip), %rdi     # 0x16fd8
leaq 0xc18d(%rip), %rsi      # 0x110a6
callq 0x4320
movq %rax, 0x218(%rsp)
jmp 0x4f28
movq 0x218(%rsp), %rdi
movq 0x12091(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x4f3e
movb 0x7df(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4fcd
movzbl 0x7db(%rsp), %r8d
movzbl 0x7dc(%rsp), %ecx
movzbl 0x7dd(%rsp), %edx
andl $0x1, %edx
andl $0x1, %ecx
andl $0x1, %r8d
leaq 0x7e8(%rsp), %rdi
leaq 0x9a0(%rsp), %rsi
callq 0xca00
jmp 0x4f89
jmp 0x5013
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x710(%rsp), %rdi
callq 0x4220
jmp 0x61ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x61e2
movzbl 0x7db(%rsp), %r9d
movzbl 0x7dc(%rsp), %r8d
movzbl 0x7dd(%rsp), %ecx
andl $0x1, %ecx
andl $0x1, %r8d
andl $0x1, %r9d
leaq 0x7e8(%rsp), %rdi
leaq 0x9a0(%rsp), %rsi
leaq 0x848(%rsp), %rdx
callq 0xbfa0
jmp 0x5011
jmp 0x5013
jmp 0x504f
movq 0x11fbc(%rip), %rdi     # 0x16fd8
leaq 0xc095(%rip), %rsi      # 0x110b8
callq 0x4320
movq %rax, 0x210(%rsp)
jmp 0x5032
movq 0x210(%rsp), %rdi
movq 0x11f87(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x5048
xorl %edi, %edi
callq 0x43c0
movq 0x11f82(%rip), %rdi     # 0x16fd8
leaq 0xc08d(%rip), %rsi      # 0x110ea
callq 0x4320
movq %rax, 0x208(%rsp)
jmp 0x506c
movq 0x208(%rsp), %rdi
movq 0x11f4d(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x5082
movl $0x0, 0x70c(%rsp)
movl 0x70c(%rsp), %eax
movq %rax, 0x200(%rsp)
leaq 0x7e8(%rsp), %rdi
addq $0x8, %rdi
callq 0x6440
movq %rax, %rcx
movq 0x200(%rsp), %rax
cmpq %rcx, %rax
jae 0x5192
movq 0x11f10(%rip), %rdi     # 0x16fd8
leaq 0xc033(%rip), %rsi      # 0x11102
callq 0x4320
movq %rax, 0x1f8(%rsp)
jmp 0x50de
leaq 0x7f0(%rsp), %rdi
movl 0x70c(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq %rax, %rdi
callq 0x4240
movq 0x1f8(%rsp), %rdi
movq %rax, %rsi
callq 0x40a0
movq %rax, 0x1f0(%rsp)
jmp 0x5116
movq 0x1f0(%rsp), %rdi
leaq 0xbfe3(%rip), %rsi      # 0x11108
callq 0x4320
movq %rax, 0x1e8(%rsp)
jmp 0x5134
leaq 0x808(%rsp), %rdi
movl 0x70c(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq 0x1e8(%rsp), %rdi
movq %rax, %rsi
callq 0x42f0
movq %rax, 0x1e0(%rsp)
jmp 0x5164
movq 0x1e0(%rsp), %rdi
movq 0x11e55(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x517a
jmp 0x517c
movl 0x70c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70c(%rsp)
jmp 0x508d
movq 0x11e3f(%rip), %rdi     # 0x16fd8
leaq 0xbf73(%rip), %rsi      # 0x11113
callq 0x4320
movq %rax, 0x1d8(%rsp)
jmp 0x51af
movq 0x1d8(%rsp), %rdi
movq 0x11e0a(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x51c5
leaq 0x6f0(%rsp), %rdi
callq 0x6480
leaq 0x6d8(%rsp), %rdi
callq 0x6490
leaq 0x6c0(%rsp), %rdi
callq 0x6490
leaq 0x6a8(%rsp), %rdi
callq 0x6480
leaq 0x690(%rsp), %rdi
callq 0x6490
leaq 0x678(%rsp), %rdi
callq 0x6490
movl $0x0, 0x674(%rsp)
movl 0x674(%rsp), %eax
movq %rax, 0x1d0(%rsp)
leaq 0x7e8(%rsp), %rdi
addq $0x8, %rdi
callq 0x6440
movq %rax, %rcx
movq 0x1d0(%rsp), %rax
cmpq %rcx, %rax
jae 0x56b1
leaq 0x658(%rsp), %rdi
callq 0x6490
leaq 0x7f0(%rsp), %rdi
movl 0x674(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq %rax, %rdi
callq 0x4140
movq %rax, 0x1c8(%rsp)
leaq 0x738(%rsp), %rdi
callq 0x4140
movq 0x1c8(%rsp), %rdx
movq %rax, %rcx
movl 0x7e0(%rsp), %r8d
leaq 0x640(%rsp), %rdi
leaq 0x730(%rsp), %rsi
callq 0xb280
jmp 0x52bc
leaq 0x658(%rsp), %rdi
movq %rdi, 0x1a8(%rsp)
leaq 0x640(%rsp), %rsi
movq %rsi, 0x1a0(%rsp)
callq 0x64a0
movq 0x1a0(%rsp), %rdi
callq 0x64e0
movq 0x1a8(%rsp), %rdi
callq 0x6540
movq %rax, 0x1b0(%rsp)
leaq 0x808(%rsp), %rdi
movl 0x674(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq %rax, 0x1b8(%rsp)
leaq 0x627(%rsp), %rdi
movq %rdi, 0x1c0(%rsp)
callq 0x6560
movq 0x1b0(%rsp), %rsi
movq 0x1b8(%rsp), %rdx
movq 0x1c0(%rsp), %rcx
leaq 0x628(%rsp), %rdi
callq 0x6570
jmp 0x535d
leaq 0x627(%rsp), %rdi
callq 0x65f0
leaq 0x6d8(%rsp), %rdi
movq %rdi, 0x190(%rsp)
callq 0x66c0
movq %rax, 0x610(%rsp)
leaq 0x618(%rsp), %rdi
leaq 0x610(%rsp), %rsi
callq 0x66f0
leaq 0x658(%rsp), %rdi
movq %rdi, 0x188(%rsp)
callq 0x6730
movq 0x188(%rsp), %rdi
movq %rax, 0x608(%rsp)
callq 0x66c0
movq 0x190(%rsp), %rdi
movq %rax, 0x600(%rsp)
movq 0x618(%rsp), %rsi
movq 0x608(%rsp), %rdx
movq 0x600(%rsp), %rcx
callq 0x6600
movq %rax, 0x198(%rsp)
jmp 0x53fd
movq 0x198(%rsp), %rax
movq %rax, 0x5f8(%rsp)
leaq 0x6f0(%rsp), %rdi
movq %rdi, 0x178(%rsp)
callq 0x6820
movq %rax, 0x5e8(%rsp)
leaq 0x5f0(%rsp), %rdi
leaq 0x5e8(%rsp), %rsi
callq 0x6850
leaq 0x628(%rsp), %rdi
movq %rdi, 0x170(%rsp)
callq 0x6890
movq 0x170(%rsp), %rdi
movq %rax, 0x5e0(%rsp)
callq 0x6820
movq 0x178(%rsp), %rdi
movq %rax, 0x5d8(%rsp)
movq 0x5f0(%rsp), %rsi
movq 0x5e0(%rsp), %rdx
movq 0x5d8(%rsp), %rcx
callq 0x6760
movq %rax, 0x180(%rsp)
jmp 0x54a0
movq 0x180(%rsp), %rax
movq %rax, 0x5d0(%rsp)
leaq 0x658(%rsp), %rdi
callq 0x6540
movq %rax, 0x160(%rsp)
movl 0x674(%rsp), %eax
movl %eax, 0x5b4(%rsp)
leaq 0x5b3(%rsp), %rdi
movq %rdi, 0x168(%rsp)
callq 0x68c0
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rcx
leaq 0x5b8(%rsp), %rdi
leaq 0x5b4(%rsp), %rdx
callq 0x68d0
jmp 0x550f
leaq 0x5b3(%rsp), %rdi
callq 0x6950
leaq 0x6c0(%rsp), %rdi
movq %rdi, 0x150(%rsp)
callq 0x66c0
movq %rax, 0x5a0(%rsp)
leaq 0x5a8(%rsp), %rdi
leaq 0x5a0(%rsp), %rsi
callq 0x66f0
leaq 0x5b8(%rsp), %rdi
movq %rdi, 0x148(%rsp)
callq 0x6730
movq 0x148(%rsp), %rdi
movq %rax, 0x598(%rsp)
callq 0x66c0
movq 0x150(%rsp), %rdi
movq %rax, 0x590(%rsp)
movq 0x5a8(%rsp), %rsi
movq 0x598(%rsp), %rdx
movq 0x590(%rsp), %rcx
callq 0x6600
movq %rax, 0x158(%rsp)
jmp 0x55af
movq 0x158(%rsp), %rax
movq %rax, 0x588(%rsp)
leaq 0x5b8(%rsp), %rdi
callq 0x64e0
leaq 0x628(%rsp), %rdi
callq 0x6960
leaq 0x658(%rsp), %rdi
callq 0x64e0
movl 0x674(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x674(%rsp)
jmp 0x521e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x569f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x627(%rsp), %rdi
callq 0x65f0
jmp 0x569f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x5692
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x5b3(%rsp), %rdi
callq 0x6950
jmp 0x5692
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x5b8(%rsp), %rdi
callq 0x64e0
leaq 0x628(%rsp), %rdi
callq 0x6960
leaq 0x658(%rsp), %rdi
callq 0x64e0
jmp 0x6194
movq 0x11920(%rip), %rdi     # 0x16fd8
leaq 0xba68(%rip), %rsi      # 0x11127
callq 0x4320
movq %rax, 0x140(%rsp)
jmp 0x56ce
movq 0x140(%rsp), %rdi
movq 0x118eb(%rip), %rsi     # 0x16fc8
callq 0x4360
jmp 0x56e4
movl $0x0, 0x584(%rsp)
movl 0x584(%rsp), %eax
movq %rax, 0x138(%rsp)
leaq 0x7e8(%rsp), %rdi
addq $0x8, %rdi
callq 0x6440
movq %rax, %rcx
movq 0x138(%rsp), %rax
cmpq %rcx, %rax
jae 0x5b9b
leaq 0x568(%rsp), %rdi
callq 0x6490
leaq 0x7f0(%rsp), %rdi
movl 0x584(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq %rax, %rdi
callq 0x4140
movq %rax, 0x130(%rsp)
leaq 0x758(%rsp), %rdi
callq 0x4140
movq 0x130(%rsp), %rdx
movq %rax, %rcx
movl 0x7e0(%rsp), %r8d
leaq 0x550(%rsp), %rdi
leaq 0x730(%rsp), %rsi
callq 0xb280
jmp 0x578d
leaq 0x568(%rsp), %rdi
movq %rdi, 0x110(%rsp)
leaq 0x550(%rsp), %rsi
movq %rsi, 0x108(%rsp)
callq 0x64a0
movq 0x108(%rsp), %rdi
callq 0x64e0
movq 0x110(%rsp), %rdi
callq 0x6540
movq %rax, 0x118(%rsp)
leaq 0x808(%rsp), %rdi
movl 0x584(%rsp), %eax
movl %eax, %esi
callq 0x6460
movq %rax, 0x120(%rsp)
leaq 0x537(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x6560
movq 0x118(%rsp), %rsi
movq 0x120(%rsp), %rdx
movq 0x128(%rsp), %rcx
leaq 0x538(%rsp), %rdi
callq 0x6570
jmp 0x582e
leaq 0x537(%rsp), %rdi
callq 0x65f0
leaq 0x690(%rsp), %rdi
movq %rdi, 0xf8(%rsp)
callq 0x66c0
movq %rax, 0x520(%rsp)
leaq 0x528(%rsp), %rdi
leaq 0x520(%rsp), %rsi
callq 0x66f0
leaq 0x568(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x6730
movq 0xf0(%rsp), %rdi
movq %rax, 0x518(%rsp)
callq 0x66c0
movq 0xf8(%rsp), %rdi
movq %rax, 0x510(%rsp)
movq 0x528(%rsp), %rsi
movq 0x518(%rsp), %rdx
movq 0x510(%rsp), %rcx
callq 0x6600
movq %rax, 0x100(%rsp)
jmp 0x58ce
movq 0x100(%rsp), %rax
movq %rax, 0x508(%rsp)
leaq 0x6a8(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x6820
movq %rax, 0x4f8(%rsp)
leaq 0x500(%rsp), %rdi
leaq 0x4f8(%rsp), %rsi
callq 0x6850
leaq 0x538(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x6890
movq 0xd8(%rsp), %rdi
movq %rax, 0x4f0(%rsp)
callq 0x6820
movq 0xe0(%rsp), %rdi
movq %rax, 0x4e8(%rsp)
movq 0x500(%rsp), %rsi
movq 0x4f0(%rsp), %rdx
movq 0x4e8(%rsp), %rcx
callq 0x6760
movq %rax, 0xe8(%rsp)
jmp 0x5971
movq 0xe8(%rsp), %rax
movq %rax, 0x4e0(%rsp)
leaq 0x568(%rsp), %rdi
callq 0x6540
movq %rax, 0xc8(%rsp)
movl 0x584(%rsp), %eax
movl %eax, 0x4c4(%rsp)
leaq 0x4c3(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x68c0
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rcx
leaq 0x4c8(%rsp), %rdi
leaq 0x4c4(%rsp), %rdx
callq 0x68d0
jmp 0x59e0
leaq 0x4c3(%rsp), %rdi
callq 0x6950
leaq 0x678(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x66c0
movq %rax, 0x4b0(%rsp)
leaq 0x4b8(%rsp), %rdi
leaq 0x4b0(%rsp), %rsi
callq 0x66f0
leaq 0x4c8(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x6730
movq 0xb0(%rsp), %rdi
movq %rax, 0x4a8(%rsp)
callq 0x66c0
movq 0xb8(%rsp), %rdi
movq %rax, 0x4a0(%rsp)
movq 0x4b8(%rsp), %rsi
movq 0x4a8(%rsp), %rdx
movq 0x4a0(%rsp), %rcx
callq 0x6600
movq %rax, 0xc0(%rsp)
jmp 0x5a80
movq 0xc0(%rsp), %rax
movq %rax, 0x498(%rsp)
leaq 0x4c8(%rsp), %rdi
callq 0x64e0
leaq 0x538(%rsp), %rdi
callq 0x6960
leaq 0x568(%rsp), %rdi
callq 0x64e0
movl 0x584(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x584(%rsp)
jmp 0x56ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x6194
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x5b89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x537(%rsp), %rdi
callq 0x65f0
jmp 0x5b89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x5b7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x4c3(%rsp), %rdi
callq 0x6950
jmp 0x5b7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x4c8(%rsp), %rdi
callq 0x64e0
leaq 0x538(%rsp), %rdi
callq 0x6960
leaq 0x568(%rsp), %rdi
callq 0x64e0
jmp 0x6194
leaq 0x298(%rsp), %rdi
callq 0x45c0
jmp 0x5baa
leaq 0x298(%rsp), %rdi
leaq 0x8a0(%rsp), %rsi
movl $0x10, %edx
callq 0x4060
jmp 0x5bc6
leaq 0x880(%rsp), %rdi
callq 0x4500
movl %eax, 0x294(%rsp)
movl $0x0, 0xaa0(%rsp)
movl 0xaa0(%rsp), %eax
movq %rax, 0xa8(%rsp)
leaq 0x6d8(%rsp), %rdi
callq 0x6540
movq %rax, %rcx
movq 0xa8(%rsp), %rax
cmpq %rcx, %rax
jae 0x5e74
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6f0(%rsp), %rdi
callq 0x6460
movq %rax, %rsi
leaq 0x298(%rsp), %rdi
callq 0x42f0
movq %rax, 0xa0(%rsp)
jmp 0x5c45
movq 0xa0(%rsp), %rdi
leaq 0xb4f6(%rip), %rsi      # 0x1114a
callq 0x4320
movq %rax, 0x98(%rsp)
jmp 0x5c63
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6d8(%rsp), %rdi
callq 0x69c0
movq 0x98(%rsp), %rdi
movl (%rax), %esi
callq 0x45d0
movq %rax, 0x90(%rsp)
jmp 0x5c92
movq 0x90(%rsp), %rdi
leaq 0xb4a9(%rip), %rsi      # 0x1114a
callq 0x4320
movq %rax, 0x88(%rsp)
jmp 0x5cb0
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6d8(%rsp), %rdi
callq 0x69c0
movq 0x88(%rsp), %rdi
movl (%rax), %esi
movl 0x294(%rsp), %eax
addl %eax, %esi
callq 0x45d0
movq %rax, 0x80(%rsp)
jmp 0x5ce8
movq 0x80(%rsp), %rdi
leaq 0xb451(%rip), %rsi      # 0x11148
callq 0x4320
movq %rax, 0x78(%rsp)
jmp 0x5d03
leaq 0x7f0(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6c0(%rsp), %rdi
callq 0x69c0
movq 0x68(%rsp), %rdi
movslq (%rax), %rsi
callq 0x6460
movq %rax, 0x70(%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6d8(%rsp), %rdi
callq 0x69c0
movq 0x70(%rsp), %rsi
movslq (%rax), %rdx
movslq 0x294(%rsp), %rcx
leaq 0x270(%rsp), %rdi
callq 0x4350
jmp 0x5d6d
movq 0x78(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x42f0
jmp 0x5d81
leaq 0x270(%rsp), %rdi
callq 0x4220
movb 0x7de(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5e46
leaq 0xb3a0(%rip), %rsi      # 0x1114a
leaq 0x298(%rsp), %rdi
callq 0x4320
movq %rax, 0x60(%rsp)
jmp 0x5dbe
leaq 0x7f0(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6c0(%rsp), %rdi
callq 0x69c0
movq 0x58(%rsp), %rdi
movslq (%rax), %rsi
callq 0x6460
movq %rax, %rdi
callq 0x4240
movq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x40a0
jmp 0x5e05
jmp 0x5e46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
jmp 0x6187
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x270(%rsp), %rdi
callq 0x4220
jmp 0x6187
movq 0x1117b(%rip), %rsi     # 0x16fc8
leaq 0x298(%rsp), %rdi
callq 0x4360
jmp 0x5e5c
jmp 0x5e5e
movl 0xaa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xaa0(%rsp)
jmp 0x5be5
movl $0x0, 0xaa0(%rsp)
movl 0xaa0(%rsp), %eax
movq %rax, 0x50(%rsp)
leaq 0x690(%rsp), %rdi
callq 0x6540
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0x60cf
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x6a8(%rsp), %rdi
callq 0x6460
movq %rax, %rsi
leaq 0x298(%rsp), %rdi
callq 0x42f0
movq %rax, 0x48(%rsp)
jmp 0x5ed6
movq 0x48(%rsp), %rdi
leaq 0xb268(%rip), %rsi      # 0x1114a
callq 0x4320
movq %rax, 0x40(%rsp)
jmp 0x5eee
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x690(%rsp), %rdi
callq 0x69c0
movq 0x40(%rsp), %rdi
movl (%rax), %esi
callq 0x45d0
movq %rax, 0x38(%rsp)
jmp 0x5f17
movq 0x38(%rsp), %rdi
leaq 0xb227(%rip), %rsi      # 0x1114a
callq 0x4320
movq %rax, 0x30(%rsp)
jmp 0x5f2f
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x690(%rsp), %rdi
callq 0x69c0
movq 0x30(%rsp), %rdi
movl (%rax), %esi
movl 0x294(%rsp), %eax
addl %eax, %esi
callq 0x45d0
movq %rax, 0x28(%rsp)
jmp 0x5f61
movq 0x28(%rsp), %rdi
leaq 0xb1df(%rip), %rsi      # 0x1114c
callq 0x4320
movq %rax, 0x20(%rsp)
jmp 0x5f79
leaq 0x7f0(%rsp), %rax
movq %rax, 0x10(%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x678(%rsp), %rdi
callq 0x69c0
movq 0x10(%rsp), %rdi
movslq (%rax), %rsi
callq 0x6460
movq %rax, 0x18(%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x690(%rsp), %rdi
callq 0x69c0
movq 0x18(%rsp), %rsi
movslq (%rax), %rdx
movslq 0x294(%rsp), %rcx
leaq 0x250(%rsp), %rdi
callq 0x4350
jmp 0x5fe3
movq 0x20(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x42f0
jmp 0x5ff7
leaq 0x250(%rsp), %rdi
callq 0x4220
movb 0x7de(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x60a1
leaq 0xb12a(%rip), %rsi      # 0x1114a
leaq 0x298(%rsp), %rdi
callq 0x4320
movq %rax, 0x8(%rsp)
jmp 0x6034
leaq 0x7f0(%rsp), %rax
movq %rax, (%rsp)
movl 0xaa0(%rsp), %eax
movl %eax, %esi
leaq 0x678(%rsp), %rdi
callq 0x69c0
movq (%rsp), %rdi
movslq (%rax), %rsi
callq 0x6460
movq %rax, %rdi
callq 0x4240
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x40a0
jmp 0x6079
jmp 0x60a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x870(%rsp)
movl %eax, 0x86c(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x4220
jmp 0x6187
movq 0x10f20(%rip), %rsi     # 0x16fc8
leaq 0x298(%rsp), %rdi
callq 0x4360
jmp 0x60b7
jmp 0x60b9
movl 0xaa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xaa0(%rsp)
jmp 0x5e7f
leaq 0x298(%rsp), %rdi
callq 0x4470
jmp 0x60de
movl $0x1, 0xab4(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x44f0
leaq 0x678(%rsp), %rdi
callq 0x64e0
leaq 0x690(%rsp), %rdi
callq 0x64e0
leaq 0x6a8(%rsp), %rdi
callq 0x6960
leaq 0x6c0(%rsp), %rdi
callq 0x64e0
leaq 0x6d8(%rsp), %rdi
callq 0x64e0
leaq 0x6f0(%rsp), %rdi
callq 0x6960
leaq 0x730(%rsp), %rdi
callq 0xae30
leaq 0x7e8(%rsp), %rdi
callq 0xbf20
leaq 0x848(%rsp), %rdi
callq 0x4220
leaq 0x880(%rsp), %rdi
callq 0x4220
movl 0xab4(%rsp), %eax
addq $0xab8, %rsp            # imm = 0xAB8
retq
leaq 0x298(%rsp), %rdi
callq 0x44f0
leaq 0x678(%rsp), %rdi
callq 0x64e0
leaq 0x690(%rsp), %rdi
callq 0x64e0
leaq 0x6a8(%rsp), %rdi
callq 0x6960
leaq 0x6c0(%rsp), %rdi
callq 0x64e0
leaq 0x6d8(%rsp), %rdi
callq 0x64e0
leaq 0x6f0(%rsp), %rdi
callq 0x6960
leaq 0x730(%rsp), %rdi
callq 0xae30
leaq 0x7e8(%rsp), %rdi
callq 0xbf20
leaq 0x848(%rsp), %rdi
callq 0x4220
leaq 0x880(%rsp), %rdi
callq 0x4220
movq 0x870(%rsp), %rdi
callq 0x4600
nopw %cs:(%rax,%rax)