// File: richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::checkExternalMessages()
void Swarm::checkExternalMessages() {
	string messagePath = options.jobOutputDir + ".req";
	if (checkIfFileExists(messagePath)) {
		ifstream messageFile(messagePath);

		std::string line;

		if (messageFile.is_open()) {
			while (getline(messageFile, line)) {
				if (line == "output results") {
					string outputDir = options.jobOutputDir + "Results";
					string command = "mkdir " + outputDir + " && cp " + configPath_ + " " + outputDir;

					int errorCounter = 0;
					while (!runCommand(command) && errorCounter < 10) {
						//sleep(1);
						++errorCounter;
					}

					if (errorCounter > 10) {
						cout << "Error: Couldn't create directory: " + outputDir + " to contain final fitting results. Outputting results to screen.";
						outputRunSummary();
					}

					outputRunSummary(outputDir);
				}
			}
		}
		else {
			string errMsg = "Error: Couldn't open data file " + messagePath + " for parsing.";
			outputError(errMsg);
		}
		messageFile.close();
		string delCmd = "rm " + messagePath;
		runCommand(delCmd);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x478(%rbp)
addq $0x1520, %rsi           # imm = 0x1520
leaq 0xd753a(%rip), %rdx     # 0x1e2d12
leaq -0x28(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x447b0
movq -0x470(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2f300
jmp 0x10b7fa
leaq -0x48(%rbp), %rdi
callq 0x17d410
movl %eax, -0x47c(%rbp)
jmp 0x10b80b
leaq -0x48(%rbp), %rdi
callq 0x311e8
movl -0x47c(%rbp), %eax
cmpl $0x0, %eax
je 0x10be21
leaq -0x260(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x8, %edx
callq 0x30d80
jmp 0x10b83a
leaq -0x280(%rbp), %rdi
callq 0x2f880
leaq -0x260(%rbp), %rdi
callq 0x30980
movb %al, -0x47d(%rbp)
jmp 0x10b85a
movb -0x47d(%rbp), %al
testb $0x1, %al
jne 0x10b869
jmp 0x10bc80
jmp 0x10b86b
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x2fcb0
movq %rax, -0x488(%rbp)
jmp 0x10b887
movq -0x488(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2f8e0
movb %al, -0x489(%rbp)
jmp 0x10b8a5
movb -0x489(%rbp), %al
testb $0x1, %al
jne 0x10b8b4
jmp 0x10bc7b
leaq 0xd745c(%rip), %rsi     # 0x1e2d17
leaq -0x280(%rbp), %rdi
callq 0x44930
movb %al, -0x48a(%rbp)
jmp 0x10b8cf
movb -0x48a(%rbp), %al
testb $0x1, %al
jne 0x10b8de
jmp 0x10bc76
movq -0x478(%rbp), %rsi
addq $0x1520, %rsi           # imm = 0x1520
leaq 0xd6c04(%rip), %rdx     # 0x1e24f7
leaq -0x2a0(%rbp), %rdi
callq 0x447b0
jmp 0x10b901
leaq 0xcee8f(%rip), %rsi     # 0x1da797
leaq -0x340(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0x44240
jmp 0x10b91d
leaq 0xd6a31(%rip), %rdx     # 0x1e2355
leaq -0x320(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x441f0
jmp 0x10b939
movq -0x478(%rbp), %rdx
addq $0x1800, %rdx           # imm = 0x1800
leaq -0x300(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x44760
jmp 0x10b95c
leaq 0xd876c(%rip), %rdx     # 0x1e40cf
leaq -0x2e0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x441f0
jmp 0x10b978
leaq -0x2c0(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
leaq -0x2a0(%rbp), %rdx
callq 0x44760
jmp 0x10b994
leaq -0x2e0(%rbp), %rdi
callq 0x311e8
leaq -0x300(%rbp), %rdi
callq 0x311e8
leaq -0x320(%rbp), %rdi
callq 0x311e8
leaq -0x340(%rbp), %rdi
callq 0x311e8
movl $0x0, -0x344(%rbp)
leaq -0x368(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
callq 0x2f300
jmp 0x10b9e3
leaq -0x368(%rbp), %rdi
callq 0x17e3f0
movl %eax, -0x490(%rbp)
jmp 0x10b9f7
movl -0x490(%rbp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x491(%rbp)
jne 0x10ba1a
cmpl $0xa, -0x344(%rbp)
setl %al
movb %al, -0x491(%rbp)
movb -0x491(%rbp), %al
movb %al, -0x492(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x311e8
movb -0x492(%rbp), %al
testb $0x1, %al
jne 0x10ba41
jmp 0x10bb3b
movl -0x344(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x344(%rbp)
jmp 0x10b9ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10be33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x311e8
jmp 0x10be33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10be07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bc65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bafc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10baf0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bae4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x311e8
leaq -0x300(%rbp), %rdi
callq 0x311e8
leaq -0x320(%rbp), %rdi
callq 0x311e8
leaq -0x340(%rbp), %rdi
callq 0x311e8
jmp 0x10bc65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bc59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x311e8
jmp 0x10bc59
cmpl $0xa, -0x344(%rbp)
jle 0x10bbf1
leaq 0xd680e(%rip), %rsi     # 0x1e235d
leaq -0x3a8(%rbp), %rdi
leaq -0x2a0(%rbp), %rdx
callq 0x44240
jmp 0x10bb64
leaq 0xd68c3(%rip), %rdx     # 0x1e242e
leaq -0x388(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x441f0
jmp 0x10bb80
movq 0x1c93c9(%rip), %rdi    # 0x2d4f50
leaq -0x388(%rbp), %rsi
callq 0x2f780
jmp 0x10bb95
leaq -0x388(%rbp), %rdi
callq 0x311e8
leaq -0x3a8(%rbp), %rdi
callq 0x311e8
movq -0x478(%rbp), %rdi
callq 0x108770
jmp 0x10bbbb
jmp 0x10bbf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bbe3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x311e8
leaq -0x3a8(%rbp), %rdi
callq 0x311e8
jmp 0x10bc59
leaq -0x3c8(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x2f300
jmp 0x10bc06
movq -0x478(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0x105530
jmp 0x10bc1b
leaq -0x3c8(%rbp), %rdi
callq 0x311e8
leaq -0x2c0(%rbp), %rdi
callq 0x311e8
leaq -0x2a0(%rbp), %rdi
callq 0x311e8
jmp 0x10bc76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x311e8
leaq -0x2c0(%rbp), %rdi
callq 0x311e8
leaq -0x2a0(%rbp), %rdi
callq 0x311e8
jmp 0x10be07
jmp 0x10b86b
jmp 0x10bd59
leaq 0xcd80b(%rip), %rsi     # 0x1d9492
leaq -0x408(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x44240
jmp 0x10bc99
leaq 0xc7c97(%rip), %rdx     # 0x1d3937
leaq -0x3e8(%rbp), %rdi
leaq -0x408(%rbp), %rsi
callq 0x441f0
jmp 0x10bcb5
leaq -0x408(%rbp), %rdi
callq 0x311e8
leaq -0x428(%rbp), %rdi
leaq -0x3e8(%rbp), %rsi
callq 0x2f300
jmp 0x10bcd6
movq -0x478(%rbp), %rdi
leaq -0x428(%rbp), %rsi
callq 0xeada0
jmp 0x10bceb
leaq -0x428(%rbp), %rdi
callq 0x311e8
leaq -0x3e8(%rbp), %rdi
callq 0x311e8
jmp 0x10bd59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x408(%rbp), %rdi
callq 0x311e8
jmp 0x10be07
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bd48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x428(%rbp), %rdi
callq 0x311e8
leaq -0x3e8(%rbp), %rdi
callq 0x311e8
jmp 0x10be07
leaq -0x260(%rbp), %rdi
callq 0x300d0
jmp 0x10bd67
leaq 0xc8446(%rip), %rsi     # 0x1d41b4
leaq -0x448(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x44240
jmp 0x10bd80
leaq -0x468(%rbp), %rdi
leaq -0x448(%rbp), %rsi
callq 0x2f300
jmp 0x10bd95
leaq -0x468(%rbp), %rdi
callq 0x17e3f0
jmp 0x10bda3
leaq -0x468(%rbp), %rdi
callq 0x311e8
leaq -0x448(%rbp), %rdi
callq 0x311e8
leaq -0x280(%rbp), %rdi
callq 0x311e8
leaq -0x260(%rbp), %rdi
callq 0x2f0e0
jmp 0x10be21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x10bdfb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x311e8
leaq -0x448(%rbp), %rdi
callq 0x311e8
leaq -0x280(%rbp), %rdi
callq 0x311e8
leaq -0x260(%rbp), %rdi
callq 0x2f0e0
jmp 0x10be33
leaq -0x28(%rbp), %rdi
callq 0x311e8
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x311e8
movq -0x50(%rbp), %rdi
callq 0x30170
nopw %cs:(%rax,%rax)