// File: /workspace/github_cpp_makefile_star2_O1/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 0x832cf(%rip), %rsi     # 0xff926
callq 0x233b0
leaq 0x14c0(%r12), %rdx
leaq 0x83db7(%rip), %rsi     # 0x100422
leaq 0x8(%rsp), %rdi
callq 0x319d8
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 0x7c6a2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1758(%r12)
je 0x7c6ef
leaq 0x1750(%r12), %rdx
leaq 0x83d72(%rip), %rsi     # 0x10042e
leaq 0x8(%rsp), %rdi
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c6ef
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1780(%r12)
je 0x7c73c
leaq 0x1778(%r12), %rdx
leaq 0x83c32(%rip), %rsi     # 0x10033b
leaq 0x8(%rsp), %rdi
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c73c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpb $0x1, 0x1798(%r12)
jne 0x7c789
leaq 0x17a0(%r12), %rdx
leaq 0x83c70(%rip), %rsi     # 0x1003c6
leaq 0x8(%rsp), %rdi
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c789
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpq $0x0, 0x1668(%r12)
je 0x7c7d6
leaq 0x1660(%r12), %rdx
leaq 0x83c46(%rip), %rsi     # 0x1003e9
leaq 0x8(%rsp), %rdi
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c7d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
cmpb $0x1, 0x1770(%r12)
jne 0x7c838
leaq 0x1500(%r12), %rdx
leaq 0x83c56(%rip), %rsi     # 0x100446
leaq 0x98(%rsp), %rdi
callq 0x319d8
leaq 0x82fe3(%rip), %rsi     # 0xff7e7
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 0x7c84c
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x7c852
leaq 0x83c13(%rip), %rsi     # 0x100452
movq %rbx, %rdi
callq 0x233b0
jmp 0x7ca39
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 0x7c8b0
movq %rdx, 0x78(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x88(%rsp)
jmp 0x7c8b6
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 0x83924(%rip), %rsi     # 0x100201
callq 0x233b0
leaq 0x38(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x7c90c
movq %rsi, %r13
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x7c915
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 0x7c96e
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7c974
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 0x7c9ba
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x7c9d1
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 0x7c9fc
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7ca18
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7ca39
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x229c0
testl %ebp, %ebp
je 0x7ca87
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0xc03b8
leaq 0x83a17(%rip), %rcx     # 0x100467
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 0x7caf4
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7cafc
movl 0x1628(%r12), %edi
movq 0x15c8(%r12), %rdx
subq 0x15c0(%r12), %rdx
shrq $0x3, %rdx
movl %edx, %esi
callq 0xbf2a3
leaq 0x28(%rsp), %rdi
movl %eax, %esi
callq 0xbee9e
leaq 0x839aa(%rip), %rcx     # 0x100467
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 0x7cb28
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x7cb30
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 0x7cb5a
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 0x7cb71
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7cb8c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x8385b(%rip), %rsi     # 0x1003ee
movq %rbx, %rdi
callq 0x233b0
testb %r15b, %r15b
je 0x7cbc8
leaq 0x8384b(%rip), %rsi     # 0x1003f2
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
jmp 0x7cbee
leaq 0x8486e(%rip), %rsi     # 0x10143d
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x319d8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x222b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7cc05
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 0x7ccef
jmp 0x7cd0b
jmp 0x7cd60
jmp 0x7cd60
jmp 0x7cd2d
jmp 0x7cd2d
jmp 0x7cd60
jmp 0x7cd60
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7cc66
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7cc66
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x7cc82
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7cc82
movq %rax, %r14
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x7cca9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7cca9
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7ccca
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7ccca
movq %rax, %r14
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7cd63
movq 0xa8(%rsp), %rsi
jmp 0x7cd54
jmp 0x7cd60
jmp 0x7cd2d
jmp 0x7cd60
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x7cd0e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7cd0e
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7cd63
movq 0x38(%rsp), %rsi
jmp 0x7cd54
jmp 0x7cd60
jmp 0x7cd2d
jmp 0x7cd60
jmp 0x7cd2d
jmp 0x7cd60
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x7cd4f
jmp 0x7cd63
jmp 0x7cd60
movq %rax, %r14
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7cd63
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x7cd63
jmp 0x7cd60
movq %rax, %r14
movq (%rbx), %rdi
cmpq 0x50(%rsp), %rdi
je 0x7cd7d
movq 0x50(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x229c0
movq %r14, %rdi
callq 0x23240
nop