// File: 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
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x1c0(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x1638(%rcx), %eax
jae 0x11a190
leaq -0x48(%rbp), %rdi
callq 0x124c00
movq -0x1c0(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0xa0, %rdi
callq 0x45540
movq %rax, -0x50(%rbp)
movq -0x1c0(%rbp), %rdi
addq $0x14c0, %rdi           # imm = 0x14C0
addq $0xa0, %rdi
callq 0x455a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x45570
testb $0x1, %al
jne 0x119d96
jmp 0x11a14d
leaq -0x88(%rbp), %rdi
callq 0xca150
leaq -0x50(%rbp), %rdi
callq 0x45950
movq 0x20(%rax), %rax
movq (%rax), %rdi
callq 0x8e350
movq %rax, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x45950
movq 0x20(%rax), %rax
movq (%rax), %rdi
callq 0x8e3b0
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x8e380
testb $0x1, %al
jne 0x119df6
jmp 0x11a08d
leaq -0xc8(%rbp), %rdi
callq 0xcae50
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x8e4e0
movq %rax, -0xd0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x8e540
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x8e510
testb $0x1, %al
jne 0x119e59
jmp 0x119eaf
leaq -0xd0(%rbp), %rdi
callq 0x8e590
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0xb4170
movq %rax, -0x1c8(%rbp)
jmp 0x119e7d
movq -0x1c8(%rbp), %rax
movl $0x0, (%rax)
leaq -0xd0(%rbp), %rdi
callq 0x8e5e0
jmp 0x119e21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x11a07c
movl $0x0, -0xe8(%rbp)
movl -0xe8(%rbp), %eax
movq %rax, -0x1d0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x124c20
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
cmpq %rcx, %rax
jae 0x119fd5
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x124c20
cmpq $0x1, %rax
jbe 0x119f52
callq 0x30b00
cltq
movq %rax, -0x1d8(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x124c20
movq %rax, %rcx
movq -0x1d8(%rbp), %rax
subq $0x1, %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, -0xec(%rbp)
jmp 0x119f5c
movl $0x0, -0xec(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rdi
addq $0x20, %rdi
callq 0x8e4e0
movq %rax, -0xf8(%rbp)
movl -0xec(%rbp), %esi
leaq -0xf8(%rbp), %rdi
callq 0x124c40
jmp 0x119f8f
leaq -0xf8(%rbp), %rdi
callq 0x8e590
movq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0xb4170
movq %rax, -0x1e0(%rbp)
jmp 0x119fb3
movq -0x1e0(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x119eb9
leaq -0x90(%rbp), %rdi
callq 0x8e4c0
movq %rax, %rsi
leaq -0x148(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x124cd0
jmp 0x119ff9
leaq -0x88(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x124c90
movb %dl, -0x1e9(%rbp)
movq %rax, -0x1e8(%rbp)
jmp 0x11a01b
movb -0x1e9(%rbp), %al
movq -0x1e8(%rbp), %rcx
movq %rcx, -0x158(%rbp)
movb %al, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x124d30
leaq -0xc8(%rbp), %rdi
callq 0x84630
leaq -0x90(%rbp), %rdi
callq 0x8e6f0
jmp 0x119dbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x124d30
leaq -0xc8(%rbp), %rdi
callq 0x84630
jmp 0x11a13f
leaq -0x50(%rbp), %rdi
callq 0x45950
movq %rax, %rsi
leaq -0x1a8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x124da0
jmp 0x11a0ae
leaq -0x48(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x124d60
movb %dl, -0x1f9(%rbp)
movq %rax, -0x1f8(%rbp)
jmp 0x11a0cd
movb -0x1f9(%rbp), %al
movq -0x1f8(%rbp), %rcx
movq %rcx, -0x1b8(%rbp)
movb %al, -0x1b0(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x124e00
leaq -0x88(%rbp), %rdi
callq 0x84370
leaq -0x50(%rbp), %rdi
callq 0x459b0
jmp 0x119d62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
jmp 0x11a13f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x124e00
leaq -0x88(%rbp), %rdi
callq 0x84370
jmp 0x11a185
movq -0x10(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x124e30
jmp 0x11a15c
leaq -0x48(%rbp), %rdi
callq 0x840b0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x119d25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xe0(%rbp)
movl %eax, -0xe4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x840b0
jmp 0x11a199
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x30170
nopw %cs:(%rax,%rax)