// File: lrq3000[P]rfrb/./src/fileHandler.cpp
// Function: FileHandler::estimateStripeSize()
int FileHandler::estimateStripeSize()
{
	//Lambda function, which is done by threads
	auto lambda = [&] (size_t id, size_t size, const float lowEdge, const float highEdge) -> std::vector<int>
	{
		//Initialization
		std::vector<std::pair<size_t, float>> entropies;
		FileReader *me = inFiles.at(id);
		const size_t CHECKS=800;
		int counters[12]={};
		float ent=0;
		std::vector<size_t> adressEdges;
		me->setBlockSize(size);
		const int checkSize = 16;
		me->reset();

		//Initial fill of vector with zero
		for (int i = 0; i < checkSize; ++i)
			entropies.push_back(std::pair<size_t,float>(0,0));

		//While loop until enough adressEdges are found
		size_t outputCounter = 0;
		while (adressEdges.size() < CHECKS)
		{
			size_t edgeCut = 0;
			size_t counter=0;
			size_t edgeAdress=0;
			bool low=false;
			bool high=false;
			do
			{
				if (me->newBlock() == false)
				{
					break;
				}
				if (outputCounter == 0)
				{
					std::string wr = "Thread ";
					wr += std::to_string(id);
					wr += " working ";
					printf("\r%s\t%f%%\t%s",wr.c_str(), static_cast<float>(adressEdges.size())*100.0f/static_cast<float>(CHECKS), me->getRelativePos().c_str());
					fflush(stdout);
				}
				outputCounter = (outputCounter + 1) % 25000;

				//Calculate entropy and check if the edges are good enough
				ent = me->calcEntropyOfCurrentBlock();
				if (ent <= lowEdge)
				{
					if (low == false)
					{
						if (high == true && counter >= checkSize)
						{
							++edgeCut;
						}
						else
						{
							edgeCut = 0;
						}
						low = true;
						high = false;
						edgeAdress = me->getCurrentAdress();
						counter = 0;
					}
					++counter;
				}
				else if (ent >= highEdge)
				{
					if (high == false)
					{
						if (low == true && counter >= checkSize)
						{
							++edgeCut;
						}
						else
						{
							edgeCut = 0;
						}
						high = true;
						low = false;
						edgeAdress = me->getCurrentAdress();
						counter = 0;
					}
					++counter;
				}
				else
				{
					low=false;
					high=false;
					edgeCut=0;
					counter=0;
				}
				if (counter == checkSize && edgeCut == 1)
					++edgeCut;
			} while (edgeCut != 2);

			//found an edge
			if (edgeCut == 2)
			{
				adressEdges.push_back(edgeAdress);
			}
			else //end of file
			{
				break;
			}
		}

		std::string wr = "Thread ";
		wr += std::to_string(id);
		wr += " working ";
		printf("\r%s\t%9d%%",wr.c_str(), 100);
		me->reset();

		//Sorting adress edges to possible stripesizes
		for (size_t i = 1; i < adressEdges.size(); ++i)
		{
			size_t in = (adressEdges.at(i) - adressEdges.at(i-1))/512;
			if (in % 4096 == 0)
				counters[0] += 1;
			else if (in % 2048 == 0)
				counters[1] += 1;
			else if (in % 1024 == 0)
				counters[2] += 1;
			else if (in % 512 == 0)
				counters[3] += 1;
			else if (in % 256 == 0)
				counters[4] += 1;
			else if (in % 128 == 0)
				counters[5] += 1;
			else if (in % 64 == 0)
				counters[6] += 1;
			else if (in % 32 == 0)
				counters[7] += 1;
			else if (in % 16 == 0)
				counters[8] += 1;
			else if (in % 8 == 0)
				counters[9] += 1;
			else if (in % 4 == 0)
				counters[10] += 1;
			else if (in % 2 == 0)
				counters[11] += 1;
		}
		std::vector<int> ret;
		for (int i = 0; i < 12; ++i)
		{
			ret.push_back(counters[i]);
		}
		return ret;
	}; //lambda function end

	//Initialization to run threads with above lambda function
	int stripeSize = -1;
	unsigned int NUM_THREADS = inFiles.size();
	std::cout << "Issuing Stripesize-calculating threads." << std::endl;
	int counters[12]={};

	std::vector<std::vector<int>> results;
	float lowEdge = 0.3f;
	float highEdge = 7.3f;
	int value[12] = {2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
	int index = 0;
	std::vector<std::future<std::vector<int>>> futureResults(inFiles.size());

	//Starting threads
	for (size_t tm = 0; tm < 12; ++tm)
		counters[tm]=0;
	for (size_t i = 0; i < NUM_THREADS; ++i)
	{
		futureResults[i] = std::async(std::launch::async, lambda, i, 512, lowEdge, highEdge);
	}

	//Getting results
	while (results.size() < inFiles.size())
	{
		for (size_t i = 0; i < NUM_THREADS; ++i)
		{
			std::vector<int> res = futureResults.at(i).get();
			results.push_back(res);
		}
	}
	for (unsigned int i=0; i < results.size();++i)
	{
		for (unsigned int j = 0; j < results.at(i).size(); ++j)
		{
			counters[j] += results.at(i).at(j);
		}
	}
	int ff=0;
	for (unsigned int i = 1; i < 12; ++i)
	{
		if (ff < counters[i])
		{
			ff = counters[i];
			index = i;
		}
	}
	//Print the results for the different stripesizes
	stripeSize = value[index];
	if (stripeSize == 2048)
	{
		std::cout << "Not one good block found. Need to abort." << std::endl;
		return -1;
	}
	while (true)
	{
		//Output and ask the user
		std::string answer;
		std::cout << "\nIt's probably:\t" << stripeSize << "KB"<< std::endl;
		std::cout << "It's just with simple heuristics. Would you like to continue with this result?" << std::endl;
		std::cout << "Answer with 'y' for 'yes', 'n' for 'no' or 'h' for 'hint' [y/n/h] ";
		std::getline(std::cin, answer);
		if (answer == "y")
		{
			stripeSize *= 1024;
			break;
		}
		else if (answer == "n")
		{
			std::cout << "With which Stripesize do you wish to continue? [1-1024] (in kB) ";
			std::cin >> stripeSize;
			stripeSize *= 1024;
			break;
		}
		else if (answer == "h")
		{
			int x = 0;
			std::cout << "\nFound possible blocksizes with following values (Higher value means supposable blocksize):\n";
			std::cout << ">1024:\t" << counters[x] << std::endl;
			++x;
			std::cout << "1024:\t" << counters[x] << std::endl;
			++x;
			std::cout << " 512:\t" << counters[x] << std::endl;
			++x;
			std::cout << " 256:\t" << counters[x] << std::endl;
			++x;
			std::cout << " 128:\t" << counters[x] << std::endl;
			++x;
			std::cout << "  64:\t" << counters[x] << std::endl;
			++x;
			std::cout << "  32:\t" << counters[x] << std::endl;
			++x;
			std::cout << "  16:\t" << counters[x] << std::endl;
			++x;
			std::cout << "   8:\t" << counters[x] << std::endl;
			++x;
			std::cout << "   4:\t" << counters[x] << std::endl;
			++x;
			std::cout << "   2:\t" << counters[x] << std::endl;
			++x;
			std::cout << "   1:\t" << counters[x] << std::endl;
			std::cerr << "Use Stripesize with high values. " << std::endl;
			std::cerr << "If automatically estimated Stripesize doesn't work correct. You could try the blocksize with the next lower value!" << std::endl;
			return -1;
		}
	}

	//If accepted, set block size to stripesize
	mStripeSize = stripeSize;
	return stripeSize;
}

// Assembly:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, 0x2c8(%rsp)
movq 0x2c8(%rsp), %rdi
movq %rdi, 0x150(%rsp)
movq %rdi, 0x2c0(%rsp)
movl $0xffffffff, 0x2bc(%rsp) # imm = 0xFFFFFFFF
addq $0x40, %rdi
movq %rdi, 0x158(%rsp)
callq 0x9d50
movl %eax, 0x2b8(%rsp)
movq 0x46e3f(%rip), %rdi     # 0x53fb0
leaq 0x2e20b(%rip), %rsi     # 0x3b383
callq 0x6420
movq %rax, %rdi
movq 0x46de9(%rip), %rsi     # 0x53f70
callq 0x6470
xorps %xmm0, %xmm0
movaps %xmm0, 0x2a0(%rsp)
movaps %xmm0, 0x290(%rsp)
movaps %xmm0, 0x280(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x19180
movq 0x158(%rsp), %rdi
movl $0x3e99999a, 0x264(%rsp) # imm = 0x3E99999A
movl $0x40e9999a, 0x260(%rsp) # imm = 0x40E9999A
movaps 0x2d827(%rip), %xmm0    # 0x3aa00
movaps %xmm0, 0x250(%rsp)
movaps 0x2d808(%rip), %xmm0    # 0x3a9f0
movaps %xmm0, 0x240(%rsp)
movaps 0x2d7e9(%rip), %xmm0    # 0x3a9e0
movaps %xmm0, 0x230(%rsp)
movl $0x0, 0x22c(%rsp)
callq 0x9d50
movq %rax, 0x160(%rsp)
leaq 0x20f(%rsp), %rdi
movq %rdi, 0x168(%rsp)
callq 0x19190
movq 0x160(%rsp), %rsi
movq 0x168(%rsp), %rdx
leaq 0x210(%rsp), %rdi
callq 0x191a0
jmp 0xd24b
leaq 0x20f(%rsp), %rdi
callq 0x19220
movq $0x0, 0x1f0(%rsp)
cmpq $0xc, 0x1f0(%rsp)
jae 0xd2be
movq 0x1f0(%rsp), %rax
movl $0x0, 0x280(%rsp,%rax,4)
movq 0x1f0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1f0(%rsp)
jmp 0xd264
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x20f(%rsp), %rdi
callq 0x19220
jmp 0xde4e
movq $0x0, 0x1e8(%rsp)
movq 0x1e8(%rsp), %rax
movl 0x2b8(%rsp), %ecx
cmpq %rcx, %rax
jae 0xd393
movl $0x200, 0x1d4(%rsp) # imm = 0x200
movq %rsp, %rax
leaq 0x260(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x1d8(%rsp), %rdi
movl $0x1, %esi
leaq 0x2c0(%rsp), %rdx
leaq 0x1e8(%rsp), %rcx
leaq 0x1d4(%rsp), %r8
leaq 0x264(%rsp), %r9
callq 0xde70
jmp 0xd32f
movq 0x1e8(%rsp), %rsi
leaq 0x210(%rsp), %rdi
callq 0x19230
movq %rax, %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x19250
leaq 0x1d8(%rsp), %rdi
callq 0x192a0
movq 0x1e8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1e8(%rsp)
jmp 0xd2ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0xde41
jmp 0xd395
leaq 0x268(%rsp), %rdi
callq 0x192b0
movq 0x150(%rsp), %rdi
movq %rax, 0x148(%rsp)
addq $0x40, %rdi
callq 0x9d50
movq %rax, %rcx
movq 0x148(%rsp), %rax
cmpq %rcx, %rax
jae 0xd491
movq $0x0, 0x1c8(%rsp)
movq 0x1c8(%rsp), %rax
movl 0x2b8(%rsp), %ecx
cmpq %rcx, %rax
jae 0xd48c
movq 0x1c8(%rsp), %rsi
leaq 0x210(%rsp), %rdi
callq 0x192d0
movq %rax, 0x140(%rsp)
jmp 0xd412
movq 0x140(%rsp), %rsi
leaq 0x1b0(%rsp), %rdi
callq 0x19310
jmp 0xd429
leaq 0x268(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x193a0
jmp 0xd440
leaq 0x1b0(%rsp), %rdi
callq 0x19410
movq 0x1c8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c8(%rsp)
jmp 0xd3db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x19410
jmp 0xde41
jmp 0xd395
movl $0x0, 0x1ac(%rsp)
movl 0x1ac(%rsp), %eax
movq %rax, 0x138(%rsp)
leaq 0x268(%rsp), %rdi
callq 0x192b0
movq %rax, %rcx
movq 0x138(%rsp), %rax
cmpq %rcx, %rax
jae 0xd5b0
movl $0x0, 0x1a8(%rsp)
movl 0x1a8(%rsp), %eax
movq %rax, 0x128(%rsp)
movl 0x1ac(%rsp), %eax
movl %eax, %esi
leaq 0x268(%rsp), %rdi
callq 0x19470
movq %rax, 0x130(%rsp)
jmp 0xd506
movq 0x130(%rsp), %rdi
callq 0x194b0
movq %rax, %rcx
movq 0x128(%rsp), %rax
cmpq %rcx, %rax
jae 0xd598
movl 0x1ac(%rsp), %eax
movl %eax, %esi
leaq 0x268(%rsp), %rdi
callq 0x19470
movq %rax, 0x120(%rsp)
jmp 0xd543
movq 0x120(%rsp), %rdi
movl 0x1a8(%rsp), %eax
movl %eax, %esi
callq 0x194d0
movq %rax, 0x118(%rsp)
jmp 0xd563
movq 0x118(%rsp), %rax
movl (%rax), %ecx
movl 0x1a8(%rsp), %eax
addl 0x280(%rsp,%rax,4), %ecx
movl %ecx, 0x280(%rsp,%rax,4)
movl 0x1a8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0xd4d7
jmp 0xd59a
movl 0x1ac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ac(%rsp)
jmp 0xd49c
movl $0x0, 0x1a4(%rsp)
movl $0x1, 0x1a0(%rsp)
cmpl $0xc, 0x1a0(%rsp)
jae 0xd61f
movl 0x1a4(%rsp), %eax
movl 0x1a0(%rsp), %ecx
cmpl 0x280(%rsp,%rcx,4), %eax
jge 0xd60a
movl 0x1a0(%rsp), %eax
movl 0x280(%rsp,%rax,4), %eax
movl %eax, 0x1a4(%rsp)
movl 0x1a0(%rsp), %eax
movl %eax, 0x22c(%rsp)
jmp 0xd60c
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a0(%rsp)
jmp 0xd5c6
movslq 0x22c(%rsp), %rax
movl 0x230(%rsp,%rax,4), %eax
movl %eax, 0x2bc(%rsp)
cmpl $0x800, 0x2bc(%rsp) # imm = 0x800
jne 0xd690
movq 0x46967(%rip), %rdi     # 0x53fb0
leaq 0x2dd5b(%rip), %rsi     # 0x3b3ab
callq 0x6420
movq %rax, 0x110(%rsp)
jmp 0xd65f
movq 0x110(%rsp), %rdi
movq 0x46902(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd675
movl $0xffffffff, 0x2d4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x19c(%rsp)
jmp 0xde18
jmp 0xd692
jmp 0xd694
leaq 0x178(%rsp), %rdi
callq 0x65c0
movq 0x46908(%rip), %rdi     # 0x53fb0
leaq 0x2dd25(%rip), %rsi     # 0x3b3d4
callq 0x6420
movq %rax, 0x108(%rsp)
jmp 0xd6be
movq 0x108(%rsp), %rdi
movl 0x2bc(%rsp), %esi
callq 0x6720
movq %rax, 0x100(%rsp)
jmp 0xd6dc
movq 0x100(%rsp), %rdi
leaq 0x2cc72(%rip), %rsi     # 0x3a35d
callq 0x6420
movq %rax, 0xf8(%rsp)
jmp 0xd6fa
movq 0xf8(%rsp), %rdi
movq 0x46867(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd710
movq 0x46899(%rip), %rdi     # 0x53fb0
leaq 0x2dcc7(%rip), %rsi     # 0x3b3e5
callq 0x6420
movq %rax, 0xf0(%rsp)
jmp 0xd72d
movq 0xf0(%rsp), %rdi
movq 0x46834(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd743
movq 0x46866(%rip), %rdi     # 0x53fb0
leaq 0x2dce3(%rip), %rsi     # 0x3b434
callq 0x6420
jmp 0xd758
movq 0x46879(%rip), %rdi     # 0x53fd8
leaq 0x178(%rsp), %rsi
callq 0x60c0
jmp 0xd76e
leaq 0x2c9ed(%rip), %rsi     # 0x3a162
leaq 0x178(%rsp), %rdi
callq 0x9e10
movb %al, 0xef(%rsp)
jmp 0xd78b
movb 0xef(%rsp), %al
testb $0x1, %al
jne 0xd798
jmp 0xd7df
movl 0x2bc(%rsp), %eax
shll $0xa, %eax
movl %eax, 0x2bc(%rsp)
movl $0x17, 0x19c(%rsp)
jmp 0xddbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x6260
jmp 0xde41
leaq 0x2edc7(%rip), %rsi     # 0x3c5ad
leaq 0x178(%rsp), %rdi
callq 0x9e10
movb %al, 0xee(%rsp)
jmp 0xd7fc
movb 0xee(%rsp), %al
testb $0x1, %al
jne 0xd809
jmp 0xd855
movq 0x467a0(%rip), %rdi     # 0x53fb0
leaq 0x2dc60(%rip), %rsi     # 0x3b477
callq 0x6420
jmp 0xd81e
movq 0x467b3(%rip), %rdi     # 0x53fd8
leaq 0x2bc(%rsp), %rsi
callq 0x6250
jmp 0xd834
movl 0x2bc(%rsp), %eax
shll $0xa, %eax
movl %eax, 0x2bc(%rsp)
movl $0x17, 0x19c(%rsp)
jmp 0xddbd
leaq 0x2ebfb(%rip), %rsi     # 0x3c457
leaq 0x178(%rsp), %rdi
callq 0x9e10
movb %al, 0xed(%rsp)
jmp 0xd872
movb 0xed(%rsp), %al
testb $0x1, %al
jne 0xd882
jmp 0xddae
movl $0x0, 0x174(%rsp)
movq 0x4671c(%rip), %rdi     # 0x53fb0
leaq 0x2dc1d(%rip), %rsi     # 0x3b4b8
callq 0x6420
jmp 0xd8a2
movq 0x46707(%rip), %rdi     # 0x53fb0
leaq 0x2dc65(%rip), %rsi     # 0x3b515
callq 0x6420
movq %rax, 0xe0(%rsp)
jmp 0xd8bf
movq 0xe0(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0xd8(%rsp)
jmp 0xd8e5
movq 0xd8(%rsp), %rdi
movq 0x4667c(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd8fb
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x4669e(%rip), %rdi     # 0x53fb0
leaq 0x2dbfd(%rip), %rsi     # 0x3b516
callq 0x6420
movq %rax, 0xd0(%rsp)
jmp 0xd928
movq 0xd0(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0xc8(%rsp)
jmp 0xd94e
movq 0xc8(%rsp), %rdi
movq 0x46613(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd964
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x46635(%rip), %rdi     # 0x53fb0
leaq 0x2db9b(%rip), %rsi     # 0x3b51d
callq 0x6420
movq %rax, 0xc0(%rsp)
jmp 0xd991
movq 0xc0(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0xb8(%rsp)
jmp 0xd9b7
movq 0xb8(%rsp), %rdi
movq 0x465aa(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xd9cd
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x465cc(%rip), %rdi     # 0x53fb0
leaq 0x2db39(%rip), %rsi     # 0x3b524
callq 0x6420
movq %rax, 0xb0(%rsp)
jmp 0xd9fa
movq 0xb0(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0xa8(%rsp)
jmp 0xda20
movq 0xa8(%rsp), %rdi
movq 0x46541(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xda36
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x46563(%rip), %rdi     # 0x53fb0
leaq 0x2dad7(%rip), %rsi     # 0x3b52b
callq 0x6420
movq %rax, 0xa0(%rsp)
jmp 0xda63
movq 0xa0(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x98(%rsp)
jmp 0xda89
movq 0x98(%rsp), %rdi
movq 0x464d8(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xda9f
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x464fa(%rip), %rdi     # 0x53fb0
leaq 0x2da75(%rip), %rsi     # 0x3b532
callq 0x6420
movq %rax, 0x90(%rsp)
jmp 0xdacc
movq 0x90(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x88(%rsp)
jmp 0xdaf2
movq 0x88(%rsp), %rdi
movq 0x4646f(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdb08
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x46491(%rip), %rdi     # 0x53fb0
leaq 0x2da13(%rip), %rsi     # 0x3b539
callq 0x6420
movq %rax, 0x80(%rsp)
jmp 0xdb35
movq 0x80(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x78(%rsp)
jmp 0xdb58
movq 0x78(%rsp), %rdi
movq 0x4640c(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdb6b
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x4642e(%rip), %rdi     # 0x53fb0
leaq 0x2d9b7(%rip), %rsi     # 0x3b540
callq 0x6420
movq %rax, 0x70(%rsp)
jmp 0xdb95
movq 0x70(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x68(%rsp)
jmp 0xdbb5
movq 0x68(%rsp), %rdi
movq 0x463af(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdbc8
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x463d1(%rip), %rdi     # 0x53fb0
leaq 0x2d961(%rip), %rsi     # 0x3b547
callq 0x6420
movq %rax, 0x60(%rsp)
jmp 0xdbf2
movq 0x60(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x58(%rsp)
jmp 0xdc12
movq 0x58(%rsp), %rdi
movq 0x46352(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdc25
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x46374(%rip), %rdi     # 0x53fb0
leaq 0x2d90b(%rip), %rsi     # 0x3b54e
callq 0x6420
movq %rax, 0x50(%rsp)
jmp 0xdc4f
movq 0x50(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x48(%rsp)
jmp 0xdc6f
movq 0x48(%rsp), %rdi
movq 0x462f5(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdc82
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x46317(%rip), %rdi     # 0x53fb0
leaq 0x2d8b5(%rip), %rsi     # 0x3b555
callq 0x6420
movq %rax, 0x40(%rsp)
jmp 0xdcac
movq 0x40(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x38(%rsp)
jmp 0xdccc
movq 0x38(%rsp), %rdi
movq 0x46298(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdcdf
movl 0x174(%rsp), %eax
incl %eax
movl %eax, 0x174(%rsp)
movq 0x462ba(%rip), %rdi     # 0x53fb0
leaq 0x2d85f(%rip), %rsi     # 0x3b55c
callq 0x6420
movq %rax, 0x30(%rsp)
jmp 0xdd09
movq 0x30(%rsp), %rdi
movslq 0x174(%rsp), %rax
movl 0x280(%rsp,%rax,4), %esi
callq 0x6720
movq %rax, 0x28(%rsp)
jmp 0xdd29
movq 0x28(%rsp), %rdi
movq 0x4623b(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdd3c
movq 0x462ad(%rip), %rdi     # 0x53ff0
leaq 0x2d819(%rip), %rsi     # 0x3b563
callq 0x6420
movq %rax, 0x20(%rsp)
jmp 0xdd56
movq 0x20(%rsp), %rdi
movq 0x4620e(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdd69
movq 0x46280(%rip), %rdi     # 0x53ff0
leaq 0x2d80e(%rip), %rsi     # 0x3b585
callq 0x6420
movq %rax, 0x18(%rsp)
jmp 0xdd83
movq 0x18(%rsp), %rdi
movq 0x461e1(%rip), %rsi     # 0x53f70
callq 0x6470
jmp 0xdd96
movl $0xffffffff, 0x2d4(%rsp) # imm = 0xFFFFFFFF
movl $0x1, 0x19c(%rsp)
jmp 0xddbd
jmp 0xddb0
jmp 0xddb2
movl $0x0, 0x19c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x6260
movl 0x19c(%rsp), %eax
movl %eax, 0x14(%rsp)
testl %eax, %eax
je 0xdde6
jmp 0xdddb
movl 0x14(%rsp), %eax
subl $0x17, %eax
je 0xddeb
jmp 0xde18
jmp 0xd692
movq 0x150(%rsp), %rax
movslq 0x2bc(%rsp), %rcx
movq %rcx, 0x60(%rax)
movl 0x2bc(%rsp), %eax
movl %eax, 0x2d4(%rsp)
movl $0x1, 0x19c(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x19510
leaq 0x268(%rsp), %rdi
callq 0x19570
movl 0x2d4(%rsp), %eax
addq $0x2d8, %rsp            # imm = 0x2D8
retq
leaq 0x210(%rsp), %rdi
callq 0x19510
leaq 0x268(%rsp), %rdi
callq 0x19570
movq 0x200(%rsp), %rdi
callq 0x6750
nopl (%rax,%rax)