// File: CK7[P]abawaca/src/abawaca-build.cpp
// Function: prepare_scgs(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
string prepare_scgs(const string& assembly_file, const string& out_directory)
{
	char cmd[4096];

	sprintf(cmd, "mkdir %s/prodigal", out_directory.c_str());
	system(cmd);
	sprintf(cmd, "mkdir %s/scg", out_directory.c_str());
	system(cmd);

	size_t l = assembly_file.rfind('/');
	string out_name = (l == string::npos)? assembly_file : assembly_file.substr(l+1);
	char scg_name[2048], prodigal_name[2048];

	sprintf(prodigal_name, "%s/prodigal/%s", out_directory.c_str(), out_name.c_str());
	sprintf(scg_name, "%s/scg/%s", out_directory.c_str(), out_name.c_str());

	sprintf(cmd, "%s -i %s -o %s.gff -d %s.genes.fna -a %s.proteins.faa -p meta -f gff 2> %s.log", prodigal, assembly_file.c_str(), prodigal_name, prodigal_name, prodigal_name, prodigal_name);
	system(cmd);
	sprintf(cmd, "ln -s ../prodigal/%s.proteins.faa %s/scg", out_name.c_str(), out_directory.c_str());
	system(cmd);
	sprintf(cmd, "%s %s.proteins.faa 2> %s.stderr > %s.stdout", bacterial_scg, scg_name, scg_name, scg_name);
//	sprintf(cmd, "ruby %s %s.proteins.faa 2> %s.stderr > %s.stdout", bacterial_scg, scg_name, scg_name, scg_name);
	system(cmd);
	sprintf(cmd, "ln -s scg/%s.proteins.faa.bacteria.scg %s", out_name.c_str(), out_directory.c_str());
	system(cmd);

	char scg_file[2048];
	sprintf(scg_file, "%s/%s.proteins.faa.bacteria.scg", out_directory.c_str(), out_name.c_str());

	return scg_file;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2910, %rsp           # imm = 0x2910
movq %rdi, -0x2888(%rbp)
movq %rdi, %rax
movq %rax, -0x2880(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x2878(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4130
movq -0x2878(%rbp), %rdi
movq %rax, %rdx
leaq 0x14ce5(%rip), %rsi     # 0x226b5
movb $0x0, %al
callq 0x4080
leaq -0x1020(%rbp), %rdi
callq 0x4250
leaq -0x1020(%rbp), %rax
movq %rax, -0x2870(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4130
movq -0x2870(%rbp), %rdi
movq %rax, %rdx
leaq 0x14cbc(%rip), %rsi     # 0x226c7
movb $0x0, %al
callq 0x4080
leaq -0x1020(%rbp), %rdi
callq 0x4250
movq -0x10(%rbp), %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x4660
movq %rax, -0x1028(%rbp)
cmpq $-0x1, -0x1028(%rbp)
jne 0xda56
movq -0x10(%rbp), %rsi
leaq -0x1048(%rbp), %rdi
callq 0x4140
jmp 0xda78
movq -0x10(%rbp), %rsi
movq -0x1028(%rbp), %rdx
addq $0x1, %rdx
leaq -0x1048(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4320
movq -0x18(%rbp), %rdi
callq 0x4130
movq %rax, -0x28c0(%rbp)
leaq -0x1048(%rbp), %rdi
movq %rdi, -0x28b8(%rbp)
callq 0x4130
movq -0x28c0(%rbp), %rdx
movq %rax, %rcx
leaq 0x14c28(%rip), %rsi     # 0x226d4
xorl %eax, %eax
movb %al, -0x2891(%rbp)
leaq -0x2050(%rbp), %rdi
movq %rdi, -0x28a0(%rbp)
callq 0x4080
movq -0x18(%rbp), %rdi
callq 0x4130
movq -0x28b8(%rbp), %rdi
movq %rax, -0x28b0(%rbp)
callq 0x4130
movq -0x28b0(%rbp), %rdx
movq %rax, %rcx
movb -0x2891(%rbp), %al
leaq 0x14be9(%rip), %rsi     # 0x226e3
leaq -0x1850(%rbp), %rdi
callq 0x4080
movq 0x2486b(%rip), %rax     # 0x32378
movq %rax, -0x28a8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4130
movq -0x28a8(%rbp), %rdx
movq -0x28a0(%rbp), %r9
movq %rax, %rcx
movb -0x2891(%rbp), %al
movq %rsp, %rsi
movq %r9, 0x8(%rsi)
movq %r9, (%rsi)
leaq 0x14ba8(%rip), %rsi     # 0x226ed
leaq -0x1020(%rbp), %rdi
movq %rdi, -0x2890(%rbp)
movq %r9, %r8
callq 0x4080
movq -0x2890(%rbp), %rdi
callq 0x4250
jmp 0xdb69
leaq -0x1048(%rbp), %rdi
callq 0x4130
movq %rax, -0x28d0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4130
movq -0x28d0(%rbp), %rdx
movq %rax, %rcx
leaq 0x14ba6(%rip), %rsi     # 0x2273c
xorl %eax, %eax
leaq -0x1020(%rbp), %rdi
movq %rdi, -0x28c8(%rbp)
callq 0x4080
movq -0x28c8(%rbp), %rdi
callq 0x4250
jmp 0xdbb9
movq 0x247b0(%rip), %rdx     # 0x32370
leaq 0x14b9e(%rip), %rsi     # 0x22765
xorl %eax, %eax
leaq -0x1020(%rbp), %rdi
movq %rdi, -0x28d8(%rbp)
leaq -0x1850(%rbp), %r9
movq %r9, %rcx
movq %r9, %r8
callq 0x4080
movq -0x28d8(%rbp), %rdi
callq 0x4250
jmp 0xdbf7
leaq -0x1048(%rbp), %rdi
callq 0x4130
movq %rax, -0x28e8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4130
movq -0x28e8(%rbp), %rdx
movq %rax, %rcx
leaq 0x14b6d(%rip), %rsi     # 0x22791
xorl %eax, %eax
leaq -0x1020(%rbp), %rdi
movq %rdi, -0x28e0(%rbp)
callq 0x4080
movq -0x28e0(%rbp), %rdi
callq 0x4250
jmp 0xdc47
movq -0x18(%rbp), %rdi
callq 0x4130
movq %rax, -0x2900(%rbp)
leaq -0x1048(%rbp), %rdi
callq 0x4130
movq -0x2900(%rbp), %rdx
movq %rax, %rcx
leaq 0x14b47(%rip), %rsi     # 0x227bb
xorl %eax, %eax
leaq -0x2860(%rbp), %rdi
movq %rdi, -0x28f8(%rbp)
callq 0x4080
leaq -0x2861(%rbp), %rdi
movq %rdi, -0x28f0(%rbp)
callq 0x45d0
movq -0x2888(%rbp), %rdi
movq -0x28f8(%rbp), %rsi
movq -0x28f0(%rbp), %rdx
callq 0x4470
jmp 0xdcb8
leaq -0x2861(%rbp), %rdi
callq 0x4370
leaq -0x1048(%rbp), %rdi
callq 0x41c0
movq -0x2880(%rbp), %rax
addq $0x2910, %rsp           # imm = 0x2910
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2058(%rbp)
movl %eax, -0x205c(%rbp)
jmp 0xdd12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2058(%rbp)
movl %eax, -0x205c(%rbp)
leaq -0x2861(%rbp), %rdi
callq 0x4370
leaq -0x1048(%rbp), %rdi
callq 0x41c0
movq -0x2058(%rbp), %rdi
callq 0x45c0
nopw (%rax,%rax)