// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateSlurmMultiProgCmd(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string Swarm::generateSlurmMultiProgCmd(string runCmd) {
	string multiProgConfPath = options.jobOutputDir + "multiprog.conf";
	ofstream multiprog(multiProgConfPath, ios::out);

	if (multiprog.is_open()) {

		vector<string> paths;
		paths.push_back(sConf_[0]);
		paths.push_back(expPaths_[0][0]);
		paths.push_back(exePath_);

		string mycommonPath = commonPath(paths, '/');
		string expsubPath;
		string exesubPath;
		string sconfsubPath;

		multiprog << "#SBATCH --workdir=" << mycommonPath << endl;

		string command = exePath_ + " -a load -c " + sConf_[0];
		//multiprog << "0 " << runCmd << " load " << sConf_[0] << endl;
		multiprog << "0 " << command << endl;
		int subPID;
		for (int id = 1; id <= options.swarmSize; ++id) {
			for (unsigned int mid = 0; mid < options.models.size(); ++mid){

				subPID = fcalcsubParID(id, mid, options.models.size());

				exesubPath = exePath_.substr(mycommonPath.length(), mycommonPath.length()+exePath_.length());
				expsubPath = expPaths_[mid][0].substr(mycommonPath.length(), mycommonPath.length()+expPaths_[mid][0].length());
				sconfsubPath = sConf_[mid].substr(mycommonPath.length(), mycommonPath.length()+sConf_[mid].length());

				//multiprog << toString(subPID) + " " << runCmd << " particle " << toString(id) << " run " << sConf_[mid] << endl;
				//				multiprog << toString(id) + " " << runCmd << " particle " << toString(id) << " run " << sConf_[mid] << endl;
				command = "." + exesubPath + " -t particle -p " + toString(subPID) + " -a cluster -g " + toString(currentGeneration) + " -c ." + sconfsubPath + " -e ." + expsubPath;  //razi: consider more than 1 exp
				command = command + " -n " + toString(this->getNumModels());
				//command = command + " >> pOUT 2>&1";
				multiprog << toString(subPID) + " " << command << endl;



			}
		}
		multiprog.close();
	}
	return generateSlurmCommand(multiProgConfPath);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6f0, %rsp            # imm = 0x6F0
