// File: EnderGed[P]fast-random-walk/Graph.cpp
// Function: Graph::readGraph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long)
Graph Graph::readGraph(std::string const input, uint64_t const flags)
{
	bool isSorted = true;
	read_t numTransitions;
	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
		numTransitions = count(fileContent, fileContentEnd, '\n') + 1;

		// Malloc data array (2 dimensions)
		data = (uint *) malloc(numTransitions * 2 * 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 < numTransitions; ++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/line (or end of file)
			pos += readLen;
			pos += nonDigits(pos, fileContentEnd);

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

			if(from < prev) isSorted = false;

			prev = from;
		}
	}

	// Sort by source node if necessary
	if(!isSorted) countSort2D(data, 2, numTransitions);

	////	Render node starts	////
	uint const numNodes = data[2 * numTransitions - 2] + 1;
	read_t * const indices = (read_t *) malloc((numNodes + 1) * sizeof(*indices));
	
	// Create adjacency list
	uint node_id = 0;
	indices[0] = 0;

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

		// Copy target node id to new (shrinked) position
		data[i] = data[2 * i + 1];
	}

	// Set target[node_id] to end of data-set for all remaining node_ids
	while(node_id < numNodes) indices[++node_id] = numTransitions;

	// Resize data to the shrinked size
	data = (uint *) realloc(data, numTransitions * sizeof(*data));

	// Convert the graph to an undirected graph
	if(flags & (flag_undirected | flag_reflect))
	{
		// Sort the transitions for each source node
		for(uint i = 0; i < numNodes; ++i)
			if(indices[i + 1] - indices[i] > 1)
				std::sort(data + indices[i], data + indices[i + 1]);

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

		// For every source node ...
		for(uint node = 0; node < numNodes; ++node)
		{
			// For every transition of the node ...
			for(read_t trans = indices[node]; trans < indices[node + 1]; ++trans)
			{
				uint const targetNode = data[trans];
				bool const found = std::binary_search(data + indices[targetNode], data + indices[targetNode + 1], node);

				// If has no counterpart ...
				if(!found)
				{
					// Increment counter for target node
					++counters[targetNode];
					// Increment number of transitions
					++acc;
					// Set bit in bitSet
					//bitMapSet(bitSet, node, true);
					bitSet[trans] = true;
				}
			}
		}

		if(acc)
		{
			////	Adapt list	////
			// Resize transitions list (data)
			numTransitions += acc;
			data = (uint *) realloc(data, numTransitions * sizeof(*data));

			// For every node (from last to first) ...
			for(uint node = numNodes - 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));
				// 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);
			}

			// Modify last element (first node) (that is not part of the loop anymore)
			indices[1] += acc;

			////	Add new transitions	////
			// For every node ...
			for(uint node = 0; node < numNodes; ++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];
						data[indices[targetNode + 1] - (counters[targetNode]--)] = node;
					}
				}
			}
		}
		else printf("Graph is already undirected\n");
		
		free(counters);
	}

	return Graph(numNodes, indices, data);
}

