// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::cleanupFiles(char const*)
void Swarm::cleanupFiles(const char * path) {
	// TODO: Should we fork to do this? ...yes.
	DIR* dp;
	dirent* de;
	errno = 0;

	vector<string> filesToDel;

	dp = opendir(path);

	if (dp)
	{
		while (true)
		{
			//cout << "about to readdir" << endl;
			errno = 0;
			de = readdir( dp );
			if (de == NULL) break;
			//cout << "read " << de->d_name << endl;
			if (boost::regex_match(string( de->d_name ),boost::regex(".+xml$|.+species$|.+cdat$|.+gdat$|.+net$|.+BNG_OUT"))) {
				//cout << "found a file";
				filesToDel.push_back( string(de->d_name) );
			}
		}
		closedir( dp );
	}
	else {
		cout << "Warning: Couldn't open " << path << " to delete un-needed simulation files." << endl;
	}

	//for (auto i: filesToDel) {
	for (auto i = filesToDel.begin(); i != filesToDel.end(); ++i) {
		string fullPath = string(path) + "/" + *i;
		remove(fullPath.c_str());
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
callq 0x28070
movq %rax, %r14
andl $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
callq 0x28f80
testq %rax, %rax
je 0x792c2
movq %rax, %r15
leaq 0x48(%rsp), %r13
leaq 0x28(%rsp), %rbp
andl $0x0, (%r14)
movq %r15, %rdi
callq 0x29000
movq %rax, %rbx
testq %rax, %rax
je 0x792b8
addq $0x13, %rbx
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x68(%rsp), %rdx
callq 0x33402
movq %rbp, %rdi
leaq 0x646ad(%rip), %rsi     # 0xdd90f
xorl %edx, %edx
callq 0x33278
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x4e785
movl %eax, %r12d
leaq 0x30(%rsp), %rdi
callq 0x33e80
movq %r13, %rdi
callq 0x295a0
testb %r12b, %r12b
je 0x79230
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x33402
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x5ec8c
movq %r13, %rdi
callq 0x295a0
jmp 0x79230
movq %r15, %rdi
callq 0x290e0
jmp 0x792f9
movq 0xecccf(%rip), %rdi     # 0x165f98
leaq 0x64672(%rip), %rsi     # 0xdd942
callq 0x289f0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x289f0
leaq 0x64671(%rip), %rsi     # 0xdd95a
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x10(%rsp), %r14
leaq 0x68(%rsp), %r15
leaq 0x7(%rsp), %r12
leaq 0x646a8(%rip), %r13     # 0xdd9b7
leaq 0x28(%rsp), %rbp
leaq 0x48(%rsp), %rbx
cmpq 0x18(%rsp), %r14
je 0x79374
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x33402
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x3336c
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x334ce
movq %rbp, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x295a0
movq 0x48(%rsp), %rdi
callq 0x29340
movq %rbx, %rdi
callq 0x295a0
addq $0x20, %r14
jmp 0x79319
leaq 0x10(%rsp), %rdi
callq 0x3355a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x793b3
jmp 0x793b3
jmp 0x79396
movq %rax, %rbx
jmp 0x793a8
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x33e80
leaq 0x48(%rsp), %rdi
jmp 0x793cf
jmp 0x793b3
jmp 0x793b3
movq %rax, %rbx
jmp 0x793d4
movq %rax, %rbx
jmp 0x793ca
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x295a0
leaq 0x68(%rsp), %rdi
callq 0x295a0
leaq 0x10(%rsp), %rdi
callq 0x3355a
movq %rbx, %rdi
callq 0x292f0