// File: /workspace/github_cpp_makefile_star2_O3/CK7[P]abawaca/src/abawaca.cpp
// Function: Prog_params::read_params(int, char const**)
int Prog_params::read_params(int argc, const char** argv)
{
	if((argc == 1) || ((argc == 2) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))) {
		usage(argv[0]);
		return -1;
	}

	// Read parameters
	for(auto i=1; i<argc; i++) {
		if(!strcmp(argv[i], "-u")) {
			abawaca_build_dir = argv[++i];
			char data_file[2048];
			sprintf(data_file, "%s/data.txt", abawaca_build_dir.c_str());
			FILE* fp = fopen(data_file, "r");
			if(fp == NULL) {
				cerr << "Error: could not find " << abawaca_build_dir << "/data.txt. Is it possible that the data was generated using an old version of abawaca-build? (prior to v1.07)" << endl << endl; 
				return -1;
			}
			char line[8192];
			while(fgets(line, 8192, fp)) {
				char* p = strrchr(line, '\n');
				while((p != NULL) && (*p == '\n'))  {
					*(p--) = 0;
				}
				p=strchr(line, '\t');
				*(p++) = 0;
				while(isspace(*p) && (*p != 0))
					p++;

				if(!strcmp(line, "Links")) {
					links_file = p;
				}
				else if(!strcmp(line, "Info")) {
					info_file = p;
				}
				else if(!strcmp(line, "Names")) {
					names_file = p;
				}
				else if(!strcmp(line, "Lrn")) {
					lrn_file = p;
				}
				else if(!strcmp(line, "Assembly")) {
					fasta_file = p;
				}
				else if(!strcmp(line, "SCG")) {
					gene2scg_file = p;
				}
			}
/*			lrn_file = abawaca_build_dir + "/abawaca.lrn";
			names_file = abawaca_build_dir + "/abawaca.names";
			info_file = abawaca_build_dir + "/abawaca.info";
			links_file = abawaca_build_dir + "/abawaca.links";*/
		}
		else if(!strcmp(argv[i], "-f"))
			fasta_file = argv[++i];
		else if(!strcmp(argv[i], "-o"))
			root_dir = argv[++i];
		else if(!strcmp(argv[i], "-p")) {
			ncpus = atoi(argv[++i]);
			if(ncpus==0 || ncpus>40) {
				cerr << "Error: # CPUs (" << argv[i] << ") must be an integer between 1 to 40" << endl << endl;
				return -1; 
			}
		}
		else if(!strcmp(argv[i], "-c"))
			gene2scg_file = argv[++i];
		else {
			cerr << "Unrecognizes flag: " << argv[i] << endl;
			return -1;
		}
	}

	// Make sure we have everything we need
	if(lrn_file == "") {
		cerr << "abawaca-build directrory was not specified (-u)" << endl << endl;
		return -1;
	}

	FILE* IN = fopen(names_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read names file (" << names_file << ") from the abawaca directory (" << abawaca_build_dir << ")" << endl;
		return -1;
	}
	fclose(IN);

	IN = fopen(lrn_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read lrn file (" << lrn_file << ") from the abawaca directory (" << abawaca_build_dir << ")" << endl;
		return -1;
	}
	fclose(IN);

	IN = fopen(info_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read info file (" << info_file << ") from the abawaca directory (" << abawaca_build_dir << ")" << endl;
		return -1;
	}
	fclose(IN);

	IN = fopen(links_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read links file (" << links_file << ") from the abawaca directory (" << abawaca_build_dir << ")" << endl;
		return -1;
	}
	fclose(IN);

	IN = fopen(fasta_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read " << fasta_file << endl;
		return -1;
	}
	fclose(IN);

	if(gene2scg_file.size() > 0) {
		IN = fopen(gene2scg_file.c_str(), "r");
		if(IN == NULL) {
			cerr << "Could not read " << gene2scg_file << endl;
			return -1;
		}
		fclose(IN);
	}