// Assembly:
subq $0x358, %rsp            # imm = 0x358
movq %rsi, 0xb8(%rsp)
movq %rdi, %rax
movq 0xb8(%rsp), %rdi
movq %rax, 0xa8(%rsp)
movq %rax, %rcx
movq %rcx, 0xb0(%rsp)
movq %rax, 0x350(%rsp)
movq %rdi, 0x348(%rsp)
movq %rdx, 0x340(%rsp)
movb $0x1, 0x33f(%rsp)
callq 0x20a0
movq 0xb8(%rsp), %rdi
movq %rax, 0x320(%rsp)
movq 0x320(%rsp), %rax
movq %rax, 0xc0(%rsp)
callq 0x2140
movq %rax, %rcx
movq 0xc0(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x318(%rsp)
movq 0x320(%rsp), %rcx
xorl %eax, %eax
cmpq 0x318(%rsp), %rcx
movb %al, 0xa7(%rsp)
jae 0x2ad0
movq 0x320(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
setle %al
movb %al, 0xa7(%rsp)
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x2add
jmp 0x2af3
movq 0x320(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x320(%rsp)
jmp 0x2a9d
jmp 0x2af5
movq 0x320(%rsp), %rcx
xorl %eax, %eax
cmpq 0x318(%rsp), %rcx
movb %al, 0xa6(%rsp)
jae 0x2b29
movq 0x318(%rsp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x20, %eax
setle %al
movb %al, 0xa6(%rsp)
movb 0xa6(%rsp), %al
testb $0x1, %al
jne 0x2b36
jmp 0x2b4c
movq 0x318(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x318(%rsp)
jmp 0x2af5
movq 0x320(%rsp), %rdi
movq 0x318(%rsp), %rsi
movl $0xa, %edx
callq 0x62f0
addq $0x1, %rax
movq %rax, 0x330(%rsp)
movq 0x330(%rsp), %rdi
shlq %rdi
shlq $0x2, %rdi
callq 0x2240
movq %rax, 0x328(%rsp)
movq 0x320(%rsp), %rax
movq %rax, 0x310(%rsp)
movq $0x0, 0x308(%rsp)
movl $0x0, 0x304(%rsp)
movq $0x0, 0x2f8(%rsp)
movq 0x2f8(%rsp), %rax
cmpq 0x330(%rsp), %rax
jae 0x2d2b
movq 0x310(%rsp), %rdi
movq 0x318(%rsp), %rsi
leaq 0x304(%rsp), %rdx
callq 0x28b0
movl %eax, 0x2f4(%rsp)
movl 0x304(%rsp), %ecx
movq 0x310(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rdi
movq 0x318(%rsp), %rsi
callq 0x2830
movl %eax, %ecx
movq 0x310(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rdi
movq 0x318(%rsp), %rsi
leaq 0x304(%rsp), %rdx
callq 0x28b0
movl %eax, 0x2f0(%rsp)
movl 0x304(%rsp), %ecx
movq 0x310(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x310(%rsp)
movq 0x310(%rsp), %rdi
movq 0x318(%rsp), %rsi
callq 0x2830
movl %eax, %ecx
movq 0x310(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x310(%rsp)
movl 0x2f4(%rsp), %edx
movq 0x328(%rsp), %rax
movq 0x2f8(%rsp), %rcx
shlq %rcx
movl %edx, (%rax,%rcx,4)
movl 0x2f0(%rsp), %edx
movq 0x328(%rsp), %rax
movq 0x2f8(%rsp), %rcx
shlq %rcx
movl %edx, 0x4(%rax,%rcx,4)
movl 0x2f4(%rsp), %eax
cmpq 0x308(%rsp), %rax
jae 0x2d03
movb $0x0, 0x33f(%rsp)
movl 0x2f4(%rsp), %eax
movq %rax, 0x308(%rsp)
movq 0x2f8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2f8(%rsp)
jmp 0x2bc1
testb $0x1, 0x33f(%rsp)
jne 0x2d53
movq 0x328(%rsp), %rdi
movq 0x330(%rsp), %rdx
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x6700
movq 0x328(%rsp), %rax
movq 0x330(%rsp), %rcx
shlq %rcx
subq $0x2, %rcx
movl (%rax,%rcx,4), %eax
addl $0x1, %eax
movl %eax, 0x2ec(%rsp)
movl 0x2ec(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2240
movq %rax, 0x2e0(%rsp)
movl $0x0, 0x2dc(%rsp)
movq 0x2e0(%rsp), %rax
movq $0x0, (%rax)
movq $0x0, 0x2d0(%rsp)
movq 0x2d0(%rsp), %rax
cmpq 0x330(%rsp), %rax
jae 0x2e5f
jmp 0x2dd4
movq 0x328(%rsp), %rax
movq 0x2d0(%rsp), %rcx
shlq %rcx
movl (%rax,%rcx,4), %eax
cmpl 0x2dc(%rsp), %eax
jbe 0x2e1c
movq 0x2d0(%rsp), %rdx
movq 0x2e0(%rsp), %rax
movl 0x2dc(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x2dc(%rsp)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x2dd4
movq 0x328(%rsp), %rax
movq 0x2d0(%rsp), %rcx
shlq %rcx
movl 0x4(%rax,%rcx,4), %edx
movq 0x328(%rsp), %rax
movq 0x2d0(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x2d0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2d0(%rsp)
jmp 0x2dbc
jmp 0x2e61
movl 0x2dc(%rsp), %eax
cmpl 0x2ec(%rsp), %eax
jae 0x2e9a
movq 0x330(%rsp), %rdx
movq 0x2e0(%rsp), %rax
movl 0x2dc(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x2dc(%rsp)
movl %ecx, %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0x2e61
movq 0x328(%rsp), %rdi
movq 0x330(%rsp), %rsi
shlq $0x2, %rsi
callq 0x22c0
movq %rax, 0x328(%rsp)
movq 0x340(%rsp), %rax
andq $0x9, %rax
cmpq $0x0, %rax
je 0x3887
movl $0x0, 0x2cc(%rsp)
movl 0x2cc(%rsp), %eax
cmpl 0x2ec(%rsp), %eax
jae 0x2f87
movq 0x2e0(%rsp), %rax
movl 0x2cc(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq 0x2e0(%rsp), %rcx
movl 0x2cc(%rsp), %edx
subq (%rcx,%rdx,8), %rax
cmpq $0x1, %rax
jbe 0x2f6f
movq 0x328(%rsp), %rdi
movq 0x2e0(%rsp), %rax
movl 0x2cc(%rsp), %ecx
movq (%rax,%rcx,8), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq 0x328(%rsp), %rsi
movq 0x2e0(%rsp), %rax
movl 0x2cc(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x3a40
jmp 0x2f71
movl 0x2cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2cc(%rsp)
jmp 0x2edc
movl 0x2ec(%rsp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2120
movq %rax, 0x2c0(%rsp)
movq 0x330(%rsp), %rax
addq %rax, %rax
movq %rax, 0x90(%rsp)
movb $0x0, 0x297(%rsp)
leaq 0x296(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x3a80
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rcx
leaq 0x298(%rsp), %rdi
leaq 0x297(%rsp), %rdx
callq 0x3a90
jmp 0x2ff9
leaq 0x296(%rsp), %rdi
callq 0x3b10
movq $0x0, 0x278(%rsp)
movl $0x0, 0x274(%rsp)
movl 0x274(%rsp), %eax
cmpl 0x2ec(%rsp), %eax
jae 0x31eb
movq 0x2e0(%rsp), %rax
movl 0x274(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x268(%rsp)
movq 0x268(%rsp), %rax
movq 0x2e0(%rsp), %rcx
movl 0x274(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
cmpq (%rcx,%rdx,8), %rax
jae 0x31d3
movq 0x328(%rsp), %rax
movq 0x268(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x264(%rsp)
movq 0x328(%rsp), %rax
movq 0x2e0(%rsp), %rcx
movl 0x264(%rsp), %edx
movl %edx, %esi
movl %esi, %edx
movq (%rcx,%rsi,8), %rsi
leaq (%rax,%rsi,4), %rdi
incl %edx
movq (%rcx,%rdx,8), %rcx
leaq (%rax,%rcx,4), %rsi
leaq 0x274(%rsp), %rdx
callq 0x3b20
movb %al, 0x8f(%rsp)
jmp 0x30cf
movb 0x8f(%rsp), %al
andb $0x1, %al
movb %al, 0x263(%rsp)
testb $0x1, 0x263(%rsp)
jne 0x31b8
movq 0x2c0(%rsp), %rax
movl 0x264(%rsp), %ecx
movl (%rax,%rcx,4), %edx
incl %edx
movl %edx, (%rax,%rcx,4)
movq 0x278(%rsp), %rax
incq %rax
movq %rax, 0x278(%rsp)
movq 0x268(%rsp), %rsi
leaq 0x298(%rsp), %rdi
callq 0x3bb0
movq %rdx, 0x78(%rsp)
movq %rax, 0x80(%rsp)
jmp 0x313b
movq 0x78(%rsp), %rax
movq 0x80(%rsp), %rcx
movq %rcx, 0x250(%rsp)
movq %rax, 0x258(%rsp)
leaq 0x250(%rsp), %rdi
movl $0x1, %esi
callq 0x3c10
jmp 0x31b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x296(%rsp), %rdi
callq 0x3b10
jmp 0x38bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x288(%rsp)
movl %eax, 0x284(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x3e90
jmp 0x38bb
jmp 0x31ba
movq 0x268(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x268(%rsp)
jmp 0x304c
jmp 0x31d5
movl 0x274(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x274(%rsp)
jmp 0x301d
cmpq $0x0, 0x278(%rsp)
je 0x385b
movq 0x278(%rsp), %rax
addq 0x330(%rsp), %rax
movq %rax, 0x330(%rsp)
movq 0x328(%rsp), %rdi
movq 0x330(%rsp), %rsi
shlq $0x2, %rsi
callq 0x22c0
movq %rax, 0x328(%rsp)
movl 0x2ec(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x24c(%rsp)
cmpl $0x0, 0x24c(%rsp)
jbe 0x36f6
movq 0x2e0(%rsp), %rcx
movl 0x24c(%rsp), %eax
movl %eax, %edx
movl %edx, %eax
incl %eax
movq (%rcx,%rax,8), %rax
movq (%rcx,%rdx,8), %rcx
subq %rcx, %rax
movq %rax, 0x240(%rsp)
movq 0x278(%rsp), %rsi
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
incl %ecx
movq (%rax,%rcx,8), %rdx
addq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x2c0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, %ecx
movq 0x278(%rsp), %rax
subq %rcx, %rax
movq %rax, 0x278(%rsp)
movq 0x328(%rsp), %rax
movq 0x2e0(%rsp), %rcx
movl 0x24c(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
leaq (%rax,%rcx,4), %rsi
movq 0x278(%rsp), %rax
leaq (%rsi,%rax,4), %rdi
movq 0x240(%rsp), %rdx
shlq $0x2, %rdx
callq 0x22b0
leaq 0x298(%rsp), %rdi
callq 0x3db0
movl %edx, 0x218(%rsp)
movq %rax, 0x210(%rsp)
movl 0x218(%rsp), %eax
movl %eax, 0x228(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x220(%rsp)
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
leaq 0x220(%rsp), %rdi
callq 0x3d70
movl %edx, 0x6c(%rsp)
movq %rax, 0x70(%rsp)
jmp 0x3366
movl 0x6c(%rsp), %eax
movq 0x70(%rsp), %rcx
movq %rcx, 0x200(%rsp)
movl %eax, 0x208(%rsp)
movl 0x208(%rsp), %eax
movl %eax, 0x238(%rsp)
movq 0x200(%rsp), %rax
movq %rax, 0x230(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x3db0
movl %edx, 0x1d8(%rsp)
movq %rax, 0x1d0(%rsp)
movl 0x1d8(%rsp), %eax
movl %eax, 0x1e8(%rsp)
movq 0x1d0(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
movq 0x240(%rsp), %rax
addq %rax, %rsi
leaq 0x1e0(%rsp), %rdi
callq 0x3d70
movl %edx, 0x5c(%rsp)
movq %rax, 0x60(%rsp)
jmp 0x340c
movl 0x5c(%rsp), %eax
movq 0x60(%rsp), %rcx
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1c8(%rsp)
movl 0x1c8(%rsp), %eax
movl %eax, 0x1f8(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x1f0(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x3db0
movl %edx, 0x198(%rsp)
movq %rax, 0x190(%rsp)
movl 0x198(%rsp), %eax
movl %eax, 0x1a8(%rsp)
movq 0x190(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
movq 0x240(%rsp), %rax
addq %rax, %rsi
movq 0x278(%rsp), %rax
addq %rax, %rsi
leaq 0x1a0(%rsp), %rdi
callq 0x3d70
movl %edx, 0x4c(%rsp)
movq %rax, 0x50(%rsp)
jmp 0x34bd
movl 0x4c(%rsp), %eax
movq 0x50(%rsp), %rcx
movq %rcx, 0x180(%rsp)
movl %eax, 0x188(%rsp)
movl 0x188(%rsp), %eax
movl %eax, 0x1b8(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x1b0(%rsp)
movq 0x230(%rsp), %rdi
movl 0x238(%rsp), %esi
movq 0x1f0(%rsp), %rdx
movl 0x1f8(%rsp), %ecx
movq 0x1b0(%rsp), %r8
movl 0x1b8(%rsp), %r9d
callq 0x3c60
movl %edx, 0x3c(%rsp)
movq %rax, 0x40(%rsp)
jmp 0x3531
movl 0x3c(%rsp), %eax
movq 0x40(%rsp), %rcx
movq %rcx, 0x170(%rsp)
movl %eax, 0x178(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x3db0
movl %edx, 0x148(%rsp)
movq %rax, 0x140(%rsp)
movl 0x148(%rsp), %eax
movl %eax, 0x158(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x150(%rsp)
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movl %ecx, %edx
movl %edx, %ecx
movq (%rax,%rdx,8), %rsi
movq 0x278(%rsp), %rax
addq %rax, %rsi
movq 0x2c0(%rsp), %rax
decl %ecx
movl (%rax,%rcx,4), %eax
subq %rax, %rsi
leaq 0x150(%rsp), %rdi
callq 0x3d70
movl %edx, 0x2c(%rsp)
movq %rax, 0x30(%rsp)
jmp 0x35cd
movl 0x2c(%rsp), %eax
movq 0x30(%rsp), %rcx
movq %rcx, 0x130(%rsp)
movl %eax, 0x138(%rsp)
movl 0x138(%rsp), %eax
movl %eax, 0x168(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x160(%rsp)
leaq 0x298(%rsp), %rdi
callq 0x3db0
movl %edx, 0x108(%rsp)
movq %rax, 0x100(%rsp)
movl 0x108(%rsp), %eax
movl %eax, 0x118(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x2e0(%rsp), %rax
movl 0x24c(%rsp), %ecx
movq (%rax,%rcx,8), %rsi
movq 0x278(%rsp), %rax
addq %rax, %rsi
leaq 0x110(%rsp), %rdi
callq 0x3d70
movl %edx, 0x1c(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x3673
movl 0x1c(%rsp), %eax
movq 0x20(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movl %eax, 0xf8(%rsp)
movl 0xf8(%rsp), %eax
movl %eax, 0x128(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x120(%rsp)
movb $0x0, 0xef(%rsp)
movq 0x160(%rsp), %rdi
movl 0x168(%rsp), %esi
movq 0x120(%rsp), %rdx
movl 0x128(%rsp), %ecx
leaq 0xef(%rsp), %r8
callq 0x3df0
jmp 0x36de
jmp 0x36e0
movl 0x24c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x24c(%rsp)
jmp 0x3244
movq 0x278(%rsp), %rcx
movq 0x2e0(%rsp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movl $0x0, 0xe8(%rsp)
movl 0xe8(%rsp), %eax
cmpl 0x2ec(%rsp), %eax
jae 0x3859
movq 0x2e0(%rsp), %rax
movl 0xe8(%rsp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq 0x2e0(%rsp), %rcx
movl 0xe8(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
cmpq (%rcx,%rdx,8), %rax
jae 0x3841
movq 0xe0(%rsp), %rsi
leaq 0x298(%rsp), %rdi
callq 0x3bb0
movq %rdx, 0x8(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x378f
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
movq %rax, 0xd8(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x3e60
testb $0x1, %al
jne 0x37bc
jmp 0x3826
movq 0x328(%rsp), %rax
movq 0xe0(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0xcc(%rsp)
movl 0xe8(%rsp), %edx
movq 0x328(%rsp), %rax
movq 0x2e0(%rsp), %rcx
movl 0xcc(%rsp), %esi
addl $0x1, %esi
movl %esi, %esi
movq (%rcx,%rsi,8), %rcx
movq 0x2c0(%rsp), %rdi
movl 0xcc(%rsp), %esi
movl %esi, %r8d
movl (%rdi,%r8,4), %esi
movl %esi, %r9d
addl $-0x1, %r9d
movl %r9d, (%rdi,%r8,4)
movl %esi, %esi
subq %rsi, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3828
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
jmp 0x3748
jmp 0x3843
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x3719
jmp 0x386d
leaq 0x881a(%rip), %rdi      # 0xc07c
xorl %eax, %eax
callq 0x2040
jmp 0x386b
jmp 0x386d
movq 0x2c0(%rsp), %rdi
callq 0x2220
leaq 0x298(%rsp), %rdi
callq 0x3e90
movq 0xa8(%rsp), %rdi
movl 0x2ec(%rsp), %esi
movq 0x2e0(%rsp), %rdx
movq 0x328(%rsp), %rcx
callq 0x2400
movq 0xb0(%rsp), %rax
addq $0x358, %rsp            # imm = 0x358
retq
movq 0x288(%rsp), %rdi
callq 0x22d0
nopl (%rax,%rax)