// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateTorqueBatchScript(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string Swarm::generateTorqueBatchScript(string cmd) {
	string batchScriptPath = options.jobOutputDir + "batch_script.sh";
	ofstream batchScript(batchScriptPath, ios::out);

	if (batchScript.is_open()) {
		batchScript << "#!/bin/bash" << endl << endl;

		batchScript << "#PBS -N " << options.jobName << endl;

		if (options.saveClusterOutput) {
			batchScript << "#PBS -o " + options.outputDir + "/" + options.jobName + "_cluster_output/" + options.jobName << endl;
			batchScript << "#PBS -j oe" << endl;
		}
		else {
			batchScript << "#PBS -o /dev/null" << endl;
		}

		if (!options.clusterQueue.empty()) {
			batchScript << "#PBS -p	" + options.clusterQueue << endl;
		}

		// Specify the cluster account if needed
		if (!options.clusterAccount.empty()) {
			batchScript << "#PBS -A " + options.clusterAccount << endl;
		}

		batchScript << "#PBS -l procs=" << options.swarmSize + 1 << ",";

		//if (options.maxFitTime != MAX_LONG) {
		//	batchScript << " walltime=00:00:" << toString(options.maxFitTime) << ",";
		//}
		if (!options.maxFitTime.empty()) { //Raquel fixed torque support
			batchScript << " walltime=" << options.maxFitTime << ","; //Raquel fixed torque support
		}

		batchScript << endl << endl;

		cout<<"Swarm::generateTorqueBatchScript Might need some modifications ....642\n";
		batchScript << "mpirun -np1" << cmd << " load " << sConf_[0] << " : cmd ";
		batchScript.close();
	}

	return cmd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movq %rdx, -0x350(%rbp)
