// File: /workspace/github_cpp_makefile_star2_O2/EnderGed[P]fast-random-walk/walk.cpp
// Function: main
int main(int const argc, char const * const argv[])
{
	uint64_t flags = 0;
	bool weighted = false;
	bool print = false;
	char const * input = 0;
	char const * output = 0;
	uint32_t walkLen = 0;
	uint32_t numWalks = 0;

	// Parse command line arguments
	for(int argi = 1; argi < argc; ++argi)
	{
		char const * arg = argv[argi];
		size_t len = strlen(arg);

		if(*arg == '-')
		{
			// Valid option
			++arg;
			--len;

			if(*arg == '-')
			{
				// Long option
				++arg;
				--len;

				char const * param = 0;
				int const remc = argc - argi;
				char const * const * const remv = argv + argi;

				if(!strcmp(arg, "optiTransOrder")) flags |= Graph::flag_optiTransOrder;
				else if(!strcmp(arg, "undirected")) flags |=  Graph::flag_undirected;
				else if(!strcmp(arg, "reflect")) flags |= Graph::flag_reflect;
				else if(!strcmp(arg, "weighted")) weighted = true;
				else if(!strcmp(arg, "print")) print = true;
				else if((param = readParam(remc, remv, "if"))) input = param;
				else if((param = readParam(remc, remv, "of"))) output = param;
				else if((param = readParam(remc, remv, "length"))) walkLen = toInt(param);
				else if((param = readParam(remc, remv, "walks"))) numWalks = toInt(param);
				else if(!strcmp(arg, "help"))
				{
					printHelp();
					exit(0);
				}
				else
				{
					printf("Unknown option --%s\n", arg);
					printHelp();
					exit(1);
				}
			}
			else
			{
				// Short option
				for(size_t i = 0; i < len; ++i)
				{
					switch(arg[i])
					{
						case 'o':
							flags |= Graph::flag_optiTransOrder;
							break;
						case 'p':
							print = true;
							break;
						case 'r':
							flags |= Graph::flag_reflect;
							break;
						case 'u':
							flags |= Graph::flag_undirected;
							break;
						case 'w':
							weighted = true;
							break;
						case 'h':
							printHelp();
							exit(0);
							break;
						default:
							printf("Unknown short option -%c\n", arg[i]);
							printHelp();
							exit(1);
					}
				}
			}
		}
		else
		{
			printf("Invalid option %s\n", arg);
			printHelp();
			exit(1);
		}
	}

	// Check whether all mandatory arguments are set
	if(!input) printHelp("No input file specified");
	else if(!output) printHelp("No output file specified");
	else if(!walkLen) printHelp("No walk length specified");
	else if(!numWalks) printHelp("Number of walks unspecified");

	//const uint64_t flags = Graph::flag_optiTransOrder | Graph::flag_undirected;
	std::string const fileContent(readFile(input));
	std::unique_ptr<Graph> graph(weighted ? new WeightedGraph(WeightedGraph::readGraph(fileContent, flags)) : new Graph(Graph::readGraph(fileContent, flags)));
	uint const to = graph->getNumNodes();

	if(print) printf("%s", graph->toString().c_str());

	Out out(output);
	doWalk(*graph, 0, to, walkLen, numWalks, out);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, 0x38(%rsp)
movl %edi, 0x2c(%rsp)
movslq %edi, %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x30(%rsp)
pushq $0x1
popq %r14
leaq 0x175a(%rip), %r13      # 0x6268
movq $0x0, 0x20(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq 0x40(%rsp), %r14
jge 0x4ceb
movq 0x38(%rsp), %rax
movq (%rax,%r14,8), %rbx
cmpb $0x2d, (%rbx)
jne 0x4e48
movq %rbx, %rdi
callq 0x20a0
cmpb $0x2d, 0x1(%rbx)
jne 0x4c09
addq $0x2, %rbx
movq %rbx, %rdi
leaq 0x1720(%rip), %rsi      # 0x628c
callq 0x2240
testl %eax, %eax
je 0x4c4e
movq %rbx, %rdi
leaq 0x1507(%rip), %rsi      # 0x608a
callq 0x2240
testl %eax, %eax
je 0x4c57
movq %rbx, %rdi
leaq 0x1701(%rip), %rsi      # 0x629b
callq 0x2240
testl %eax, %eax
je 0x4c60
movq %rbx, %rdi
leaq 0x16f2(%rip), %rsi      # 0x62a3
callq 0x2240
testl %eax, %eax
je 0x4c66
movq %rbx, %rdi
leaq 0x16e4(%rip), %rsi      # 0x62ac
callq 0x2240
testl %eax, %eax
je 0x4c6b
movq 0x38(%rsp), %rax
leaq (%rax,%r14,8), %rsi
movl 0x2c(%rsp), %edi
subl %r14d, %edi
movl %edi, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
leaq 0x16bd(%rip), %rdx      # 0x62b2
callq 0x4f16
testq %rax, %rax
je 0x4c70
movq %rax, 0x30(%rsp)
jmp 0x4ce3
pushq $0x1
popq %rcx
cmpq %rcx, %rax
je 0x4ce3
movzbl (%rbx,%rcx), %edx
leal -0x6f(%rdx), %esi
cmpl $0x8, %esi
ja 0x4e24
movslq (%r13,%rsi,4), %rsi
addq %r13, %rsi
jmpq *%rsi
orq $0x2, %r15
jmp 0x4c49
movb $0x1, %r12b
jmp 0x4c49
orq $0x8, %r15
jmp 0x4c49
orq $0x1, %r15
jmp 0x4c49
movb $0x1, %bpl
incq %rcx
jmp 0x4c0c
orq $0x2, %r15
jmp 0x4ce3
orq $0x1, %r15
jmp 0x4ce3
orq $0x8, %r15
jmp 0x4ce3
movb $0x1, %r12b
jmp 0x4ce3
movb $0x1, %bpl
jmp 0x4ce3
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0x1635(%rip), %rdx      # 0x62b5
callq 0x4f16
testq %rax, %rax
je 0x4c91
movq %rax, 0x20(%rsp)
jmp 0x4ce3
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0x1617(%rip), %rdx      # 0x62b8
callq 0x4f16
testq %rax, %rax
je 0x4cb9
movq %rax, %rdi
callq 0x387e
movl %eax, 0x14(%rsp)
jmp 0x4ce3
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0x15f6(%rip), %rdx      # 0x62bf
callq 0x4f16
testq %rax, %rax
je 0x4e96
movq %rax, %rdi
callq 0x387e
movl %eax, 0x10(%rsp)
incq %r14
jmp 0x4b2f
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x4e66
cmpq $0x0, 0x20(%rsp)
movl 0x14(%rsp), %r13d
je 0x4e72
testl %r13d, %r13d
je 0x4e7e
cmpl $0x0, 0x10(%rsp)
je 0x4e8a
leaq 0x48(%rsp), %rdi
callq 0x3739
testb $0x1, %r12b
je 0x4d5e
pushq $0x28
popq %rdi
callq 0x2190
movq %rax, %rbx
leaq 0xb8(%rsp), %r14
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x2220
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x412a
jmp 0x4d8c
pushq $0x20
popq %rdi
callq 0x2190
movq %rax, %rbx
leaq 0x98(%rsp), %r14
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x2220
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x26ee
movq %r14, %rdi
callq 0x20b0
movl 0x8(%rbx), %r15d
testb $0x1, %bpl
je 0x4dca
movq (%rbx), %rax
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
callq *0x20(%rax)
leaq 0x68(%rsp), %r14
movq (%r14), %rsi
leaq 0x15b7(%rip), %rdi      # 0x6372
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
callq 0x20b0
leaq 0x68(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x515a
leaq 0x68(%rsp), %r9
movq %rbx, %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r13d, %ecx
movl 0x10(%rsp), %r8d
callq 0x506e
leaq 0x68(%rsp), %rdi
callq 0x5186
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x48(%rsp), %rdi
callq 0x20b0
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %edx
jne 0x4e35
callq 0x4fa9
xorl %edi, %edi
callq 0x2200
movsbl %dl, %esi
leaq 0x14a0(%rip), %rdi      # 0x62df
xorl %eax, %eax
callq 0x2040
jmp 0x4e59
leaq 0x14aa(%rip), %rdi      # 0x62f9
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2040
callq 0x4fa9
pushq $0x1
popq %rdi
callq 0x2200
leaq 0x149f(%rip), %rdi      # 0x630c
callq 0x504f
leaq 0x14ab(%rip), %rdi      # 0x6324
callq 0x504f
leaq 0x14b8(%rip), %rdi      # 0x633d
callq 0x504f
leaq 0x14c5(%rip), %rdi      # 0x6356
callq 0x504f
leaq 0x1428(%rip), %rsi      # 0x62c5
movq %rbx, %rdi
callq 0x2240
testl %eax, %eax
je 0x4e29
leaq 0x141a(%rip), %rdi      # 0x62ca
jmp 0x4e4f
jmp 0x4ef8
movq %rax, %r14
leaq 0x98(%rsp), %rdi
jmp 0x4ecc
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
callq 0x20b0
jmp 0x4ed8
jmp 0x4ed5
movq %rax, %r14
movq %rbx, %rdi
callq 0x2170
jmp 0x4f04
jmp 0x4ee4
movq %rax, %r14
jmp 0x4f04
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x5186
jmp 0x4efb
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x48(%rsp), %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x22c0