// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::setJobOutputDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Swarm::setJobOutputDir(string path) {
	options.jobOutputDir = path;

	if (!checkIfFileExists(options.outputDir)) {
		string cmd = "mkdir " + options.outputDir;
		//cout << "running: " << cmd << endl;
		if(runCommand(cmd) != 0) {
			outputError("Error: Couldn't create base output directory with command: " + cmd + ". Quitting.");
		}
	}

	if (checkIfFileExists(options.jobOutputDir)) {
		string input;
		string answer;
		while (1) {

			//Raquel fixing MPI support issues
			if(options.clusterSoftware != "mpi" && options.clusterSoftware != "BNF2mpi"){
				cout << "Warning: Your output directory " << options.jobOutputDir << " already exists. Overwrite? (Y or N) ";
				getline(cin, input);
				stringstream myInp(input);
				myInp >> answer;
			}

			if(options.clusterSoftware == "mpi" || options.clusterSoftware == "BNF2mpi"){
				answer = "Y";
			}

			if (answer == "Y" || answer == "y") {
				string cmd = "rm -r " + options.jobOutputDir;
				if (options.verbosity >= 1) {
					cout << "Deleting old output directory, this may take a few minutes..." << endl;
				}

				if(runCommand(cmd) != 0) {
					outputError("Error: Couldn't delete existing output directory with the command: " + cmd + ". Quitting.");
				}
				break;
			}
			else if (answer == "N" || answer == "n") {
				outputError("Error: Output directory already exists. Quitting.");
			}
		}
	}
	string cmd = "mkdir " + options.jobOutputDir;
	//cout << "else running: " << cmd << endl;
	//int ret = system(cmd.c_str());
	if(runCommand(cmd) != 0) {
		outputError("Error: Couldn't create output directory with command: " + cmd + ". Quitting.");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
addq $0x1520, %rdi           # imm = 0x1520
callq 0x30fa0
movq -0x3e8(%rbp), %rsi
addq $0x1500, %rsi           # imm = 0x1500
leaq -0x30(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x2f300
movq -0x3e0(%rbp), %rdi
callq 0x17d410
movl %eax, -0x3d4(%rbp)
jmp 0xef70c
movl -0x3d4(%rbp), %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x3e9(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x311e8
movb -0x3e9(%rbp), %al
testb $0x1, %al
jne 0xef738
jmp 0xef888
movq -0x3e8(%rbp), %rdx
addq $0x1500, %rdx           # imm = 0x1500
leaq 0xeb04a(%rip), %rsi     # 0x1da797
leaq -0x60(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0x44240
movq -0x3f8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2f300
jmp 0xef76f
leaq -0x80(%rbp), %rdi
callq 0x17e3f0
movl %eax, -0x3fc(%rbp)
jmp 0xef780
leaq -0x80(%rbp), %rdi
callq 0x311e8
movl -0x3fc(%rbp), %eax
cmpl $0x0, %eax
je 0xef86f
leaq 0xf1dda(%rip), %rsi     # 0x1e1579
leaq -0xc0(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x44240
jmp 0xef7b1
leaq 0xf4eac(%rip), %rdx     # 0x1e4664
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x441f0
jmp 0xef7cd
movq -0x3e8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xeada0
jmp 0xef7e2
leaq -0xa0(%rbp), %rdi
callq 0x311e8
leaq -0xc0(%rbp), %rdi
callq 0x311e8
jmp 0xef86f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x311e8
jmp 0xeff24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xef87a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x311e8
jmp 0xef87a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xef861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x311e8
leaq -0xc0(%rbp), %rdi
callq 0x311e8
jmp 0xef87a
leaq -0x60(%rbp), %rdi
callq 0x311e8
jmp 0xef888
leaq -0x60(%rbp), %rdi
callq 0x311e8
jmp 0xeff24
movq -0x3e8(%rbp), %rsi
addq $0x1520, %rsi           # imm = 0x1520
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x408(%rbp)
callq 0x2f300
movq -0x408(%rbp), %rdi
callq 0x17d410
movl %eax, -0x400(%rbp)
jmp 0xef8bd
leaq -0xe0(%rbp), %rdi
callq 0x311e8
movl -0x400(%rbp), %eax
cmpl $0x0, %eax
je 0xefdd4
leaq -0x100(%rbp), %rdi
callq 0x2f880
leaq -0x120(%rbp), %rdi
callq 0x2f880
jmp 0xef8f2
movq -0x3e8(%rbp), %rdi
addq $0x1730, %rdi           # imm = 0x1730
leaq 0xe4efe(%rip), %rsi     # 0x1d4805
callq 0x45af0
movb %al, -0x409(%rbp)
jmp 0xef914
movb -0x409(%rbp), %al
testb $0x1, %al
jne 0xef923
jmp 0xefa5d
movq -0x3e8(%rbp), %rdi
addq $0x1730, %rdi           # imm = 0x1730
leaq 0xe4ec9(%rip), %rsi     # 0x1d4801
callq 0x45af0
movb %al, -0x40a(%rbp)
jmp 0xef945
movb -0x40a(%rbp), %al
testb $0x1, %al
jne 0xef954
jmp 0xefa5d
movq 0x1e55f5(%rip), %rdi    # 0x2d4f50
leaq 0xf1c53(%rip), %rsi     # 0x1e15b5
callq 0x2ff50
movq %rax, -0x418(%rbp)
jmp 0xef970
movq -0x418(%rbp), %rdi
movq -0x3e8(%rbp), %rsi
addq $0x1520, %rsi           # imm = 0x1520
callq 0x2f780
movq %rax, -0x420(%rbp)
jmp 0xef993
movq -0x420(%rbp), %rdi
leaq 0xf1c34(%rip), %rsi     # 0x1e15d5
callq 0x2ff50
jmp 0xef9a8
movq 0x1e5609(%rip), %rdi    # 0x2d4fb8
leaq -0x100(%rbp), %rsi
callq 0x2fcb0
jmp 0xef9bd
movl $0x10, %edi
movl $0x8, %esi
callq 0x122610
movl %eax, -0x424(%rbp)
jmp 0xef9d4
movl -0x424(%rbp), %edx
leaq -0x2a8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x31190
jmp 0xef9ef
leaq -0x2a8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2fae0
jmp 0xefa04
leaq -0x2a8(%rbp), %rdi
callq 0x2f940
jmp 0xefa5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x311e8
jmp 0xeff24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xefdb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x2f940
jmp 0xefdb7
movq -0x3e8(%rbp), %rdi
addq $0x1730, %rdi           # imm = 0x1730
leaq 0xe4d93(%rip), %rsi     # 0x1d4805
callq 0x44930
movb %al, -0x425(%rbp)
jmp 0xefa7f
movb -0x425(%rbp), %al
testb $0x1, %al
jne 0xefab9
jmp 0xefa8b
movq -0x3e8(%rbp), %rdi
addq $0x1730, %rdi           # imm = 0x1730
leaq 0xe4d61(%rip), %rsi     # 0x1d4801
callq 0x44930
movb %al, -0x426(%rbp)
jmp 0xefaad
movb -0x426(%rbp), %al
testb $0x1, %al
jne 0xefab9
jmp 0xefad0
leaq 0xf1b3b(%rip), %rsi     # 0x1e15fb
leaq -0x120(%rbp), %rdi
callq 0x2f9d0
jmp 0xeface
jmp 0xefad0
leaq 0xf1b24(%rip), %rsi     # 0x1e15fb
leaq -0x120(%rbp), %rdi
callq 0x44930
movb %al, -0x427(%rbp)
jmp 0xefaeb
movb -0x427(%rbp), %al
testb $0x1, %al
jne 0xefb21
jmp 0xefaf7
leaq 0xe42cc(%rip), %rsi     # 0x1d3dca
leaq -0x120(%rbp), %rdi
callq 0x44930
movb %al, -0x428(%rbp)
jmp 0xefb12
movb -0x428(%rbp), %al
testb $0x1, %al
jne 0xefb21
jmp 0xefcb3
movq -0x3e8(%rbp), %rdx
addq $0x1520, %rdx           # imm = 0x1520
leaq 0xf1ac7(%rip), %rsi     # 0x1e15fd
leaq -0x2c8(%rbp), %rdi
callq 0x44240
jmp 0xefb44
movq -0x3e8(%rbp), %rax
cmpl $0x1, 0x1614(%rax)
jb 0xefb98
movq 0x1e53f5(%rip), %rdi    # 0x2d4f50
leaq 0xf1aa2(%rip), %rsi     # 0x1e1604
callq 0x2ff50
movq %rax, -0x430(%rbp)
jmp 0xefb70
movq -0x430(%rbp), %rdi
movq 0x1e544a(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0xefb85
jmp 0xefb98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xefca2
leaq -0x2e8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x2f300
jmp 0xefbad
leaq -0x2e8(%rbp), %rdi
callq 0x17e3f0
movl %eax, -0x434(%rbp)
jmp 0xefbc1
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
movl -0x434(%rbp), %eax
cmpl $0x0, %eax
je 0xefc91
leaq 0xf1a5f(%rip), %rsi     # 0x1e1642
leaq -0x328(%rbp), %rdi
leaq -0x2c8(%rbp), %rdx
callq 0x44240
jmp 0xefbf8
leaq 0xf4a65(%rip), %rdx     # 0x1e4664
leaq -0x308(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x441f0
jmp 0xefc14
movq -0x3e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0xeada0
jmp 0xefc29
leaq -0x308(%rbp), %rdi
callq 0x311e8
leaq -0x328(%rbp), %rdi
callq 0x311e8
jmp 0xefc91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
jmp 0xefca2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xefc83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x311e8
leaq -0x328(%rbp), %rdi
callq 0x311e8
jmp 0xefca2
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
jmp 0xefd9d
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
jmp 0xefdb7
leaq 0x12166f(%rip), %rsi    # 0x211329
leaq -0x120(%rbp), %rdi
callq 0x44930
movb %al, -0x435(%rbp)
jmp 0xefcce
movb -0x435(%rbp), %al
testb $0x1, %al
jne 0xefd04
jmp 0xefcda
leaq 0xf3367(%rip), %rsi     # 0x1e3048
leaq -0x120(%rbp), %rdi
callq 0x44930
movb %al, -0x436(%rbp)
jmp 0xefcf5
movb -0x436(%rbp), %al
testb $0x1, %al
jne 0xefd04
jmp 0xefd96
leaq -0x349(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x30a70
movq -0x440(%rbp), %rdx
leaq 0xf1961(%rip), %rsi     # 0x1e1686
leaq -0x348(%rbp), %rdi
callq 0x44470
jmp 0xefd33
movq -0x3e8(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0xeada0
jmp 0xefd48
leaq -0x348(%rbp), %rdi
callq 0x311e8
leaq -0x349(%rbp), %rdi
callq 0x311c0
jmp 0xefd96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xefd88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x311e8
leaq -0x349(%rbp), %rdi
callq 0x311c0
jmp 0xefdb7
jmp 0xefd98
jmp 0xef8f0
leaq -0x120(%rbp), %rdi
callq 0x311e8
leaq -0x100(%rbp), %rdi
callq 0x311e8
jmp 0xefdd4
leaq -0x120(%rbp), %rdi
callq 0x311e8
leaq -0x100(%rbp), %rdi
callq 0x311e8
jmp 0xeff24
movq -0x3e8(%rbp), %rdx
addq $0x1520, %rdx           # imm = 0x1520
leaq 0xea9ae(%rip), %rsi     # 0x1da797
leaq -0x370(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x44240
movq -0x448(%rbp), %rsi
leaq -0x390(%rbp), %rdi
callq 0x2f300
jmp 0xefe11
leaq -0x390(%rbp), %rdi
callq 0x17e3f0
movl %eax, -0x44c(%rbp)
jmp 0xefe25
leaq -0x390(%rbp), %rdi
callq 0x311e8
movl -0x44c(%rbp), %eax
cmpl $0x0, %eax
je 0xeff03
leaq 0xf1871(%rip), %rsi     # 0x1e16b8
leaq -0x3d0(%rbp), %rdi
leaq -0x370(%rbp), %rdx
callq 0x44240
jmp 0xefe5c
leaq 0xf4801(%rip), %rdx     # 0x1e4664
leaq -0x3b0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x441f0
jmp 0xefe78
movq -0x3e8(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
callq 0xeada0
jmp 0xefe8d
leaq -0x3b0(%rbp), %rdi
callq 0x311e8
leaq -0x3d0(%rbp), %rdi
callq 0x311e8
jmp 0xeff03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xeff18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x311e8
jmp 0xeff18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xefef5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x311e8
leaq -0x3d0(%rbp), %rdi
callq 0x311e8
jmp 0xeff18
leaq -0x370(%rbp), %rdi
callq 0x311e8
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
leaq -0x370(%rbp), %rdi
callq 0x311e8
movq -0x38(%rbp), %rdi
callq 0x30170
nopl (%rax)