movq %rdi, -0x348(%rbp)
movq %rdi, %rax
movq %rax, -0x340(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0x338(%rbp)
addq $0x1520, %rsi           # imm = 0x1520
leaq 0xd60b3(%rip), %rdx     # 0x1e2ecb
leaq -0x38(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x447b0
movq -0x330(%rbp), %rsi
leaq -0x238(%rbp), %rdi
movl $0x10, %edx
callq 0x2f360
jmp 0x10ce42
leaq -0x238(%rbp), %rdi
callq 0x30530
movb %al, -0x351(%rbp)
jmp 0x10ce56
movb -0x351(%rbp), %al
testb $0x1, %al
jne 0x10ce65
jmp 0x10d467
leaq 0xd606f(%rip), %rsi     # 0x1e2edb
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x360(%rbp)
jmp 0x10ce81
movq -0x360(%rbp), %rdi
movq 0x1c8139(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
movq %rax, -0x368(%rbp)
jmp 0x10ce9d
movq -0x368(%rbp), %rdi
movq 0x1c811d(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10ceb2
leaq 0xd602e(%rip), %rsi     # 0x1e2ee7
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x370(%rbp)
jmp 0x10cece
movq -0x370(%rbp), %rdi
movq -0x338(%rbp), %rsi
addq $0x14c0, %rsi           # imm = 0x14C0
callq 0x2f780
movq %rax, -0x378(%rbp)
jmp 0x10cef1
movq -0x378(%rbp), %rdi
movq 0x1c80c9(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10cf06
movq -0x338(%rbp), %rax
testb $0x1, 0x1770(%rax)
je 0x10d12f
movq -0x338(%rbp), %rdx
addq $0x1500, %rdx           # imm = 0x1500
leaq 0xd5fc1(%rip), %rsi     # 0x1e2ef0
leaq -0x2e8(%rbp), %rdi
callq 0x44240
jmp 0x10cf3d
leaq 0xd540f(%rip), %rdx     # 0x1e2353
leaq -0x2c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x441f0
jmp 0x10cf59
movq -0x338(%rbp), %rdx
addq $0x14c0, %rdx           # imm = 0x14C0
leaq -0x2a8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x44760
jmp 0x10cf7c
leaq 0xd5e5d(%rip), %rdx     # 0x1e2de0
leaq -0x288(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x441f0
jmp 0x10cf98
movq -0x338(%rbp), %rdx
addq $0x14c0, %rdx           # imm = 0x14C0
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x44760
jmp 0x10cfbb
leaq -0x238(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x2f780
movq %rax, -0x380(%rbp)
jmp 0x10cfd7
movq -0x380(%rbp), %rdi
movq 0x1c7fe3(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10cfec
leaq -0x268(%rbp), %rdi
callq 0x311e8
leaq -0x288(%rbp), %rdi
callq 0x311e8
leaq -0x2a8(%rbp), %rdi
callq 0x311e8
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
leaq 0xd5eca(%rip), %rsi     # 0x1e2ef9
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x388(%rbp)
jmp 0x10d044
movq -0x388(%rbp), %rdi
movq 0x1c7f76(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10d059
jmp 0x10d162
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d4ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d49f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d11e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d106
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x10d0fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x311e8
leaq -0x288(%rbp), %rdi
callq 0x311e8
leaq -0x2a8(%rbp), %rdi
callq 0x311e8
leaq -0x2c8(%rbp), %rdi
callq 0x311e8
leaq -0x2e8(%rbp), %rdi
callq 0x311e8
jmp 0x10d49f
leaq 0xd5dce(%rip), %rsi     # 0x1e2f04
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x390(%rbp)
jmp 0x10d14b
movq -0x390(%rbp), %rdi
movq 0x1c7e6f(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10d160
jmp 0x10d162
movq -0x338(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x2b8, %rdi            # imm = 0x2B8
callq 0x2f700
testb $0x1, %al
jne 0x10d209
movq -0x338(%rbp), %rdx
addq $0x1778, %rdx           # imm = 0x1778
leaq 0xd5d7d(%rip), %rsi     # 0x1e2f16
leaq -0x308(%rbp), %rdi
callq 0x44240
jmp 0x10d1a7
leaq -0x238(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x2f780
movq %rax, -0x398(%rbp)
jmp 0x10d1c3
movq -0x398(%rbp), %rdi
movq 0x1c7df7(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10d1d8
leaq -0x308(%rbp), %rdi
callq 0x311e8
jmp 0x10d209
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x311e8
jmp 0x10d49f
movq -0x338(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x290, %rdi            # imm = 0x290
callq 0x2f700
testb $0x1, %al
jne 0x10d2b0
movq -0x338(%rbp), %rdx
addq $0x1750, %rdx           # imm = 0x1750
leaq 0xd5cdf(%rip), %rsi     # 0x1e2f1f
leaq -0x328(%rbp), %rdi
callq 0x44240
jmp 0x10d24e
leaq -0x238(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x2f780
movq %rax, -0x3a0(%rbp)
jmp 0x10d26a
movq -0x3a0(%rbp), %rdi
movq 0x1c7d50(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10d27f
leaq -0x328(%rbp), %rdi
callq 0x311e8
jmp 0x10d2b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x311e8
jmp 0x10d49f
leaq 0xd5c71(%rip), %rsi     # 0x1e2f28
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x3a8(%rbp)
jmp 0x10d2cc
movq -0x3a8(%rbp), %rdi
movq -0x338(%rbp), %rax
movl 0x1620(%rax), %esi
incl %esi
callq 0x2f800
movq %rax, -0x3b0(%rbp)
jmp 0x10d2f0
movq -0x3b0(%rbp), %rdi
leaq 0xcd312(%rip), %rsi     # 0x1da610
callq 0x2ff50
jmp 0x10d305
movq -0x338(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0x1a0, %rdi            # imm = 0x1A0
callq 0x2f700
testb $0x1, %al
jne 0x10d379
leaq 0xd5c0d(%rip), %rsi     # 0x1e2f37
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x3b8(%rbp)
jmp 0x10d33f
movq -0x3b8(%rbp), %rdi
movq -0x338(%rbp), %rsi
addq $0x1660, %rsi           # imm = 0x1660
callq 0x2f780
movq %rax, -0x3c0(%rbp)
jmp 0x10d362
movq -0x3c0(%rbp), %rdi
leaq 0xcd2a0(%rip), %rsi     # 0x1da610
callq 0x2ff50
jmp 0x10d377
jmp 0x10d379
movq 0x1c7c48(%rip), %rsi    # 0x2d4fc8
leaq -0x238(%rbp), %rdi
callq 0x30c10
movq %rax, -0x3c8(%rbp)
jmp 0x10d395
movq -0x3c8(%rbp), %rdi
movq 0x1c7c25(%rip), %rsi    # 0x2d4fc8
callq 0x30c10
jmp 0x10d3aa
movq 0x1c7b9f(%rip), %rdi    # 0x2d4f50
leaq 0xd5b8a(%rip), %rsi     # 0x1e2f42
callq 0x2ff50
jmp 0x10d3bf
leaq 0xd5bc4(%rip), %rsi     # 0x1e2f8a
leaq -0x238(%rbp), %rdi
callq 0x2ff50
movq %rax, -0x3d0(%rbp)
jmp 0x10d3db
movq -0x350(%rbp), %rsi
movq -0x3d0(%rbp), %rdi
callq 0x2f780
movq %rax, -0x3d8(%rbp)
jmp 0x10d3f7
movq -0x3d8(%rbp), %rdi
leaq 0xd5b91(%rip), %rsi     # 0x1e2f96
callq 0x2ff50
movq %rax, -0x3e0(%rbp)
jmp 0x10d413
movq -0x338(%rbp), %rdi
addq $0x1938, %rdi           # imm = 0x1938
xorl %eax, %eax
movl %eax, %esi
callq 0x449e0
movq -0x3e0(%rbp), %rdi
movq %rax, %rsi
callq 0x2f780
movq %rax, -0x3e8(%rbp)
jmp 0x10d442
movq -0x3e8(%rbp), %rdi
leaq 0xd5b4d(%rip), %rsi     # 0x1e2f9d
callq 0x2ff50
jmp 0x10d457
leaq -0x238(%rbp), %rdi
callq 0x30910
jmp 0x10d465
jmp 0x10d467
movq -0x350(%rbp), %rsi
movq -0x348(%rbp), %rdi
callq 0x30940
leaq -0x238(%rbp), %rdi
callq 0x304f0
leaq -0x38(%rbp), %rdi
callq 0x311e8
movq -0x340(%rbp), %rax
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
leaq -0x238(%rbp), %rdi
callq 0x304f0
leaq -0x38(%rbp), %rdi
callq 0x311e8
movq -0x240(%rbp), %rdi
callq 0x30170