// File: /workspace/github_cpp_makefile_star2_O1/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 0x920f7
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 0x920ea
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 0x32210
movq %rbx, %rdi
leaq 0x6d741(%rip), %rsi     # 0xff73f
xorl %edx, %edx
callq 0x31902
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 0x52123
movl %eax, %ebp
movq %r12, %rdi
callq 0x32024
leaq 0x58(%rsp), %rdi
callq 0x322a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9208d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
testb %bpl, %bpl
je 0x91fae
leaq 0x80(%rsp), %rbp
movq %rbp, 0x70(%rsp)
movq %r13, %rdi
callq 0x223a0
leaq (%rax,%r13), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x32210
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x6a77e
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x91fae
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x91fae
movq %r15, %rdi
callq 0x23050
jmp 0x92195
movq 0xe3e92(%rip), %rbx     # 0x175f90
leaq 0x6d66d(%rip), %rsi     # 0xff772
movl $0x17, %edx
movq %rbx, %rdi
callq 0x22ab0
movq 0x28(%rsp), %r14
testq %r14, %r14
je 0x92138
movq %r14, %rdi
callq 0x223a0
movq 0xe3e65(%rip), %rdi     # 0x175f90
movq %r14, %rsi
movq %rax, %rdx
callq 0x22ab0
jmp 0x9214f
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x23180
movq 0xe3e3a(%rip), %rbx     # 0x175f90
leaq 0x6d62d(%rip), %rsi     # 0xff78a
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 0xe3e08(%rip), %rdi     # 0x175f90
callq 0x22050
movq %rax, %rdi
callq 0x22660
movq 0x30(%rsp), %r13
cmpq 0x38(%rsp), %r13
je 0x922dd
leaq 0x18(%rsp), %rbp
leaq 0x80(%rsp), %r14
leaq 0x50(%rsp), %rbx
leaq 0x6d629(%rip), %r15     # 0xff7e7
leaq 0x8(%rsp), %r12
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
leaq 0x7(%rsp), %rdx
callq 0x31a60
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 0x92203
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x9220a
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 0x92258
movq %rdx, 0x70(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x80(%rsp)
jmp 0x9225f
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 0x9228e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x922aa
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x70(%rsp), %rdi
callq 0x23290
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x922ce
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x229c0
addq $0x20, %r13
cmpq 0x38(%rsp), %r13
jne 0x921c3
leaq 0x30(%rsp), %rdi
callq 0x31a9e
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x92391
jmp 0x92391
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %rbp, %rdi
je 0x92394
movq 0x80(%rsp), %rsi
jmp 0x92387
movq %rax, %rbx
jmp 0x9233a
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x32024
leaq 0x58(%rsp), %rdi
callq 0x322a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x92394
movq 0x18(%rsp), %rsi
jmp 0x92387
jmp 0x92391
jmp 0x92391
movq %rax, %rbx
jmp 0x92373
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x92373
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x229c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x92394
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x229c0
jmp 0x92394
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x31a9e
movq %rbx, %rdi
callq 0x23240