// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rsi, %rbx
callq 0x22070
movq %rax, %r14
movl $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq %rbx, 0x28(%rsp)
movq %rbx, %rdi
callq 0x22f10
testq %rax, %rax
je 0x917d9
movq %rax, %r15
leaq 0x50(%rsp), %rbx
leaq 0x70(%rsp), %r12
movl $0x0, (%r14)
movq %r15, %rdi
callq 0x22f90
movq %rax, %rbp
testq %rax, %rax
je 0x917cc
leaq 0x13(%rbp), %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x223a0
leaq (%rax,%rbp), %rdx
addq $0x13, %rdx
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x321d2
movq %rbx, %rdi
leaq 0x6e0cf(%rip), %rsi     # 0xff7af
xorl %edx, %edx
callq 0x3186e
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movb $0x0, 0xa0(%rsp)
leaq 0xa8(%rsp), %rax
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
movb $0x1, 0xbc(%rsp)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
addq %rdi, %rsi
movq %r12, %rdx
movq %rbx, %rcx
movl $0x400, %r8d            # imm = 0x400
callq 0x51e2f
movl %eax, %ebp
movq %r12, %rdi
callq 0x31fe0
leaq 0x58(%rsp), %rdi
callq 0x32268
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9176f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
testb %bpl, %bpl
je 0x91690
leaq 0x80(%rsp), %rbp
movq %rbp, 0x70(%rsp)
movq %r13, %rdi
callq 0x223a0
leaq (%rax,%r13), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x321d2
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x6a2a2
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x91690
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x91690
movq %r15, %rdi
callq 0x23050
jmp 0x91877
movq 0xe47c8(%rip), %rbx     # 0x175fa8
leaq 0x6dffb(%rip), %rsi     # 0xff7e2
movl $0x17, %edx
movq %rbx, %rdi
callq 0x22ab0
movq 0x28(%rsp), %r14
testq %r14, %r14
je 0x9181a
movq %r14, %rdi
callq 0x223a0
movq 0xe479b(%rip), %rdi     # 0x175fa8
movq %r14, %rsi
movq %rax, %rdx
callq 0x22ab0
jmp 0x91831
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x23180
movq 0xe4770(%rip), %rbx     # 0x175fa8
leaq 0x6dfbb(%rip), %rsi     # 0xff7fa
movl $0x26, %edx
movq %rbx, %rdi
callq 0x22ab0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x22940
movsbl %al, %esi
movq 0xe473e(%rip), %rdi     # 0x175fa8
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x30(%rsp), %r13
cmpq 0x38(%rsp), %r13
je 0x919bf
leaq 0x18(%rsp), %rbp
leaq 0x80(%rsp), %r14
leaq 0x50(%rsp), %rbx
leaq 0x6dfb7(%rip), %r15     # 0xff857
leaq 0x8(%rsp), %r12
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x319cc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x233b0
movq %rbp, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x918e5
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x918ec
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %r12, %rdi
callq 0x222b0
movq %r14, 0x70(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x9193a
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x91941
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x78(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x91970
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x9198c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x70(%rsp), %rdi
callq 0x23290
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x919b0
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x229c0
addq $0x20, %r13
cmpq 0x38(%rsp), %r13
jne 0x918a5
leaq 0x30(%rsp), %rdi
callq 0x31a0a
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x91a73
jmp 0x91a73
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x91a76
movq 0x80(%rsp), %rsi
jmp 0x91a69
movq %rax, %rbx
jmp 0x91a1c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x31fe0
leaq 0x58(%rsp), %rdi
callq 0x32268
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x91a76
movq 0x18(%rsp), %rsi
jmp 0x91a69
jmp 0x91a73
jmp 0x91a73
movq %rax, %rbx
jmp 0x91a55
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x91a55
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x91a76
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x91a76
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x31a0a
movq %rbx, %rdi
callq 0x23240