//	const char* p = strrchr(argv[0], '/');
//	if(p != NULL) {
//		string s = argv[0];
//		scg_list_file = s.substr(0, p-argv[0]+1) + scg_list_file;
//	}
	IN = fopen(scg_list_file.c_str(), "r");
	if(IN == NULL) {
		cerr << "Could not read " << scg_list_file << endl;
		return -1;
	}
	fclose(IN);

	cluster_dir = root_dir + string("/clusters");
	fasta_dir = root_dir + string("/final-clusters");

	char 			line[1024] = {};

	if(!directory_exists(root_dir.c_str())) {
		sprintf(line, "mkdir %s", root_dir.c_str());
		system(line);
	}
	if(!directory_exists(cluster_dir.c_str())) {
		sprintf(line, "mkdir %s", cluster_dir.c_str());
		system(line);
	}
	if(!directory_exists(fasta_dir.c_str())) {
		sprintf(line, "mkdir %s", fasta_dir.c_str());
		system(line);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2888, %rsp           # imm = 0x2888
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r12
cmpl $0x2, %esi
je 0x85d1
cmpl $0x1, %ebx
je 0x8af9
jg 0x85fe
leaq 0x11f2d(%rip), %rsi     # 0x1a25a
movq %r12, %rdi
callq 0x50f0
testl %eax, %eax
je 0x89b9
movq 0x20(%r12), %rdi
leaq 0x10de8(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8a22
movq %rax, %rdi
callq 0x5390
movq (%r12), %rdi
leaq 0x10dc7(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8a49
movq %rax, %rdi
callq 0x5390
movq 0x40(%r12), %rdi
leaq 0x10da5(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8b03
movq %rax, %rdi
callq 0x5390
movq 0x60(%r12), %rdi
leaq 0x10d83(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8b76
movq %rax, %rdi
callq 0x5390
movq 0x80(%r12), %rdi
leaq 0x10d5e(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8c34
movq %rax, %rdi
callq 0x5390
cmpq $0x0, 0xc8(%r12)
je 0x8419
movq 0xc0(%r12), %rdi
leaq 0x10d2e(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8cb9
movq %rax, %rdi
callq 0x5390
movq 0xe0(%r12), %rdi
leaq 0x10d09(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8c8c
movq %rax, %rdi
callq 0x5390
leaq -0x8a0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x10fd1(%rip), %rsi     # 0x19421
leaq 0x10fd3(%rip), %rdx     # 0x1942a
leaq -0x8b0(%rbp), %rdi
callq 0xb226
movq %r12, %rbx
leaq 0xa0(%r12), %r15
leaq -0x28b0(%rbp), %rdi
leaq -0x8b0(%rbp), %rdx
movq %r15, %rsi
callq 0x977d
leaq 0x120(%rbx), %r14
leaq -0x28b0(%rbp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5490
movq (%rbx), %rdi
leaq -0x28a0(%rbp), %r13
cmpq %r13, %rdi
je 0x84b1
callq 0x5340
movq -0x8b0(%rbp), %rdi
leaq -0x8a0(%rbp), %rax
cmpq %rax, %rdi
je 0x84c9
callq 0x5340
leaq -0x8b0(%rbp), %rdi
leaq -0x8a0(%rbp), %rax
movq %rax, (%rdi)
leaq 0x10f4a(%rip), %rsi     # 0x1942b
leaq 0x10f52(%rip), %rdx     # 0x1943a
callq 0xb226
leaq -0x28b0(%rbp), %rdi
leaq -0x8b0(%rbp), %rdx
movq %r15, %rsi
callq 0x977d
movq %r12, %rdi
addq $0x140, %rdi            # imm = 0x140
movq %rdi, %r12
movq %rbx, %rsi
callq 0x5490
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x8525
callq 0x5340
movq -0x8b0(%rbp), %rdi
leaq -0x8a0(%rbp), %rax
cmpq %rax, %rdi
je 0x853d
callq 0x5340
leaq -0x28b0(%rbp), %rdi
movl $0x400, %edx            # imm = 0x400
xorl %esi, %esi
callq 0x51f0
movq (%r15), %rdi
callq 0x1772e
testl %eax, %eax
jne 0x8578
movq (%r15), %rdx
leaq 0x10ed5(%rip), %rsi     # 0x1943b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5090
movq %rbx, %rdi
callq 0x52e0
movq (%r14), %rdi
callq 0x1772e
testl %eax, %eax
jne 0x85a0
movq (%r14), %rdx
leaq 0x10ead(%rip), %rsi     # 0x1943b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5090
movq %rbx, %rdi
callq 0x52e0
movq (%r12), %rdi
callq 0x1772e
testl %eax, %eax
jne 0x85ca
movq (%r12), %rdx
leaq 0x10e83(%rip), %rsi     # 0x1943b
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5090
movq %rbx, %rdi
callq 0x52e0
xorl %eax, %eax
jmp 0x8ae7
movq 0x8(%r15), %rdi
cmpb $0x2d, (%rdi)
jne 0x85ea
cmpb $0x68, 0x1(%rdi)
jne 0x85ea
cmpb $0x0, 0x2(%rdi)
je 0x8af9
leaq 0x10c69(%rip), %rsi     # 0x1925a
callq 0x5510
testl %eax, %eax
je 0x8af9
leaq 0xc0(%r12), %rax
movq %rax, -0x58(%rbp)
leaq 0xc8(%r12), %rax
movq %rax, -0x50(%rbp)
leaq 0xa0(%r12), %rax
movq %rax, -0x60(%rbp)
leaq 0x80(%r12), %rax
movq %rax, -0x48(%rbp)
leaq 0x88(%r12), %rax
movq %rax, -0x40(%rbp)
leaq 0x100(%r12), %rax
movq %rax, -0x70(%rbp)
leaq 0x8(%r12), %rax
movq %rax, -0x78(%rbp)
leaq 0x20(%r12), %rax
movq %rax, -0x88(%rbp)
leaq 0x28(%r12), %rax
movq %rax, -0x80(%rbp)
leaq 0x40(%r12), %rax
movq %rax, -0x98(%rbp)
leaq 0x48(%r12), %rax
movq %rax, -0x90(%rbp)
leaq 0x60(%r12), %rax
movq %rax, -0xa8(%rbp)
leaq 0x68(%r12), %rax
movq %rax, -0xa0(%rbp)
movl $0x1, %r13d
movl %ebx, -0x2c(%rbp)
movq %r12, -0x38(%rbp)
movq %r15, -0x68(%rbp)
movslq %r13d, %r14
movq (%r15,%r14,8), %rax
cmpb $0x2d, (%rax)
jne 0x897b
cmpb $0x75, 0x1(%rax)
jne 0x86c1
cmpb $0x0, 0x2(%rax)
je 0x8726
cmpb $0x66, 0x1(%rax)
jne 0x86d1
cmpb $0x0, 0x2(%rax)
je 0x88f6
cmpb $0x6f, 0x1(%rax)
jne 0x86e1
cmpb $0x0, 0x2(%rax)
je 0x8913
cmpb $0x70, 0x1(%rax)
jne 0x86f1
cmpb $0x0, 0x2(%rax)
je 0x8953
cmpb $0x63, 0x1(%rax)
jne 0x897b
cmpb $0x0, 0x2(%rax)
jne 0x897b
leal 0x1(%r14), %r13d
movq 0x8(%r15,%r14,8), %rbx
movq -0x50(%rbp), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x5180
movq -0x58(%rbp), %rdi
jmp 0x892f
movq 0x8(%r15,%r14,8), %rbx
movq 0x108(%r12), %r15
movq %rbx, %rdi
callq 0x5180
movq -0x70(%rbp), %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x55a0
movq 0x100(%r12), %rdx
leaq -0x8b0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x10af9(%rip), %rsi     # 0x19261
xorl %eax, %eax
callq 0x5090
movq %rbx, %rdi
leaq 0x109b8(%rip), %rsi     # 0x19131
callq 0x5450
testq %rax, %rax
je 0x8b2a
movq %rax, %r12
leaq -0x28b0(%rbp), %rbx
movq %rbx, %rdi
movl $0x2000, %esi           # imm = 0x2000
movq %r12, %rdx
callq 0x55e0
testq %rax, %rax
je 0x88e6
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53f0
testq %rax, %rax
je 0x87ce
cmpb $0xa, (%rax)
jne 0x87ce
movb $0x0, (%rax)
cmpb $0xa, -0x1(%rax)
leaq -0x1(%rax), %rax
je 0x87c1
movq %rbx, %rdi
movl $0x9, %esi
callq 0x5150
movq %rax, %r15
movb $0x0, (%rax)
movsbl 0x1(%r15), %ebx
incq %r15
movl %ebx, %edi
callq 0x5070
testl %ebx, %ebx
je 0x87f8
testl %eax, %eax
jne 0x87e1
movl -0x28b0(%rbp), %eax
movl $0x6b6e694c, %ecx       # imm = 0x6B6E694C
xorl %ecx, %eax
movzwl -0x28ac(%rbp), %ecx
xorl $0x73, %ecx
orl %eax, %ecx
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rbx
je 0x88c3
movl -0x28b0(%rbp), %eax
movl $0x6f666e49, %ecx       # imm = 0x6F666E49
xorl %ecx, %eax
movzbl -0x28ac(%rbp), %ecx
orl %eax, %ecx
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rbx
je 0x88c3
movl -0x28b0(%rbp), %eax
movl $0x656d614e, %ecx       # imm = 0x656D614E
xorl %ecx, %eax
movzwl -0x28ac(%rbp), %ecx
xorl $0x73, %ecx
orl %eax, %ecx
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rbx
je 0x88c3
movl -0x28b0(%rbp), %ecx
movq -0x78(%rbp), %rax
movq -0x38(%rbp), %rbx
cmpl $0x6e724c, %ecx         # imm = 0x6E724C
je 0x88c3
movq -0x28b0(%rbp), %rax
movabsq $0x796c626d65737341, %rdx # imm = 0x796C626D65737341
xorq %rdx, %rax
movzbl -0x28a8(%rbp), %edx
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rbx
je 0x88c3
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rbx
cmpl $0x474353, %ecx         # imm = 0x474353
jne 0x878a
movq (%rax), %r14
movq %r15, %rdi
callq 0x5180
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x55a0
jmp 0x878a
incl %r13d
movq -0x38(%rbp), %r12
movq -0x68(%rbp), %r15
movl -0x2c(%rbp), %ebx
jmp 0x8942
incl %r13d
movq 0x8(%r15,%r14,8), %rbx
movq -0x40(%rbp), %rax
movq (%rax), %r14
movq %rbx, %rdi
callq 0x5180
movq -0x48(%rbp), %rdi
jmp 0x892f
incl %r13d
movq 0x8(%r15,%r14,8), %rbx
movq 0xa8(%r12), %r14
movq %rbx, %rdi
callq 0x5180
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
movl -0x2c(%rbp), %ebx
movq %rax, %r8
callq 0x55a0
incl %r13d
cmpl %ebx, %r13d
jl 0x86a5
jmp 0x8326
movq 0x8(%r15,%r14,8), %rdi
callq 0x55c0
movl %eax, 0x160(%r12)
testl %eax, %eax
je 0x8bf1
cmpl $0x29, %eax
jge 0x8bf1
incl %r13d
jmp 0x8942
movq 0x19666(%rip), %rbx     # 0x21fe8
leaq 0x109b8(%rip), %rsi     # 0x19341
movl $0x13, %edx
movq %rbx, %rdi
callq 0x5420
movq (%r15,%r14,8), %r14
testq %r14, %r14
je 0x8a06
movq %r14, %rdi
callq 0x5180
movq 0x1963a(%rip), %rdi     # 0x21fe8
movq %r14, %rsi
movq %rax, %rdx
jmp 0x8ab6
movq 0x19628(%rip), %rbx     # 0x21fe8
leaq 0x1098e(%rip), %rsi     # 0x19355
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
jmp 0x8abe
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x5630
jmp 0x8abb
movq 0x195bf(%rip), %rbx     # 0x21fe8
leaq 0x10955(%rip), %rsi     # 0x19385
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
jmp 0x8a6d
movq 0x19598(%rip), %rbx     # 0x21fe8
leaq 0x10969(%rip), %rsi     # 0x193c0
movl $0x19, %edx
movq %rbx, %rdi
callq 0x5420
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
leaq 0x10922(%rip), %rsi     # 0x193a1
movl $0x1e, %edx
movq %rax, %rdi
callq 0x5420
movq 0x100(%r12), %rsi
movq 0x108(%r12), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
leaq 0x11a7a(%rip), %rsi     # 0x1a528
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5250
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x2888, %rsp           # imm = 0x2888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x5790
jmp 0x8ae2
movq 0x194de(%rip), %rbx     # 0x21fe8
leaq 0x108c9(%rip), %rsi     # 0x193da
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x40(%r12), %rsi
movq 0x48(%r12), %rdx
jmp 0x8b9b
movq 0x194b7(%rip), %rbx     # 0x21fe8
leaq 0x10735(%rip), %rsi     # 0x1926d
movl $0x16, %edx
movq %rbx, %rdi
callq 0x5420
movq -0x38(%rbp), %rax
movq 0x100(%rax), %rsi
movq 0x108(%rax), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
leaq 0x1071b(%rip), %rsi     # 0x19284
movl $0x6d, %edx
movq %rax, %rdi
jmp 0x89cf
movq 0x1946b(%rip), %rbx     # 0x21fe8
leaq 0x10871(%rip), %rsi     # 0x193f5
movl $0x1b, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x60(%r12), %rsi
movq 0x68(%r12), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
leaq 0x107f4(%rip), %rsi     # 0x193a1
movl $0x1e, %edx
movq %rax, %rdi
callq 0x5420
movq 0x100(%r12), %rsi
movq 0x108(%r12), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
leaq 0x1194c(%rip), %rsi     # 0x1a528
movl $0x1, %edx
movq %rax, %rdi
callq 0x5420
movq %rbx, %rdi
jmp 0x8cef
incq %r14
movq 0x193ed(%rip), %rbx     # 0x21fe8
leaq 0x1070a(%rip), %rsi     # 0x1930c
movl $0xf, %edx
movq %rbx, %rdi
callq 0x5420
movq (%r15,%r14,8), %r14
testq %r14, %r14
je 0x8c64
movq %r14, %rdi
callq 0x5180
movq 0x193c1(%rip), %rdi     # 0x21fe8
movq %r14, %rsi
movq %rax, %rdx
callq 0x5420
jmp 0x8c7b
movq 0x193ad(%rip), %rbx     # 0x21fe8
leaq 0x107cf(%rip), %rsi     # 0x19411
movl $0xf, %edx
movq %rbx, %rdi
callq 0x5420
movq 0x80(%r12), %rsi
movq 0x88(%r12), %rdx
jmp 0x8ce4
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x5630
leaq 0x1069a(%rip), %rsi     # 0x1931c
movl $0x24, %edx
jmp 0x89cc
movq 0x19355(%rip), %rbx     # 0x21fe8
leaq 0x10777(%rip), %rsi     # 0x19411
movl $0xf, %edx
movq %rbx, %rdi
callq 0x5420
movq 0xe0(%r12), %rsi
movq 0xe8(%r12), %rdx
jmp 0x8ce4
movq 0x19328(%rip), %rbx     # 0x21fe8
leaq 0x1074a(%rip), %rsi     # 0x19411
movl $0xf, %edx
movq %rbx, %rdi
callq 0x5420
movq 0xc0(%r12), %rsi
movq 0xc8(%r12), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rdi
callq 0x51a0
jmp 0x8ae2
jmp 0x8cfd
jmp 0x8d1a
movq %rax, %rbx
movq -0x8b0(%rbp), %rdi
leaq -0x8a0(%rbp), %rax
cmpq %rax, %rdi
je 0x8d1d
callq 0x5340
jmp 0x8d1d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x56a0