// File: /workspace/github_cpp_makefile_star2_O3/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 $0xb8, %rsp
movl %r8d, %ebp
movl %ecx, %r15d
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, 0x50(%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
leaq 0x83948(%rip), %rsi     # 0xff90d
callq 0x233b0
leaq 0x14c0(%r12), %rdx
leaq 0x84430(%rip), %rsi     # 0x100409
leaq 0x8(%rsp), %rdi
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
leaq 0x18(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x7c010
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1758(%r12)
je 0x7c05d
leaq 0x1750(%r12), %rdx
leaq 0x843eb(%rip), %rsi     # 0x100415
leaq 0x8(%rsp), %rdi
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c05d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1780(%r12)
je 0x7c0aa
leaq 0x1778(%r12), %rdx
leaq 0x842ab(%rip), %rsi     # 0x100322
leaq 0x8(%rsp), %rdi
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c0aa
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpb $0x1, 0x1798(%r12)
jne 0x7c0f7
leaq 0x17a0(%r12), %rdx
leaq 0x842e9(%rip), %rsi     # 0x1003ad
leaq 0x8(%rsp), %rdi
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c0f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1668(%r12)
je 0x7c144
leaq 0x1660(%r12), %rdx
leaq 0x842bf(%rip), %rsi     # 0x1003d0
leaq 0x8(%rsp), %rdi
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c144
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpb $0x1, 0x1770(%r12)
jne 0x7c1a6
leaq 0x1500(%r12), %rdx
leaq 0x842cf(%rip), %rsi     # 0x10042d
leaq 0x98(%rsp), %rdi
callq 0x31944
leaq 0x836e5(%rip), %rsi     # 0xff857
leaq 0x98(%rsp), %rdi
callq 0x233b0
leaq 0x68(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c1ba
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x7c1c0
leaq 0x8428c(%rip), %rsi     # 0x100439
movq %rbx, %rdi
callq 0x233b0
jmp 0x7c3a7
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x58(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x14c0(%r12), %rsi
movq 0x14c8(%r12), %rdx
callq 0x222b0
leaq 0x88(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c21e
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x7c224
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movl %ebp, 0x4c(%rsp)
movq 0x8(%rax), %rdx
leaq 0x78(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x83f9d(%rip), %rsi     # 0x1001e8
callq 0x233b0
leaq 0x38(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c27a
movq %rsi, %r13
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x7c283
movups (%rcx), %xmm0
movq %rsi, %r13
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x14c0(%r12), %rsi
movq 0x14c8(%r12), %rdx
callq 0x222b0
leaq 0x18(%rsp), %rsi
movq %rsi, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c2dc
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7c2e2
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7c328
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c33f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
movl 0x4c(%rsp), %ebp
leaq 0x18(%rsp), %r13
je 0x7c36a
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7c386
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c3a7
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
je 0x7c3f5
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0xbfa49
leaq 0x84090(%rip), %rcx     # 0x10044e
leaq 0x28(%rsp), %rdi
movl $0x3, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
movq %r13, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c462
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7c46a
movl 0x1628(%r12), %edi
movq 0x15c8(%r12), %rdx
subq 0x15c0(%r12), %rdx
shrq $0x3, %rdx
movl %edx, %esi
callq 0xbe989
leaq 0x28(%rsp), %rdi
movl %eax, %esi
callq 0xbe584
leaq 0x84023(%rip), %rcx     # 0x10044e
leaq 0x28(%rsp), %rdi
movl $0x3, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a80
movq %r13, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c496
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7c49e
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
jmp 0x7c4c8
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c4df
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c4fa
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x83ed4(%rip), %rsi     # 0x1003d5
movq %rbx, %rdi
callq 0x233b0
testb %r15b, %r15b
je 0x7c536
leaq 0x83ec4(%rip), %rsi     # 0x1003d9
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
jmp 0x7c55c
leaq 0x84ee7(%rip), %rsi     # 0x101424
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x31944
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c573
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7c65d
jmp 0x7c679
jmp 0x7c6ce
jmp 0x7c6ce
jmp 0x7c69b
jmp 0x7c69b
jmp 0x7c6ce
jmp 0x7c6ce
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7c5d4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c5d4
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c5f0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c5f0
movq %rax, %r14
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x7c617
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c617
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7c638
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c638
movq %rax, %r14
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c6d1
movq 0xa8(%rsp), %rsi
jmp 0x7c6c2
jmp 0x7c6ce
jmp 0x7c69b
jmp 0x7c6ce
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c67c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c67c
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c6d1
movq 0x38(%rsp), %rsi
jmp 0x7c6c2
jmp 0x7c6ce
jmp 0x7c69b
jmp 0x7c6ce
jmp 0x7c69b
jmp 0x7c6ce
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x7c6bd
jmp 0x7c6d1
jmp 0x7c6ce
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c6d1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7c6d1
jmp 0x7c6ce
movq %rax, %r14
movq (%rbx), %rdi
cmpq 0x50(%rsp), %rdi
je 0x7c6eb
movq 0x50(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x229c0
movq %r14, %rdi
callq 0x23240
nop