// File: 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
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq %rdx, -0x260(%rbp)
movq %rdi, -0x248(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x258(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x250(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x2f880
movq -0x248(%rbp), %rdi
leaq 0xf3eb9(%rip), %rsi     # 0x1e2505
callq 0x2f330
jmp 0xee653
movq -0x250(%rbp), %rdx
addq $0x14c0, %rdx           # imm = 0x14C0
leaq 0xf4999(%rip), %rsi     # 0x1e3001
leaq -0x58(%rbp), %rdi
callq 0x44240
jmp 0xee673
movq -0x248(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x2f1e0
jmp 0xee685
leaq -0x58(%rbp), %rdi
callq 0x311e8
movq -0x250(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x290, %rdi            # imm = 0x290
callq 0x2f700
testb $0x1, %al
jne 0xee732
movq -0x250(%rbp), %rdx
addq $0x1750, %rdx           # imm = 0x1750
leaq 0xf4948(%rip), %rsi     # 0x1e300d
leaq -0x78(%rbp), %rdi
callq 0x44240
jmp 0xee6d0
movq -0x248(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x2f1e0
jmp 0xee6e2
leaq -0x78(%rbp), %rdi
callq 0x311e8
jmp 0xee732
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeecd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x250(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x2b8, %rdi            # imm = 0x2B8
callq 0x2f700
testb $0x1, %al
jne 0xee7b3
movq -0x250(%rbp), %rdx
addq $0x1778, %rdx           # imm = 0x1778
leaq 0xf47b5(%rip), %rsi     # 0x1e2f1a
leaq -0x98(%rbp), %rdi
callq 0x44240
jmp 0xee773
movq -0x248(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2f1e0
jmp 0xee788
leaq -0x98(%rbp), %rdi
callq 0x311e8
jmp 0xee7b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x250(%rbp), %rax
testb $0x1, 0x1798(%rax)
je 0xee826
movq -0x250(%rbp), %rdx
addq $0x17a0, %rdx           # imm = 0x17A0
leaq 0xf47cd(%rip), %rsi     # 0x1e2fa5
leaq -0xb8(%rbp), %rdi
callq 0x44240
jmp 0xee7e6
movq -0x248(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2f1e0
jmp 0xee7fb
leaq -0xb8(%rbp), %rdi
callq 0x311e8
jmp 0xee826
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x250(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x2f700
testb $0x1, %al
jne 0xee8a7
movq -0x250(%rbp), %rdx
addq $0x1660, %rdx           # imm = 0x1660
leaq 0xf476f(%rip), %rsi     # 0x1e2fc8
leaq -0xd8(%rbp), %rdi
callq 0x44240
jmp 0xee867
movq -0x248(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x2f1e0
jmp 0xee87c
leaq -0xd8(%rbp), %rdi
callq 0x311e8
jmp 0xee8a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x250(%rbp), %rax
testb $0x1, 0x1770(%rax)
je 0xeea37
movq -0x250(%rbp), %rdx
addq $0x1500, %rdx           # imm = 0x1500
leaq 0xf4755(%rip), %rsi     # 0x1e3025
leaq -0x178(%rbp), %rdi
callq 0x44240
jmp 0xee8de
leaq 0xf3a6e(%rip), %rdx     # 0x1e2353
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x441f0
jmp 0xee8fa
movq -0x250(%rbp), %rdx
addq $0x14c0, %rdx           # imm = 0x14C0
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x44760
jmp 0xee91d
leaq 0xf44bc(%rip), %rdx     # 0x1e2de0
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x441f0
jmp 0xee939
movq -0x250(%rbp), %rdx
addq $0x14c0, %rdx           # imm = 0x14C0
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x44760
jmp 0xee95c
movq -0x248(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x2f1e0
jmp 0xee971
leaq -0xf8(%rbp), %rdi
callq 0x311e8
leaq -0x118(%rbp), %rdi
callq 0x311e8
leaq -0x138(%rbp), %rdi
callq 0x311e8
leaq -0x158(%rbp), %rdi
callq 0x311e8
leaq -0x178(%rbp), %rdi
callq 0x311e8
jmp 0xeea4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeea26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeea1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeea0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeea02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x311e8
leaq -0x118(%rbp), %rdi
callq 0x311e8
leaq -0x138(%rbp), %rdi
callq 0x311e8
leaq -0x158(%rbp), %rdi
callq 0x311e8
leaq -0x178(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x248(%rbp), %rdi
leaq 0xf45ec(%rip), %rsi     # 0x1e3031
callq 0x2f330
jmp 0xeea4c
jmp 0xeea4e
cmpl $0x0, -0x20(%rbp)
jne 0xeeb50
movq -0x250(%rbp), %rdi
movl 0x1628(%rdi), %eax
movl %eax, -0x26c(%rbp)
addq $0x15c0, %rdi           # imm = 0x15C0
movq %rdi, -0x278(%rbp)
callq 0x45170
movq -0x278(%rbp), %rdi
movl %eax, -0x268(%rbp)
callq 0x45170
movl -0x26c(%rbp), %edi
movl -0x268(%rbp), %esi
movl %eax, %edx
callq 0x17d3a0
movl %eax, -0x264(%rbp)
jmp 0xeeaab
movl -0x264(%rbp), %eax
movl %eax, -0x17c(%rbp)
movl -0x17c(%rbp), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x17ce40
jmp 0xeeacb
leaq 0xf4574(%rip), %rsi     # 0x1e3046
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rdx
callq 0x8e0f0
jmp 0xeeae7
movq -0x248(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x2f1e0
jmp 0xeeafc
leaq -0x1a0(%rbp), %rdi
callq 0x311e8
leaq -0x1c0(%rbp), %rdi
callq 0x311e8
jmp 0xeebe3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeeb3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x311e8
leaq -0x1c0(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movl -0x20(%rbp), %esi
leaq -0x200(%rbp), %rdi
callq 0x17e460
jmp 0xeeb61
leaq 0xf44de(%rip), %rsi     # 0x1e3046
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rdx
callq 0x8e0f0
jmp 0xeeb7d
movq -0x248(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x2f1e0
jmp 0xeeb92
leaq -0x1e0(%rbp), %rdi
callq 0x311e8
leaq -0x200(%rbp), %rdi
callq 0x311e8
jmp 0xeebe3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xeebd2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x311e8
leaq -0x200(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x248(%rbp), %rdi
leaq 0xf43dc(%rip), %rsi     # 0x1e2fcd
callq 0x2f330
jmp 0xeebf8
testb $0x1, -0x19(%rbp)
je 0xeec57
movq -0x260(%rbp), %rdx
leaq 0xf43c5(%rip), %rsi     # 0x1e2fd1
leaq -0x220(%rbp), %rdi
callq 0x44240
jmp 0xeec1a
movq -0x248(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x2f1e0
jmp 0xeec2f
leaq -0x220(%rbp), %rdi
callq 0x311e8
jmp 0xeecb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movq -0x260(%rbp), %rdx
leaq 0xf546a(%rip), %rsi     # 0x1e40cf
leaq -0x240(%rbp), %rdi
callq 0x44240
jmp 0xeec73
movq -0x248(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x2f1e0
jmp 0xeec88
leaq -0x240(%rbp), %rdi
callq 0x311e8
jmp 0xeecb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x311e8
jmp 0xeecd6
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0xeecc6
movq -0x248(%rbp), %rdi
callq 0x311e8
movq -0x258(%rbp), %rax
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq -0x248(%rbp), %rdi
callq 0x311e8
movq -0x30(%rbp), %rdi
callq 0x30170
nopl (%rax,%rax)