// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, %r15
addq $0x1520, %rdi           # imm = 0x1520
movq %rdi, (%rsp)
callq 0x28570
leaq 0x1500(%r15), %rbx
leaq 0x170(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x28dd0
movq %r14, %rdi
callq 0x9ec28
movl %eax, %ebp
leaq 0x170(%rsp), %rdi
callq 0x295a0
testl %ebp, %ebp
jne 0x6d81e
leaq 0x686cd(%rip), %rsi     # 0xd5e97
leaq 0x190(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3338b
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x28dd0
leaq 0x90(%rsp), %rdi
callq 0x9f543
movl %eax, %ebx
leaq 0x90(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
jne 0x6db4b
leaq 0x190(%rsp), %rdi
callq 0x295a0
leaq 0x130(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
callq 0x28dd0
movq %rbx, %rdi
callq 0x9ec28
movl %eax, %ebx
leaq 0x130(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
je 0x6da5e
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movq %r15, 0x8(%rsp)
addq $0x1730, %r15           # imm = 0x1730
leaq 0x62b47(%rip), %r12     # 0xd03d0
leaq 0x70(%rsp), %rbp
leaq 0x6f3f6(%rip), %r14     # 0xdcc8b
leaq 0x620f9(%rip), %rbx     # 0xcf995
movq %r15, %rdi
movq %r12, %rsi
callq 0x33990
testb %al, %al
je 0x6d928
movq %r15, %rdi
leaq 0x62b17(%rip), %rsi     # 0xd03cc
callq 0x33990
testb %al, %al
je 0x6d928
movq 0xf86d3(%rip), %rdi     # 0x165f98
leaq 0x6f379(%rip), %rsi     # 0xdcc45
callq 0x289f0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x6f37e(%rip), %rsi     # 0xdcc65
callq 0x289f0
movq 0xf86dd(%rip), %rdi     # 0x165fd0
leaq 0x10(%rsp), %rsi
callq 0x28180
leaq 0x190(%rsp), %r13
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x290a0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x28ce0
movq %r13, %rdi
callq 0x28790
movq %r15, %rdi
movq %r12, %rsi
callq 0x3357b
testb %al, %al
jne 0x6d94a
movq %r15, %rdi
leaq 0x62a8b(%rip), %rsi     # 0xd03cc
callq 0x3357b
testb %al, %al
je 0x6d955
movq %rbp, %rdi
movq %r14, %rsi
callq 0x29490
movq %rbp, %rdi
movq %r14, %rsi
callq 0x3357b
testb %al, %al
jne 0x6d9cb
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3357b
testb %al, %al
jne 0x6d9cb
movq %rbp, %rdi
leaq 0x9e90c(%rip), %rsi     # 0x10c289
callq 0x3357b
testb %al, %al
jne 0x6d99d
movq %rbp, %rdi
leaq 0x70ca9(%rip), %rsi     # 0xde639
callq 0x3357b
testb %al, %al
je 0x6d89c
leaq 0x6f372(%rip), %rsi     # 0xdcd16
leaq 0xd0(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x33402
leaq 0xd0(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x6aed2
leaq 0x6f2bb(%rip), %rsi     # 0xdcc8d
leaq 0x190(%rsp), %rdi
movq (%rsp), %rdx
callq 0x3338b
movq 0x8(%rsp), %r15
cmpl $0x0, 0x1614(%r15)
je 0x6da0d
movq 0xf859f(%rip), %rdi     # 0x165f98
leaq 0x6f294(%rip), %rsi     # 0xdcc94
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x50(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x28dd0
leaq 0x50(%rsp), %rdi
callq 0x9f543
movl %eax, %ebx
leaq 0x50(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
jne 0x6db01
leaq 0x190(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x10(%rsp), %rdi
callq 0x295a0
leaq 0x68432(%rip), %rsi     # 0xd5e97
leaq 0x190(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rdx
callq 0x3338b
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x28dd0
leaq 0x30(%rsp), %rdi
callq 0x9f543
movl %eax, %ebx
leaq 0x30(%rsp), %rdi
callq 0x295a0
testl %ebx, %ebx
jne 0x6dabf
leaq 0x190(%rsp), %rdi
callq 0x295a0
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6f282(%rip), %rsi     # 0xdcd48
leaq 0x10(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x3338b
leaq 0x720c3(%rip), %rdx     # 0xdfba2
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x3336c
leaq 0xb0(%rsp), %rsi
movq %r15, %rdi
callq 0x6aed2
leaq 0x6f1ca(%rip), %rsi     # 0xdccd2
leaq 0xf0(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x3338b
leaq 0x7207e(%rip), %rdx     # 0xdfba2
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x3336c
leaq 0x110(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x6aed2
leaq 0x6f0b7(%rip), %rsi     # 0xdcc09
leaq 0x10(%rsp), %rdi
leaq 0x190(%rsp), %rdx
callq 0x3338b
leaq 0x72037(%rip), %rdx     # 0xdfba2
leaq 0x150(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x3336c
leaq 0x150(%rsp), %rsi
movq %r15, %rdi
callq 0x6aed2
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
jmp 0x6dbc8
jmp 0x6dbcf
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x295a0
jmp 0x6dbb1
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x6dbf4
jmp 0x6dc0c
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x295a0
jmp 0x6dbd2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x6dc05
jmp 0x6dc33
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x6dc05
jmp 0x6dc0c
jmp 0x6dc0c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x295a0
jmp 0x6dc36
jmp 0x6dc68
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x295a0
jmp 0x6dc0f
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
jmp 0x6dc7a
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
jmp 0x6dc7a
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
jmp 0x6dc7a
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
jmp 0x6dc5f
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x28790
jmp 0x6dc6b
jmp 0x6dc68
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x295a0
jmp 0x6dc6b
jmp 0x6dc68
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x10(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0
nop