// File: /workspace/github_cpp_makefile_star2_O1/EnderGed[P]fast-random-walk/WeightedGraph.cpp
// Function: WeightedGraph::readGraph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)
WeightedGraph WeightedGraph::readGraph(std::string const input, uint64_t const flags)
{
	bool isSorted = true;
	read_t numRows;
	uint * data;

	////	Read from file	////
	{
		char const * fileContent = input.c_str();
		char const * fileContentEnd = fileContent + input.size();

		// Trim file content
		while(fileContent < fileContentEnd && *fileContent <= ' ') ++fileContent;
		while(fileContent < fileContentEnd && *(fileContentEnd - 1) <= ' ') --fileContentEnd;

		// Count rows
		numRows = count(fileContent, fileContentEnd, '\n') + 1;

		// Malloc data array (3 dimensions)
		data = (uint *) malloc(numRows * 3 * sizeof(*data));

		// File content to array
		char const * pos = fileContent;
		read_t prev = 0;
		unsigned readLen = 0;

		// For every row/transition ...
		for(read_t i = 0; i < numRows; ++i)
		{
			// Read source node
			uint const from = readInt(pos, fileContentEnd, readLen);

			// Go to next number
			pos += readLen;
			pos += nonDigits(pos, fileContentEnd);

			// Read target node
			uint const to = readInt(pos, fileContentEnd, readLen);

			// Go to next number
			pos += readLen;
			pos += nonDigits(pos, fileContentEnd);

			// Read weight
			uint const weight = readInt(pos, fileContentEnd, readLen);

			// Go to next number/line (or end of file)
			pos += readLen;
			pos += nonDigits(pos, fileContentEnd);

			// Put into data array
			data[3 * i] = from;
			data[3 * i + 1] = to;
			data[3 * i + 2] = weight;

			if(from < prev) isSorted = false;

			prev = from;
		}
	}

	// Sort if necessary
	if(!isSorted) countSort2D(data, 3, numRows);

	////		Render node starts	////
	uint * weights = (uint*)malloc(numRows * sizeof(*weights));
	uint const numIndices = data[3 * numRows - 3] + 1;
	read_t * const indices = (read_t *) malloc((numIndices + 1) * sizeof(*indices));
	
	// Create adjacency list
	uint curr = 0;
	indices[0] = 0;

	for(read_t i = 0; i < numRows; ++i)
	{
		// Set target[curr] for all nodes until the start node of the i-th transition
		while(data[3 * i] > curr) indices[++curr] = i;

		// Copy target node id to new (shrinked) position
		data[i] = data[3 * i + 1];
		// Copy the weight of the transition to weights
		weights[i] = data[3 * i + 2];
	}

	// Set target[curr] to end of data-set for all remaining indices
	while(curr < numIndices) indices[++curr] = numRows;

	// Shrink the size of data to its real content
	data = (uint *) realloc(data, numRows * sizeof(*data));

	////		Convert the graph to an undirected graph	////
	if(flags & (flag_undirected | flag_reflect))
	{
		// Sort the transitions for each source node
		// (Target nodes in increasing order)
		for(uint i = 0; i < numIndices; ++i)
		{
			read_t const start = indices[i];
			read_t const count = indices[i + 1] - start;

			if(count > 1) countSort2D({data + start, weights + start}, count);
		}

		///		Count number of missing transitions for every node		///
		uint * const counters = (uint *) calloc(numIndices, sizeof(*counters));
		std::vector<bool> bitSet(numRows * 2, false);
		read_t acc = 0; // Sum of all counters

		// For every source node ...
		for(uint node = 0; node < numIndices; ++node)
		{
			// For every transition of the node ...
			for(read_t trans = indices[node]; trans < indices[node + 1]; ++trans)
			{
				uint const targetNode = data[trans];
				uint const * const from = data + indices[targetNode];
				uint const * const to = data + indices[targetNode + 1];
				uint const * const found = binaryFind(from, to, node);

				// If has no counterpart ...
				if(found == to || *found != node)
				{
					// Increment counter for target node
					++counters[targetNode];
					// Increment number of transitions
					++acc;
					// Set bit in bitSet
					bitSet[trans] = true;
				}
				else if(flags & flag_reflect)
				{
					read_t const other_trans = found - data;
					if(other_trans > trans) weights[trans] = weights[other_trans] = weights[other_trans] + weights[trans];
				}
			}
		}

		if(acc)
		{
			////	Adapt list (make it undirected)		////
			// Resize transitions lists (data and weights)
			numRows += acc;
			data = (uint *) realloc(data, numRows * sizeof(*data));
			weights = (uint *) realloc(weights, numRows * sizeof(*weights));

			// For every node (from last to first)
			for(uint node = numIndices - 1; node > 0; --node)
			{
				// Get number of transitions
				size_t const len = indices[node + 1] - indices[node];
				// Increase end by accumulative counter
				indices[node + 1] += acc;
				// Subtract own new transitions from accumulative counter
				acc -= counters[node];
				//Move transitions to new position
				memmove(data + indices[node] + acc, data + indices[node], len * sizeof(*data));
				memmove(weights + indices[node] + acc, weights + indices[node], len * sizeof(*weights));
				// Move bits in bitSet
				std::move_backward(bitSet.begin() + indices[node], bitSet.begin() + (indices[node] + len), bitSet.begin() + (indices[node] + len + acc));
				std::fill(bitSet.begin() + (indices[node] + acc - counters[node - 1]), bitSet.begin() + (indices[node] + acc), false);
			}

			// Node 0
			indices[1] += acc;

			////	Add new transitions		////
			// For every node ...
			for(uint node = 0; node < numIndices; ++node)
			{
				// For every transition of that node ...
				for(read_t trans = indices[node]; trans < indices[node + 1]; ++trans)
				{
					if(bitSet[trans])
					{
						uint const targetNode = data[trans];
						uint const weight = weights[trans];
						data[indices[targetNode + 1] - (counters[targetNode])] = node;
						weights[indices[targetNode + 1] - (counters[targetNode])] = weight;

						--counters[targetNode];
					}
				}
			}
		}
		else if(!(flags & flag_reflect)) printf("Graph is already undirected\n");

		free(counters);
	}

	////		Optimize transition order	////
	if((flags & flag_optiTransOrder) && numIndices > 0)
	{
		// Sort each node
		for(uint nodeId = 0; nodeId < numIndices; ++nodeId)
		{
			// Determine sort range
			read_t const start = indices[nodeId];
			read_t const count = indices[nodeId + 1] - start;

			// Sort node (lowest weight first)
			countSort2D({weights + start, data + start}, count);

			// Reverse order (highest weight first)
			std::reverse(data + start, data + start + count);
			std::reverse(weights + start, weights + start + count);
		}
	}

	////		Post-Processing		////
	bool errorFound = false;
	// Accumulate weights
	for(read_t const * posIndices = indices, * indicesEnd = indices + numIndices; posIndices < indicesEnd; ++posIndices)
	{ // For each node ...
		uint newWeight = weights[*posIndices];
	
		// Accumulate weights of this nodes transitions
		for(read_t posWeights = *posIndices + 1; posWeights < *(posIndices + 1); ++posWeights)
		{
			//if(__builtin_add_overflow(weights[posWeights], weights[posWeights - 1], &weights[posWeights])) std::cout << "!!!!!Problem!!!!!" << std::endl;
			newWeight = weights[posWeights] + weights[posWeights - 1];
			if(newWeight < weights[posWeights] || newWeight < weights[posWeights - 1])
			{
				printf("Integer Overflow!!!");
				exit(1);
			}
			weights[posWeights] = newWeight;
		}

		// Check whether sum of weights is 0
		if(newWeight == 0)
		{
			printf("Node %lu has an accumulative weight of 0!\n", posIndices - indices);
			errorFound = true;
		}
	}
	
	if(errorFound) exit(1);

	return WeightedGraph(numIndices, indices, data, weights);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, 0x48(%rsp)
movq %rdi, 0x80(%rsp)
movq (%rsi), %rbp
movq 0x8(%rsi), %rcx
leaq (%rcx,%rbp), %rax
testq %rcx, %rcx
jle 0x450f
cmpb $0x20, (%rbp)
jg 0x450f
incq %rbp
cmpq %rax, %rbp
jb 0x44f4
jmp 0x450f
leaq -0x1(%r14), %rax
cmpb $0x21, -0x1(%r14)
jge 0x4517
movq %rax, %r14
cmpq %rax, %rbp
jb 0x4504
movq %rbp, %rdi
movq %r14, %rsi
movl $0xa, %edx
callq 0x3914
movq %rax, %r13
incq %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rbx
movq %rbx, %rdi
callq 0x21f0
movq %rax, %r12
movq %r13, %r15
movl $0x0, 0x50(%rsp)
incq %r15
movq %r15, 0x78(%rsp)
je 0x4668
movq %rbx, 0x30(%rsp)
movq %r13, 0x28(%rsp)
movq %r12, 0x38(%rsp)
movq %r12, %rcx
addq $0x8, %rcx
movb $0x1, %r12b
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq %r15, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdx
callq 0x2752
movl %eax, 0x18(%rsp)
movl 0x50(%rsp), %r13d
addq %rbp, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x272e
movl %eax, %ebp
addq %r13, %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2752
movl %eax, %r13d
movl 0x50(%rsp), %r15d
addq %rbp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x272e
movl %eax, %ebp
addq %r15, %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2752
movl %eax, %r15d
movl 0x50(%rsp), %ebx
addq %rbp, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x272e
movq 0x10(%rsp), %rcx
movl %eax, %ebp
addq %rbx, %rbp
movl 0x18(%rsp), %eax
movl %eax, -0x8(%rcx)
movl %r13d, -0x4(%rcx)
movl %eax, %eax
cmpq %rax, 0x20(%rsp)
movzbl %r12b, %r12d
movl $0x0, %edx
cmoval %edx, %r12d
movl %r15d, (%rcx)
addq $0xc, %rcx
movq 0x8(%rsp), %r15
decq %r15
jne 0x4574
testb $0x1, %r12b
movq 0x78(%rsp), %r15
movq 0x38(%rsp), %r12
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %rbx
jne 0x4668
movl $0x3, %esi
movq %r12, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x3b5a
leaq (,%r15,4), %rbp
movq %rbp, %rdi
callq 0x21f0
movq %rax, %r14
movl -0xc(%r12,%rbx), %ebx
leal 0x1(%rbx), %eax
movl %eax, 0x4(%rsp)
leal 0x2(%rbx), %edi
shlq $0x3, %rdi
callq 0x21f0
movq $0x0, (%rax)
testq %r15, %r15
movq %rax, 0x8(%rsp)
je 0x46ff
leaq 0x8(%rax), %rcx
xorl %eax, %eax
xorl %edx, %edx
leaq (,%rdx,4), %rsi
leaq (%rsi,%rsi,2), %rsi
movl (%r12,%rsi), %edi
cmpl %eax, %edi
jbe 0x46df
movl %eax, %eax
movq %rax, %r8
subq %rdi, %r8
leaq (%rcx,%rax,8), %r9
xorl %edi, %edi
movq %rdx, (%r9,%rdi,8)
incq %rdi
movq %r8, %r10
addq %rdi, %r10
jne 0x46ce
addl %edi, %eax
movl 0x4(%r12,%rsi), %edi
movl %edi, (%r12,%rdx,4)
movl 0x8(%r12,%rsi), %esi
movl %esi, (%r14,%rdx,4)
leaq 0x1(%rdx), %rsi
cmpq %r13, %rdx
movq %rsi, %rdx
jne 0x46ac
jmp 0x4701
xorl %eax, %eax
movl 0x4(%rsp), %ecx
movl %ecx, %edx
movq %rdx, 0x28(%rsp)
cmpl %ecx, %eax
jae 0x47b7
movl %eax, %ecx
movq 0x28(%rsp), %rdx
subq %rcx, %rdx
leaq 0x1(%rdx), %rax
andq $-0x2, %rax
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movq 0x8(%rsp), %rdx
leaq (%rdx,%rcx,8), %rcx
addq $0x10, %rcx
xorl %edx, %edx
movdqa 0x18c6(%rip), %xmm1     # 0x6010
movdqa 0x18ce(%rip), %xmm2     # 0x6020
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movq %rdx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %esi
notl %esi
testb $0x1, %sil
je 0x479b
movq %r15, -0x8(%rcx,%rdx,8)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %esi
testb $0x1, %sil
je 0x47ae
movq %r15, (%rcx,%rdx,8)
addq $0x2, %rdx
cmpq %rdx, %rax
jne 0x475a
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2280
movq %rax, 0x10(%rsp)
testb $0x9, 0x48(%rsp)
je 0x49aa
movq %rbx, 0x30(%rsp)
cmpl $0x0, 0x4(%rsp)
je 0x485b
xorl %r12d, %r12d
leaq 0xa0(%rsp), %r15
leaq 0x50(%rsp), %rbx
leaq 0x3(%rsp), %rbp
movq 0x8(%rsp), %rcx
movq (%rcx,%r12,8), %rax
movq 0x8(%rcx,%r12,8), %r13
subq %rax, %r13
cmpq $0x2, %r13
jb 0x4851
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,4), %rcx
movq %rcx, 0x50(%rsp)
leaq (%r14,%rax,4), %rax
movq %rax, 0x58(%rsp)
movl $0x2, %edx
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rcx
callq 0x4f7e
movq %r15, %rdi
movq %r13, %rsi
callq 0x3f55
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x4851
callq 0x2160
incq %r12
cmpq %r12, 0x28(%rsp)
jne 0x47f3
movl $0x4, %esi
movq 0x28(%rsp), %rdi
callq 0x20f0
movq %rax, %rbx
movq 0x78(%rsp), %rax
leaq (%rax,%rax), %rsi
leaq 0x3(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x50(%rsp), %rdi
leaq 0x47(%rsp), %rcx
callq 0x30cc
movq %rbx, 0x18(%rsp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
cmpl $0x0, 0x4(%rsp)
movq 0x8(%rsp), %rbp
je 0x49b4
xorl %r12d, %r12d
addq $0x3f, %rax
movq %rax, 0x38(%rsp)
movq $0x0, 0x20(%rsp)
movq %r12, %r13
movq (%rbp,%r12,8), %r15
incq %r12
cmpq 0x8(%rbp,%r13,8), %r15
jae 0x499d
movq 0x10(%rsp), %rcx
movl (%rcx,%r15,4), %ebx
movq (%rbp,%rbx,8), %rax
leaq (%rcx,%rax,4), %rdi
leal 0x1(%rbx), %eax
movq (%rbp,%rax,8), %rax
leaq (%rcx,%rax,4), %rbp
movq %rbp, %rsi
movl %r13d, %edx
callq 0x4fbc
cmpq %rbp, %rax
je 0x493b
movl (%rax), %ecx
cmpq %rcx, %r13
jne 0x493b
testb $0x8, 0x48(%rsp)
je 0x498a
subq 0x10(%rsp), %rax
movq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
movq 0x8(%rsp), %rbp
jbe 0x498f
movl (%r14,%r15,4), %ecx
addl (%r14,%rax), %ecx
movl %ecx, (%r14,%rax)
movl %ecx, (%r14,%r15,4)
jmp 0x498f
movq 0x18(%rsp), %rax
incl (%rax,%rbx,4)
leaq 0x3f(%r15), %rax
testq %r15, %r15
cmovnsq %r15, %rax
sarq $0x6, %rax
shlq $0x3, %rax
addq 0x50(%rsp), %rax
movq %r15, %rcx
andq 0x38(%rsp), %rcx
xorl %edx, %edx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
cmpq %rsi, %rcx
setbe %dl
movl $0x1, %esi
movl %r15d, %ecx
shlq %cl, %rsi
incq 0x20(%rsp)
orq %rsi, -0x8(%rax,%rdx,8)
movq 0x8(%rsp), %rbp
incq %r15
cmpq (%rbp,%r12,8), %r15
jb 0x48d7
cmpq 0x28(%rsp), %r12
jne 0x48c1
jmp 0x49bd
movq 0x8(%rsp), %rbp
jmp 0x4d32
movq $0x0, 0x20(%rsp)
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x4ced
movq 0x78(%rsp), %rbx
addq %rax, %rbx
shlq $0x2, %rbx
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x2280
movq %rax, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2280
movq %rax, %r14
movq 0x30(%rsp), %rbp
testq %rbp, %rbp
je 0x4c3b
incq %rbp
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
leaq 0x3f(%rax), %rbx
movq %rbx, 0x38(%rsp)
movl %ebp, %eax
movq 0x8(%rsp), %rbx
movq (%rbx,%rax,8), %r12
movq -0x8(%rbx,%rbp,8), %r15
movq %rbp, %rdx
movq %r12, %r13
subq %r15, %r13
movq 0x20(%rsp), %rbp
leaq (%r12,%rbp), %rcx
movq %rcx, (%rbx,%rax,8)
movq %rdx, 0x30(%rsp)
movq 0x18(%rsp), %rax
movl -0x4(%rax,%rdx,4), %eax
subq %rax, %rbp
movq 0x10(%rsp), %rax
leaq (%rax,%r15,4), %rsi
leaq (%rsi,%rbp,4), %rdi
shlq $0x2, %r13
movq %r13, %rdx
callq 0x2270
leaq (%r14,%r15,4), %rsi
leaq (%rsi,%rbp,4), %rdi
movq %r13, %rdx
callq 0x2270
movq 0x50(%rsp), %rax
leaq 0x3f(%r15), %rcx
testq %r15, %r15
cmovnsq %r15, %rcx
sarq $0x6, %rcx
leaq (%rax,%rcx,8), %rcx
movq %r15, %rdx
movq 0x38(%rsp), %r8
andq %r8, %rdx
xorl %esi, %esi
movabsq $-0x8000000000000000, %r13 # imm = 0x8000000000000000
cmpq %r13, %rdx
setbe %sil
leaq (%rcx,%rsi,8), %rdi
addq $-0x8, %rdi
andl $0x3f, %r15d
leaq 0x3f(%r12), %rcx
testq %r12, %r12
cmovnsq %r12, %rcx
sarq $0x6, %rcx
leaq (%rax,%rcx,8), %rcx
movq %r12, %rdx
andq %r8, %rdx
xorl %esi, %esi
cmpq %r13, %rdx
setbe %sil
leaq (%rcx,%rsi,8), %rdx
addq $-0x8, %rdx
movl %r12d, %ecx
andl $0x3f, %ecx
movq %rbp, %r9
addq %r12, %r9
leaq 0x3f(%rbp,%r12), %rsi
cmovnsq %r9, %rsi
sarq $0x6, %rsi
leaq (%rax,%rsi,8), %rax
movq %r9, %rsi
movq %r8, %r12
andq %r8, %rsi
xorl %r8d, %r8d
cmpq %r13, %rsi
setbe %r8b
leaq (%rax,%r8,8), %r8
addq $-0x8, %r8
andl $0x3f, %r9d
movl %r15d, %esi
callq 0x387c
movq 0x30(%rsp), %r11
movq -0x8(%rbx,%r11,8), %rdx
leaq (%rdx,%rbp), %r15
movq 0x18(%rsp), %rax
movl -0x8(%rax,%r11,4), %ecx
movq %r15, %rax
subq %rcx, %rax
leaq 0x3f(%rax), %rsi
testq %rax, %rax
cmovnsq %rax, %rsi
movq 0x50(%rsp), %rcx
sarq $0x6, %rsi
movq %rax, %rdi
movq %r12, %rbx
andq %r12, %rdi
xorl %r8d, %r8d
cmpq %r13, %rdi
setbe %r8b
leaq (%rcx,%rsi,8), %rsi
leaq (%rsi,%r8,8), %r9
movl %eax, %edi
andl $0x3f, %edi
movq %rbp, 0x20(%rsp)
leaq (%rdx,%rbp), %r10
addq $0x3f, %r10
testq %r15, %r15
cmovnsq %r15, %r10
leaq (%rsi,%r8,8), %r12
addq $-0x8, %r12
sarq $0x6, %r10
movq %r15, %rsi
andq %rbx, %rsi
xorl %edx, %edx
cmpq %r13, %rsi
setbe %dl
leaq (%rcx,%r10,8), %rsi
leaq (%rsi,%rdx,8), %rcx
andl $0x3f, %r15d
cmpq %rcx, %r9
movq %r11, %rbp
je 0x4c0a
testl %edi, %edi
je 0x4bdb
movq $-0x1, %rdi
movl %eax, %ecx
shlq %cl, %rdi
notq %rdi
andq %rdi, (%r12)
addq $0x8, %r12
movq %r12, %rdi
leaq (%rsi,%rdx,8), %r12
addq $-0x8, %r12
movq %r12, %rdx
subq %rdi, %rdx
xorl %esi, %esi
callq 0x20e0
testl %r15d, %r15d
je 0x4c2e
negb %r15b
movq $-0x1, %rdx
movl %r15d, %ecx
shrq %cl, %rdx
jmp 0x4c27
cmpl %r15d, %edi
je 0x4c2e
negb %r15b
movq $-0x1, %rdx
movl %r15d, %ecx
shrq %cl, %rdx
movl %eax, %ecx
shrq %cl, %rdx
shlq %cl, %rdx
notq %rdx
andq %rdx, (%r12)
decq %rbp
cmpq $0x1, %rbp
jne 0x4a1b
movq 0x8(%rsp), %rbp
movq 0x20(%rsp), %rax
addq %rax, 0x8(%rbp)
cmpl $0x0, 0x4(%rsp)
je 0x4d00
movq 0x50(%rsp), %rax
xorl %ecx, %ecx
movabsq $-0x8000000000000000, %r12 # imm = 0x8000000000000000
leaq 0x3f(%r12), %rdx
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rbx
movq (%rbp,%rcx,8), %rsi
movq 0x8(%rbp,%rcx,8), %r15
cmpq %r15, %rsi
jae 0x4ce1
leaq 0x3f(%rsi), %r8
testq %rsi, %rsi
cmovnsq %rsi, %r8
sarq $0x6, %r8
leaq (%rax,%r8,8), %r8
movq %rsi, %r9
andq %rdx, %r9
xorl %r10d, %r10d
cmpq %r12, %r9
setbe %r10b
movq -0x8(%r8,%r10,8), %r8
btq %rsi, %r8
jae 0x4cd9
movl (%rbx,%rsi,4), %r8d
movl (%r14,%rsi,4), %r9d
leal 0x1(%r8), %r10d
movq (%rbp,%r10,8), %r10
movl (%rdi,%r8,4), %r11d
subq %r11, %r10
movl %ecx, (%rbx,%r10,4)
movl %r9d, (%r14,%r10,4)
leal -0x1(%r11), %r9d
movl %r9d, (%rdi,%r8,4)
incq %rsi
cmpq %rsi, %r15
jne 0x4c83
incq %rcx
cmpq 0x28(%rsp), %rcx
jne 0x4c74
jmp 0x4d05
testb $0x8, 0x48(%rsp)
jne 0x4d00
leaq 0x13da(%rip), %rdi      # 0x60d5
callq 0x2250
movq 0x18(%rsp), %rdi
callq 0x21d0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4d32
callq 0x2160
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movl %eax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movl %eax, 0x68(%rsp)
movq %rax, 0x70(%rsp)
testb $0x2, 0x48(%rsp)
je 0x4e62
cmpl $0x0, 0x4(%rsp)
je 0x4e62
movq 0x10(%rsp), %rax
leaq -0x4(%rax), %rcx
movq %rcx, 0x38(%rsp)
leaq -0x4(%r14), %rcx
movq %rcx, 0x18(%rsp)
addq $0x4, %rax
movq %rax, 0x48(%rsp)
leaq 0x4(%r14), %rax
movq %rax, 0x30(%rsp)
xorl %r13d, %r13d
leaq 0x88(%rsp), %rbx
movq (%rbp,%r13,8), %r12
movq 0x8(%rbp,%r13,8), %rbp
leaq (%r14,%r12,4), %rax
movq %rax, 0x20(%rsp)
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rax
leaq (%rax,%r12,4), %r15
movq %r15, 0x58(%rsp)
movl $0x2, %edx
movq %rbx, %rdi
leaq 0x50(%rsp), %rsi
leaq 0x3(%rsp), %rcx
callq 0x4f7e
movq %rbp, %rsi
subq %r12, %rsi
movq %rbx, %rdi
callq 0x3f55
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x4dd9
callq 0x2160
cmpq %r12, %rbp
je 0x4e0f
movq 0x38(%rsp), %rax
leaq (%rax,%rbp,4), %rax
cmpq %r15, %rax
jbe 0x4e0f
movq 0x48(%rsp), %rcx
leaq (%rcx,%r12,4), %rcx
movl -0x4(%rcx), %edx
movl (%rax), %esi
movl %esi, -0x4(%rcx)
movl %edx, (%rax)
addq $-0x4, %rax
leaq 0x4(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x4df5
cmpq %r12, %rbp
leaq 0x88(%rsp), %rbx
je 0x4e4f
movq 0x18(%rsp), %rax
leaq (%rax,%rbp,4), %rax
cmpq 0x20(%rsp), %rax
jbe 0x4e4f
movq 0x30(%rsp), %rcx
leaq (%rcx,%r12,4), %rcx
movl -0x4(%rcx), %edx
movl (%rax), %esi
movl %esi, -0x4(%rcx)
movl %edx, (%rax)
addq $-0x4, %rax
leaq 0x4(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x4e35
incq %r13
cmpq 0x28(%rsp), %r13
movq 0x8(%rsp), %rbp
jne 0x4d7c
cmpl $0x0, 0x4(%rsp)
je 0x4eda
movq 0x28(%rsp), %rax
leaq (,%rax,8), %r12
addq %rbp, %r12
xorl %eax, %eax
leaq 0x13d6(%rip), %r15      # 0x6258
movq %rbp, %r13
movq (%r13), %rsi
movq 0x8(%r13), %rcx
leaq 0x1(%rsi), %rdx
cmpq %rcx, %rdx
jae 0x4eaf
movl -0x4(%r14,%rdx,4), %esi
addl (%r14,%rdx,4), %esi
jb 0x4f19
movl %esi, (%r14,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x4e96
jmp 0x4eb3
movl (%r14,%rsi,4), %esi
testl %esi, %esi
jne 0x4ecd
movq %r13, %rsi
subq %rbp, %rsi
sarq $0x3, %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x2040
movb $0x1, %al
addq $0x8, %r13
cmpq %r12, %r13
jb 0x4e85
testb $0x1, %al
jne 0x4f27
movq 0x80(%rsp), %rbx
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x248c
leaq 0x3e83(%rip), %rax      # 0x8d80
movq %rax, (%rbx)
movq %r14, 0x20(%rbx)
movq %rbx, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1324(%rip), %rdi      # 0x6244
xorl %eax, %eax
callq 0x2040
movl $0x1, %edi
callq 0x21e0
jmp 0x4f5b
jmp 0x4f5b
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
jmp 0x4f6b
movq %rax, %rbx
movq 0x50(%rsp), %rsi
testq %rsi, %rsi
je 0x4f75
leaq 0x50(%rsp), %rdi
callq 0x234d
jmp 0x4f75
movq %rax, %rbx
jmp 0x4f75
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x4f75
callq 0x2160
movq %rbx, %rdi
callq 0x2290
nop