// File: /workspace/github_cpp_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
movq %rsi, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x1568(%rdi), %rax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
leaq 0x68(%rsp), %r14
leaq 0xc8(%rsp), %r12
leaq 0x98(%rsp), %rbp
movq %rdi, 0x18(%rsp)
cmpl 0x1638(%rbx), %eax
jae 0x830f5
movq %rax, 0x10(%rsp)
andl $0x0, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
andq $0x0, 0x90(%rsp)
movq 0x1578(%rbx), %r13
cmpq 0x20(%rsp), %r13
je 0x830d4
andl $0x0, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
leaq 0x20(%r13), %rax
movq %rax, 0x28(%rsp)
movq 0x40(%r13), %rax
movq (%rax), %rax
movq 0x18(%rax), %r15
movq %r13, 0x30(%rsp)
addq $0x8, %rax
cmpq %rax, %r15
je 0x8308b
andl $0x0, 0xa0(%rsp)
andq $0x0, 0xa8(%rsp)
leaq 0xa0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
andq $0x0, 0xc0(%rsp)
leaq 0x20(%r15), %r14
movq 0x58(%r15), %r13
leaq 0x48(%r15), %rbx
cmpq %rbx, %r13
je 0x82fe8
leaq 0x20(%r13), %rsi
movq %rbp, %rdi
callq 0x5a4c8
andl $0x0, (%rax)
movq %r13, %rdi
callq 0x28700
movq %rax, %r13
jmp 0x82fc7
xorl %r13d, %r13d
movl %r13d, %ecx
movq 0x68(%r15), %rax
cmpq %rcx, %rax
jbe 0x83044
xorl %esi, %esi
cmpq $0x2, %rax
jb 0x83015
callq 0x28280
cltq
movq 0x68(%r15), %rcx
decq %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
movq 0x58(%r15), %rax
movq %rax, 0xc8(%rsp)
movq %r12, %rdi
callq 0x86a98
movq 0xc8(%rsp), %rsi
addq $0x20, %rsi
movq %rbp, %rdi
callq 0x5a4c8
incl (%rax)
incl %r13d
jmp 0x82feb
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x86aa0
leaq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x9cfe0
movq %r12, %rdi
callq 0x86ad6
movq %rbp, %rdi
callq 0x45f7c
movq %r15, %rdi
callq 0x28700
movq %rax, %r15
movq 0x30(%rsp), %r13
movq 0x40(%r13), %rax
movq (%rax), %rax
jmp 0x82f7c
movq %r12, %rdi
movq 0x28(%rsp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x86aec
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x9d0b2
movq %r12, %rdi
callq 0x86b22
leaq 0x38(%rsp), %rdi
callq 0x45f02
movq %r13, %rdi
callq 0x28700
movq %rax, %r13
movq 0x18(%rsp), %rbx
jmp 0x82f38
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x86b38
movq %r14, %rdi
callq 0x45e88
movq 0x10(%rsp), %rax
incl %eax
jmp 0x82ef7
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x83153
movq %rax, %rbx
jmp 0x83149
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x86b22
jmp 0x83149
jmp 0x83139
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x86ad6
jmp 0x8313c
jmp 0x83139
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x45f7c
leaq 0x38(%rsp), %rdi
callq 0x45f02
leaq 0x68(%rsp), %rdi
callq 0x45e88
movq %rbx, %rdi
callq 0x292f0
nop