// File: /workspace/github_cpp_makefile_star2_O1/richardposner[P]BioNetFit2/src/code/Swarm.cpp
// Function: Swarm::generateBootstrapMaps(std::vector<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>>>>>>>, std::allocator<std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::map<double, unsigned int, std::less<double>, std::allocator<std::pair<double const, unsigned int>>>>>>>>>>>&)
void Swarm::generateBootstrapMaps(vector<map<string, map<string, map<double,unsigned int> > > > &bootStrapMaps) {
	for (unsigned int i = 0; i < options.bootstrap; ++i) {
		//cout << "i: " << i << endl;
		// For each .exp file
		map<string, map<string, map<double, unsigned int> > > maps;
		for (auto dataSet = options.expFiles.begin(); dataSet != options.expFiles.end(); ++dataSet) {
			//cout << "set: " << dataSet->first << endl;
			// For each column
			map<string, map<double, unsigned int> > bsMap;
			for (auto col = dataSet->second->dataCurrent->begin(); col != dataSet->second->dataCurrent->end(); ++col) {
				//cout << "col: " << col->first << endl;
				// Fill the map with 0's
				map<double, unsigned int> colVals;
				for (auto tp = col->second.begin(); tp != col->second.end(); ++tp) {
					//cout << "tp: " << tp->first << endl;
					colVals[tp->first] = 0;
				}

				// Select datapoints at random. If a datapoint is selected,
				// increment it's integer value in the vals map
				for (unsigned int o = 0; o < col->second.size(); ++o) {
					int i;
					if (col->second.size() > 1) {
					  i = rand() % (col->second.size() - 1);
					}
					else
					{
					  i = 0;
					}
					auto it = col->second.begin();
					advance(it, i);
					colVals[it->first] += 1;
					//cout << "chose " << i << " (" << it->first << ")" << endl;
				}

				// Insert this column into the map
				bsMap.insert(pair<string, map<double, unsigned int> >(col->first, colVals));
			}
			// Insert this dataset into the maps set
			maps.insert(pair<string, map<string, map<double, unsigned int> > >(dataSet->first, bsMap));
		}
		// Insert this set of maps into the master set
		bootStrapMaps.push_back(maps);
	}

	/*
	unsigned int setCounter = 1;
	for (auto bsSet = bootStrapMaps.begin(); bsSet != bootStrapMaps.end(); ++bsSet) {
		cout << "Set " << setCounter << endl;
		for (auto dataSet = bsSet->begin(); dataSet != bsSet->end(); ++dataSet) {
			cout << "Dataset " << dataSet->first << endl;
			for (auto col = dataSet->second.begin(); col != dataSet->second.end(); ++col) {
				cout << "Col " << col->first << endl;
				for (auto tp = col->second.begin(); tp != col->second.end(); ++tp) {
					cout << tp->first << " " << tp -> second << endl;
				}
			}
		}
	}
	 */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, 0x20(%rsp)
cmpl $0x0, 0x1638(%rdi)
je 0xa2f30
leaq 0x1568(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x58(%rsp), %rbx
leaq 0xb8(%rsp), %rbp
leaq 0x88(%rsp), %r14
xorl %r15d, %r15d
movq %rdi, 0x18(%rsp)
movl %r15d, 0xc(%rsp)
movl $0x0, 0x60(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x68(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x70(%rsp)
movq %rax, 0x78(%rsp)
movq %rcx, 0x80(%rsp)
movq 0x1578(%rdi), %r12
cmpq 0x10(%rsp), %r12
je 0xa2f01
movl $0x0, 0x30(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x38(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
movq 0x40(%r12), %rax
movq (%rax), %rax
movq 0x18(%rax), %r13
addq $0x8, %rax
cmpq %rax, %r13
je 0xa2e8d
movl $0x0, 0x90(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x98(%rsp)
leaq 0x90(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rax, 0xa8(%rsp)
movq %rcx, 0xb0(%rsp)
movq 0x58(%r13), %r15
leaq 0x48(%r13), %rbx
cmpq %rbx, %r15
je 0xa2db1
leaq 0x20(%r15), %rsi
movq %r14, %rdi
callq 0x667c6
movl $0x0, (%rax)
movq %r15, %rdi
callq 0x22670
movq %rax, %r15
cmpq %rbx, %rax
jne 0xa2d8f
movq 0x68(%r13), %rax
testq %rax, %rax
je 0xa2e1f
xorl %r15d, %r15d
movl $0x0, %edx
cmpq $0x2, %rax
jb 0xa2ddb
callq 0x22230
cltq
movq 0x68(%r13), %rcx
decq %rcx
xorl %edx, %edx
divq %rcx
movq 0x58(%r13), %rax
movslq %edx, %rbx
testl %ebx, %ebx
jle 0xa2e00
movq %rax, %rdi
callq 0x22670
decq %rbx
jne 0xa2de6
jmp 0xa2e02
movq %rax, %rdi
callq 0x22a10
incq %rbx
jne 0xa2df5
addq $0x20, %rax
movq %r14, %rdi
movq %rax, %rsi
callq 0x667c6
incl (%rax)
incl %r15d
movq 0x68(%r13), %rax
cmpq %r15, %rax
ja 0xa2dbd
leaq 0x20(%r13), %rsi
movq %rbp, %rdi
movq %r14, %rdx
callq 0xa8d94
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0xbcedc
leaq 0xd8(%rsp), %rdi
callq 0x464c2
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xa2e6d
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
movq %r14, %rdi
callq 0x464c2
movq %r13, %rdi
callq 0x22670
movq %rax, %r13
movq 0x40(%r12), %rax
movq (%rax), %rax
jmp 0xa2d40
leaq 0x20(%r12), %rsi
movq %rbp, %rdi
leaq 0x28(%rsp), %rdx
callq 0xa8e10
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbcfe4
leaq 0xd8(%rsp), %rdi
callq 0x4643e
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xa2ee1
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x229c0
leaq 0x28(%rsp), %rdi
callq 0x4643e
movq %r12, %rdi
callq 0x22670
movq %rax, %r12
cmpq 0x10(%rsp), %rax
jne 0xa2d11
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0xa8e8c
movl 0xc(%rsp), %r15d
movq %rbx, %rdi
callq 0x463ba
incl %r15d
movq 0x18(%rsp), %rdi
cmpl 0x1638(%rdi), %r15d
jb 0xa2cd4
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xa2f8e
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xa8e64
jmp 0xa2f84
movq %rax, %rbx
jmp 0xa2f84
jmp 0xa2f74
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0xa8de8
jmp 0xa2f77
jmp 0xa2f74
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x464c2
leaq 0x28(%rsp), %rdi
callq 0x4643e
leaq 0x58(%rsp), %rdi
callq 0x463ba
movq %rbx, %rdi
callq 0x23240