// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateSlurmCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, unsigned int)
string Swarm::generateSlurmCommand(string cmd, bool multiProg, unsigned int nCPU) {
	string command;

	//TODO: Need to display terminal output from cluster jobs

	// srun submits the job to the cluster
	command += "srun";

	// Add the job name
	command += " -J " + options.jobName;

	// Specify the cluster account if needed
	if (!options.clusterAccount.empty()) {
		command += " -A " + options.clusterAccount;
	}

	if (!options.clusterQueue.empty()) {
		command += " -p	" + options.clusterQueue;
	}

	if (options.emailWhenFinished) {
		command += " --mail-type=END,FAIL --mail-user=" + options.emailAddress;
	}

	//if (options.maxFitTime != MAX_LONG) {
	if (!options.maxFitTime.empty()) { //Raquel fixed slurm support
		//command += " -t 00:00:" + toString(options.maxFitTime);
		command += " -t " + options.maxFitTime; //Raquel fixed slurm support
	}

	// Specify output directory if needed
	if (options.saveClusterOutput) {
		command += " -o " + options.outputDir + "/" + options.jobName + "_cluster_output/" + options.jobName;
	}
	else {
		command += " -o /dev/null";
	}

	if (nCPU == 0) {
		int subParID;
		subParID = fcalcsubParID(options.parallelCount, options.models.size(), options.models.size());
		//command += " -n" + toString(options.parallelCount + 1);
		command += " -n" + toString(subParID);
	}
	else {
		command += " -n" + toString(nCPU);
	}

	command += " -l";


	if (multiProg) {
		command += " --multi-prog " + cmd;
	}
	else {
		command+= " " + cmd;
	}

	return command;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %r8d, %r15d
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
leaq 0x70bbe(%rip), %rsi     # 0xddaf6
callq 0x29480
leaq 0x14c0(%r12), %r13
leaq 0x716a6(%rip), %rsi     # 0xde5f2
leaq 0x8(%rsp), %rdi
movq %r13, %rdx
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
cmpq $0x0, 0x1758(%r12)
je 0x6cfab
leaq 0x1750(%r12), %rdx
leaq 0x71674(%rip), %rsi     # 0xde5fe
leaq 0x8(%rsp), %rdi
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
cmpq $0x0, 0x1780(%r12)
je 0x6cfe6
leaq 0x1778(%r12), %rdx
leaq 0x71546(%rip), %rsi     # 0xde50b
leaq 0x8(%rsp), %rdi
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
cmpb $0x1, 0x1798(%r12)
jne 0x6d021
leaq 0x17a0(%r12), %rdx
leaq 0x71596(%rip), %rsi     # 0xde596
leaq 0x8(%rsp), %rdi
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
cmpq $0x0, 0x1668(%r12)
je 0x6d05c
leaq 0x1660(%r12), %rdx
leaq 0x7157e(%rip), %rsi     # 0xde5b9
leaq 0x8(%rsp), %rdi
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
cmpb $0x1, 0x1770(%r12)
jne 0x6d11e
leaq 0x1500(%r12), %rdx
leaq 0x7159c(%rip), %rsi     # 0xde616
leaq 0x48(%rsp), %rdi
callq 0x3338b
leaq 0x7092c(%rip), %rdx     # 0xdd9b7
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x3336c
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movq %r13, %rdx
callq 0x334ce
leaq 0x7131b(%rip), %rdx     # 0xde3d1
leaq 0x28(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x3336c
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r13, %rdx
callq 0x334ce
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
leaq 0x28(%rsp), %rdi
callq 0x295a0
leaq 0x88(%rsp), %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
callq 0x295a0
leaq 0x48(%rsp), %rdi
callq 0x295a0
jmp 0x6d12d
leaq 0x714fd(%rip), %rsi     # 0xde622
movq %rbx, %rdi
callq 0x29480
testl %r15d, %r15d
je 0x6d164
leaq 0x28(%rsp), %rdi
movl %r15d, %esi
callq 0x9f56b
leaq 0x714f1(%rip), %rsi     # 0xde637
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x4933b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
jmp 0x6d1b6
movl 0x1628(%r12), %edi
movq 0x15c8(%r12), %rdx
subq 0x15c0(%r12), %rdx
shrq $0x3, %rdx
movl %edx, %esi
callq 0x9ec09
leaq 0x28(%rsp), %rdi
movl %eax, %esi
callq 0x9e9c3
leaq 0x7149d(%rip), %rsi     # 0xde637
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x4933b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
leaq 0x28(%rsp), %rdi
callq 0x295a0
leaq 0x713ed(%rip), %rsi     # 0xde5be
movq %rbx, %rdi
callq 0x29480
testb %bpl, %bpl
je 0x6d201
leaq 0x713dd(%rip), %rsi     # 0xde5c2
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
jmp 0x6d222
leaq 0x72405(%rip), %rsi     # 0xdf60d
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x3338b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x294d0
leaq 0x8(%rsp), %rdi
callq 0x295a0
movq %rbx, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6d2b2
jmp 0x6d2c1
jmp 0x6d2ea
jmp 0x6d2ea
jmp 0x6d2d9
jmp 0x6d2d9
jmp 0x6d2ea
jmp 0x6d2ea
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x295a0
jmp 0x6d275
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x295a0
jmp 0x6d284
movq %rax, %r14
leaq 0x88(%rsp), %rdi
callq 0x295a0
jmp 0x6d296
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x295a0
jmp 0x6d2a5
movq %rax, %r14
leaq 0x48(%rsp), %rdi
jmp 0x6d2e1
jmp 0x6d2ea
jmp 0x6d2d9
jmp 0x6d2ea
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x295a0
jmp 0x6d2c4
movq %rax, %r14
leaq 0x28(%rsp), %rdi
jmp 0x6d2e1
jmp 0x6d2ea
jmp 0x6d2d9
jmp 0x6d2ea
jmp 0x6d2d9
jmp 0x6d2ea
jmp 0x6d2d9
jmp 0x6d2ea
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x295a0
jmp 0x6d2ed
jmp 0x6d2ea
movq %rax, %r14
movq %rbx, %rdi
callq 0x295a0
movq %r14, %rdi
callq 0x292f0
nop