movq %rdi, -0x5d8(%rbp)
movq %rdi, %rax
movq %rax, -0x5d0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x5c8(%rbp)
addq $0x1520, %rsi           # imm = 0x1520
leaq 0xd6cc9(%rip), %rdx     # 0x1e2e8a
leaq -0x38(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x447b0
movq -0x5c0(%rbp), %rsi
leaq -0x238(%rbp), %rdi
movl $0x10, %edx
callq 0x2f360
jmp 0x10c1eb
leaq -0x238(%rbp), %rdi
callq 0x30530
movb %al, -0x5d9(%rbp)
jmp 0x10c1ff
movb -0x5d9(%rbp), %al
testb $0x1, %al
jne 0x10c20e
jmp 0x10cd24
leaq -0x260(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
callq 0x448b0
movq -0x5c8(%rbp), %rdi
addq $0x1938, %rdi           # imm = 0x1938
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq -0x5e8(%rbp), %rdi
movq %rax, %rsi
callq 0x45280
jmp 0x10c249
movq -0x5c8(%rbp), %rdi
addq $0x1908, %rdi           # imm = 0x1908
movl $0x0, -0x264(%rbp)
leaq -0x264(%rbp), %rsi
callq 0x121860
movq %rax, -0x5f0(%rbp)
jmp 0x10c276
movq -0x5f0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq %rax, %rsi
leaq -0x260(%rbp), %rdi
callq 0x45280
jmp 0x10c297
movq -0x5c8(%rbp), %rsi
addq $0x17e0, %rsi           # imm = 0x17E0
leaq -0x260(%rbp), %rdi
callq 0x45280
jmp 0x10c2b3
leaq -0x288(%rbp), %rdi
leaq -0x260(%rbp), %rsi
movl $0x2f, %edx
callq 0x17de70
jmp 0x10c2cd
leaq -0x2a8(%rbp), %rdi
callq 0x2f880
leaq -0x2c8(%rbp), %rdi
callq 0x2f880
leaq -0x2e8(%rbp), %rdi
callq 0x2f880
leaq 0xd6ba1(%rip), %rsi     # 0x1e2e99
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x5f8(%rbp)
jmp 0x10c30d
movq -0x5f8(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x2f780
movq %rax, -0x600(%rbp)
jmp 0x10c329
movq -0x600(%rbp), %rdi
movq 0x1c8c91(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10c33e
movq -0x5c8(%rbp), %rsi
addq $0x17e0, %rsi           # imm = 0x17E0
leaq 0xd6a3e(%rip), %rdx     # 0x1e2d91
leaq -0x328(%rbp), %rdi
callq 0x447b0
jmp 0x10c361
movq -0x5c8(%rbp), %rdi
addq $0x1938, %rdi           # imm = 0x1938
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq %rax, %rdx
leaq -0x308(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x44760
jmp 0x10c390
leaq -0x328(%rbp), %rdi
callq 0x311e8
leaq 0xd6b09(%rip), %rsi     # 0x1e2eac
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x608(%rbp)
jmp 0x10c3b8
movq -0x608(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x2f780
movq %rax, -0x610(%rbp)
jmp 0x10c3d4
movq -0x610(%rbp), %rdi
movq 0x1c8be6(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10c3e9
movl $0x1, -0x330(%rbp)
movq -0x5c8(%rbp), %rcx
movl -0x330(%rbp), %eax
cmpl 0x1620(%rcx), %eax
jg 0x10cc7f
movl $0x0, -0x334(%rbp)
movq -0x5c8(%rbp), %rdi
movl -0x334(%rbp), %eax
movq %rax, -0x618(%rbp)
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x100, %rdi            # imm = 0x100
callq 0x45170
movq %rax, %rcx
movq -0x618(%rbp), %rax
cmpq %rcx, %rax
jae 0x10cc69
movq -0x5c8(%rbp), %rdi
movl -0x330(%rbp), %eax
movl %eax, -0x624(%rbp)
movl -0x334(%rbp), %eax
movl %eax, -0x620(%rbp)
addq $0x15c0, %rdi           # imm = 0x15C0
callq 0x45170
movl -0x624(%rbp), %edi
movl -0x620(%rbp), %esi
movl %eax, %edx
callq 0x17d3a0
movl %eax, -0x61c(%rbp)
jmp 0x10c496
movq -0x5c8(%rbp), %rax
movl -0x61c(%rbp), %ecx
movl %ecx, -0x32c(%rbp)
addq $0x17e0, %rax           # imm = 0x17E0
movq %rax, -0x638(%rbp)
leaq -0x288(%rbp), %rdi
movq %rdi, -0x648(%rbp)
callq 0x2ff30
movq -0x648(%rbp), %rdi
movq %rax, -0x630(%rbp)
callq 0x2ff30
movq -0x638(%rbp), %rdi
movq %rax, -0x640(%rbp)
callq 0x2ff30
movq -0x640(%rbp), %rcx
movq -0x638(%rbp), %rsi
movq -0x630(%rbp), %rdx
addq %rax, %rcx
leaq -0x358(%rbp), %rdi
callq 0x30b40
jmp 0x10c515
leaq -0x2c8(%rbp), %rdi
leaq -0x358(%rbp), %rsi
movq %rsi, -0x658(%rbp)
callq 0x2fd80
movq -0x658(%rbp), %rdi
callq 0x311e8
movq -0x5c8(%rbp), %rdi
addq $0x1908, %rdi           # imm = 0x1908
leaq -0x334(%rbp), %rsi
callq 0xb5dc0
movq %rax, -0x650(%rbp)
jmp 0x10c55e
movq -0x650(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq %rax, -0x680(%rbp)
leaq -0x288(%rbp), %rdi
movq %rdi, -0x678(%rbp)
callq 0x2ff30
movq -0x678(%rbp), %rdi
movq %rax, -0x670(%rbp)
callq 0x2ff30
movq -0x5c8(%rbp), %rdi
movq %rax, -0x668(%rbp)
addq $0x1908, %rdi           # imm = 0x1908
leaq -0x334(%rbp), %rsi
callq 0xb5dc0
movq %rax, -0x660(%rbp)
jmp 0x10c5c5
movq -0x660(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq %rax, %rdi
callq 0x2ff30
movq -0x668(%rbp), %rcx
movq -0x680(%rbp), %rsi
movq -0x670(%rbp), %rdx
addq %rax, %rcx
leaq -0x378(%rbp), %rdi
callq 0x30b40
jmp 0x10c603
leaq -0x2a8(%rbp), %rdi
leaq -0x378(%rbp), %rsi
movq %rsi, -0x6b0(%rbp)
callq 0x2fd80
movq -0x6b0(%rbp), %rdi
callq 0x311e8
movq -0x5c8(%rbp), %rdi
addq $0x1938, %rdi           # imm = 0x1938
movq %rdi, -0x6a0(%rbp)
movl -0x334(%rbp), %eax
movl %eax, %esi
callq 0x449e0
movq %rax, -0x690(%rbp)
leaq -0x288(%rbp), %rdi
movq %rdi, -0x6a8(%rbp)
callq 0x2ff30
movq -0x6a8(%rbp), %rdi
movq %rax, -0x688(%rbp)
callq 0x2ff30
movq -0x6a0(%rbp), %rdi
movq %rax, -0x698(%rbp)
movl -0x334(%rbp), %eax
movl %eax, %esi
callq 0x449e0
movq %rax, %rdi
callq 0x2ff30
movq -0x698(%rbp), %rcx
movq -0x690(%rbp), %rsi
movq -0x688(%rbp), %rdx
addq %rax, %rcx
leaq -0x398(%rbp), %rdi
callq 0x30b40
jmp 0x10c6c1
leaq -0x2e8(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movq %rsi, -0x6b8(%rbp)
callq 0x2fd80
movq -0x6b8(%rbp), %rdi
callq 0x311e8
leaq 0xd532f(%rip), %rsi     # 0x1e1a1d
leaq -0x4b8(%rbp), %rdi
leaq -0x2c8(%rbp), %rdx
callq 0x44240
jmp 0x10c703
leaq 0xd576d(%rip), %rdx     # 0x1e1e77
leaq -0x498(%rbp), %rdi
leaq -0x4b8(%rbp), %rsi
callq 0x441f0
jmp 0x10c71f
movl -0x32c(%rbp), %esi
leaq -0x4d8(%rbp), %rdi
callq 0x17ce40
jmp 0x10c733
leaq -0x478(%rbp), %rdi
leaq -0x498(%rbp), %rsi
leaq -0x4d8(%rbp), %rdx
callq 0x9c7d0
jmp 0x10c74f
leaq 0xd6759(%rip), %rdx     # 0x1e2eaf
leaq -0x458(%rbp), %rdi
leaq -0x478(%rbp), %rsi
callq 0x441f0
jmp 0x10c76b
movq -0x5c8(%rbp), %rax
movl 0x13e8(%rax), %esi
leaq -0x4f8(%rbp), %rdi
callq 0x17e460
jmp 0x10c786
leaq -0x438(%rbp), %rdi
leaq -0x458(%rbp), %rsi
leaq -0x4f8(%rbp), %rdx
callq 0x9c7d0
jmp 0x10c7a2
leaq 0xd6716(%rip), %rdx     # 0x1e2ebf
leaq -0x418(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0x441f0
jmp 0x10c7be
leaq -0x3f8(%rbp), %rdi
leaq -0x418(%rbp), %rsi
leaq -0x2e8(%rbp), %rdx
callq 0x44760
jmp 0x10c7da
leaq 0xd66e4(%rip), %rdx     # 0x1e2ec5
leaq -0x3d8(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x441f0
jmp 0x10c7f6
leaq -0x3b8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x44760
jmp 0x10c812
leaq -0x308(%rbp), %rdi
movq %rdi, -0x6c0(%rbp)
leaq -0x3b8(%rbp), %rsi
movq %rsi, -0x6c8(%rbp)
callq 0x2fd80
movq -0x6c8(%rbp), %rdi
callq 0x311e8
leaq -0x3d8(%rbp), %rdi
callq 0x311e8
leaq -0x3f8(%rbp), %rdi
callq 0x311e8
leaq -0x418(%rbp), %rdi
callq 0x311e8
leaq -0x438(%rbp), %rdi
callq 0x311e8
leaq -0x4f8(%rbp), %rdi
callq 0x311e8
leaq -0x458(%rbp), %rdi
callq 0x311e8
leaq -0x478(%rbp), %rdi
callq 0x311e8
leaq -0x4d8(%rbp), %rdi
callq 0x311e8
leaq -0x498(%rbp), %rdi
callq 0x311e8
leaq -0x4b8(%rbp), %rdi
callq 0x311e8
movq -0x6c0(%rbp), %rsi
leaq 0xd55cf(%rip), %rdx     # 0x1e1e94
leaq -0x538(%rbp), %rdi
callq 0x447b0
jmp 0x10c8d3
movq -0x5c8(%rbp), %rdi
callq 0x8dec0
movl %eax, -0x6cc(%rbp)
jmp 0x10c8e7
movl -0x6cc(%rbp), %esi
leaq -0x558(%rbp), %rdi
callq 0x17e460
jmp 0x10c8fb
leaq -0x518(%rbp), %rdi
leaq -0x538(%rbp), %rsi
leaq -0x558(%rbp), %rdx
callq 0x9c7d0
jmp 0x10c917
leaq -0x308(%rbp), %rdi
leaq -0x518(%rbp), %rsi
movq %rsi, -0x6d8(%rbp)
callq 0x2fd80
movq -0x6d8(%rbp), %rdi
callq 0x311e8
leaq -0x558(%rbp), %rdi
callq 0x311e8
leaq -0x538(%rbp), %rdi
callq 0x311e8
movl -0x32c(%rbp), %esi
leaq -0x598(%rbp), %rdi
callq 0x17ce40
jmp 0x10c969
leaq 0xd775f(%rip), %rdx     # 0x1e40cf
leaq -0x578(%rbp), %rdi
leaq -0x598(%rbp), %rsi
callq 0x441f0
jmp 0x10c985
leaq -0x238(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x2f780
movq %rax, -0x6e0(%rbp)
jmp 0x10c9a1
movq -0x6e0(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x2f780
movq %rax, -0x6e8(%rbp)
jmp 0x10c9bd
movq -0x6e8(%rbp), %rdi
movq 0x1c85fd(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10c9d2
leaq -0x578(%rbp), %rdi
callq 0x311e8
leaq -0x598(%rbp), %rdi
callq 0x311e8
movl -0x334(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x334(%rbp)
jmp 0x10c416
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cdb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cda9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cd13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cce3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x311e8
jmp 0x10cce3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10ccd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cbd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cbc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cbbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cbb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cba5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cb99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cb8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cb81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cb75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x3d8(%rbp), %rdi
callq 0x311e8
leaq -0x3f8(%rbp), %rdi
callq 0x311e8
leaq -0x418(%rbp), %rdi
callq 0x311e8
leaq -0x438(%rbp), %rdi
callq 0x311e8
leaq -0x4f8(%rbp), %rdi
callq 0x311e8
leaq -0x458(%rbp), %rdi
callq 0x311e8
leaq -0x478(%rbp), %rdi
callq 0x311e8
leaq -0x4d8(%rbp), %rdi
callq 0x311e8
leaq -0x498(%rbp), %rdi
callq 0x311e8
leaq -0x4b8(%rbp), %rdi
callq 0x311e8
jmp 0x10ccd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cc18
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x558(%rbp), %rdi
callq 0x311e8
leaq -0x538(%rbp), %rdi
callq 0x311e8
jmp 0x10ccd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10cc5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x578(%rbp), %rdi
callq 0x311e8
leaq -0x598(%rbp), %rdi
callq 0x311e8
jmp 0x10ccd7
jmp 0x10cc6b
movl -0x330(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x330(%rbp)
jmp 0x10c3f3
leaq -0x238(%rbp), %rdi
callq 0x30910
jmp 0x10cc8d
leaq -0x308(%rbp), %rdi
callq 0x311e8
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
leaq -0x2a8(%rbp), %rdi
callq 0x311e8
leaq -0x288(%rbp), %rdi
callq 0x311e8
leaq -0x260(%rbp), %rdi
callq 0x448d0
jmp 0x10cd24
leaq -0x308(%rbp), %rdi
callq 0x311e8
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
leaq -0x2a8(%rbp), %rdi
callq 0x311e8
leaq -0x288(%rbp), %rdi
callq 0x311e8
leaq -0x260(%rbp), %rdi
callq 0x448d0
jmp 0x10cda9
leaq -0x5b8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2f300
jmp 0x10cd36
movq -0x5c8(%rbp), %rsi
movq -0x5d8(%rbp), %rdi
leaq -0x5b8(%rbp), %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0xee5f0
jmp 0x10cd5a
leaq -0x5b8(%rbp), %rdi
callq 0x311e8
leaq -0x238(%rbp), %rdi
callq 0x304f0
leaq -0x38(%rbp), %rdi
callq 0x311e8
movq -0x5d0(%rbp), %rax
addq $0x6f0, %rsp            # imm = 0x6F0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x5b8(%rbp), %rdi
callq 0x311e8
leaq -0x238(%rbp), %rdi
callq 0x304f0
leaq -0x38(%rbp), %rdi
callq 0x311e8
movq -0x240(%rbp), %rdi
callq 0x30170
nopw (%rax,%rax)