// File: /workspace/github_cpp_makefile_star2_O1/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 $0xc8, %rsp
movq %rsi, 0x30(%rsp)
cmpl $0x2, %edi
jl 0x533a
movl %edi, %eax
movq %rax, 0x28(%rsp)
xorl %r15d, %r15d
movl $0x1, %r13d
leaq 0x117e(%rip), %r12      # 0x62c4
xorl %ebx, %ebx
xorl %ebp, %ebp
movl $0x0, (%rsp)
movl $0x0, 0x4(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq (%rax,%r13,8), %r14
cmpb $0x2d, (%r14)
jne 0x5528
movq %r14, %rdi
callq 0x20a0
cmpb $0x2d, 0x1(%r14)
jne 0x523e
addq $0x2, %r14
movq %r14, %rdi
leaq 0x1149(%rip), %rsi      # 0x62e8
callq 0x2210
testl %eax, %eax
je 0x528f
movq %r14, %rdi
leaq 0xf30(%rip), %rsi       # 0x60e6
callq 0x2210
testl %eax, %eax
je 0x5298
movq %r14, %rdi
leaq 0x112a(%rip), %rsi      # 0x62f7
callq 0x2210
testl %eax, %eax
je 0x52a1
movq %r14, %rdi
leaq 0x111b(%rip), %rsi      # 0x62ff
callq 0x2210
testl %eax, %eax
je 0x52a7
movq %r14, %rdi
leaq 0x110d(%rip), %rsi      # 0x6308
callq 0x2210
testl %eax, %eax
je 0x52ab
movq 0x30(%rsp), %rax
leaq (%rax,%r13,8), %rsi
movq 0x28(%rsp), %rdi
subq %r13, %rdi
movq %rdi, 0x10(%rsp)
movq %rsi, 0x18(%rsp)
leaq 0x10e4(%rip), %rdx      # 0x630e
callq 0x5643
testq %rax, %rax
je 0x52b0
movq %rax, 0x20(%rsp)
jmp 0x5325
movq %rax, %rcx
decq %rcx
je 0x5325
movl $0x1, %ecx
movzbl (%r14,%rcx), %edx
leal -0x6f(%rdx), %esi
cmpl $0x8, %esi
ja 0x5504
movslq (%r12,%rsi,4), %rsi
addq %r12, %rsi
jmpq *%rsi
orq $0x2, %r15
jmp 0x5282
movb $0x1, %bl
jmp 0x5282
orq $0x8, %r15
jmp 0x5282
orq $0x1, %r15
jmp 0x5282
movb $0x1, %bpl
incq %rcx
cmpq %rcx, %rax
jne 0x524f
jmp 0x5325
orq $0x2, %r15
jmp 0x5325
orq $0x1, %r15
jmp 0x5325
orq $0x8, %r15
jmp 0x5325
movb $0x1, %bl
jmp 0x5325
movb $0x1, %bpl
jmp 0x5325
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x1050(%rip), %rdx      # 0x6311
callq 0x5643
testq %rax, %rax
je 0x52d2
movq %rax, 0x8(%rsp)
jmp 0x5325
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x1031(%rip), %rdx      # 0x6314
callq 0x5643
testq %rax, %rax
je 0x52fb
movq %rax, %rdi
callq 0x3aab
movl %eax, 0x4(%rsp)
jmp 0x5325
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x100f(%rip), %rdx      # 0x631b
callq 0x5643
testq %rax, %rax
je 0x5588
movq %rax, %rdi
callq 0x3aab
movl %eax, (%rsp)
incq %r13
cmpq 0x28(%rsp), %r13
jne 0x516b
movq 0x20(%rsp), %rsi
jmp 0x535b
xorl %esi, %esi
movq $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl $0x0, (%rsp)
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r15d, %r15d
testq %rsi, %rsi
je 0x5548
cmpq $0x0, 0x8(%rsp)
je 0x5558
cmpl $0x0, 0x4(%rsp)
je 0x5568
cmpl $0x0, (%rsp)
je 0x5578
leaq 0x38(%rsp), %rdi
callq 0x397b
testb $0x1, %bl
je 0x53d6
movl $0x28, %edi
callq 0x2180
movq %rax, %r13
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x59fc
leaq 0x78(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x44c6
jmp 0x5416
movl $0x20, %edi
callq 0x2180
movq %rax, %r12
leaq 0x68(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x59fc
leaq 0x58(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x281a
movq %r12, %r13
testb $0x1, %bl
je 0x5425
leaq 0x88(%rsp), %rax
jmp 0x542a
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5438
callq 0x2160
movl 0x8(%r13), %ebx
testb $0x1, %bpl
je 0x547c
movq (%r13), %rax
leaq 0x98(%rsp), %rdi
movq %r13, %rsi
callq *0x20(%rax)
leaq 0xa8(%rsp), %r14
movq -0x10(%r14), %rsi
leaq 0xf67(%rip), %rdi       # 0x63ce
xorl %eax, %eax
callq 0x2040
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x547c
callq 0x2160
leaq 0xcb9(%rip), %rsi       # 0x613c
movq 0x8(%rsp), %rdi
callq 0x21c0
leaq 0x98(%rsp), %r9
movq %rax, (%r9)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r9)
movups %xmm0, 0x18(%r9)
movq $0x0, 0x28(%r9)
movq %r13, %rdi
xorl %esi, %esi
movl %ebx, %edx
movl 0x4(%rsp), %ecx
movl (%rsp), %r8d
callq 0x57a1
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x54d3
callq 0x2170
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x54f0
callq 0x2160
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %edx
jne 0x5515
callq 0x56d8
xorl %edi, %edi
callq 0x21e0
movsbl %dl, %esi
leaq 0xe1c(%rip), %rdi       # 0x633b
xorl %eax, %eax
callq 0x2040
jmp 0x5539
leaq 0xe26(%rip), %rdi       # 0x6355
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
callq 0x56d8
movl $0x1, %edi
callq 0x21e0
leaq 0xe9e(%rip), %rdi       # 0x63ed
leaq 0xe12(%rip), %rsi       # 0x6368
jmp 0x5532
leaq 0xe8e(%rip), %rdi       # 0x63ed
leaq 0xe1a(%rip), %rsi       # 0x6380
jmp 0x5532
leaq 0xe7e(%rip), %rdi       # 0x63ed
leaq 0xe23(%rip), %rsi       # 0x6399
jmp 0x5532
leaq 0xe6e(%rip), %rdi       # 0x63ed
leaq 0xe2c(%rip), %rsi       # 0x63b2
jmp 0x5532
leaq 0xd92(%rip), %rsi       # 0x6321
movq %r14, %rdi
callq 0x2210
testl %eax, %eax
je 0x5509
leaq 0xd80(%rip), %rdi       # 0x6326
jmp 0x552f
movq %rax, %r14
jmp 0x55f1
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x55c4
callq 0x2160
jmp 0x55c4
movq %rax, %r14
movq %r12, %rdi
callq 0x2160
xorl %ebx, %ebx
jmp 0x5600
movq %rax, %r14
movb $0x1, %bl
jmp 0x561b
movq %rax, %r14
jmp 0x5628
movq %rax, %r14
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x55f1
callq 0x2170
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
jmp 0x5628
movq %rax, %r14
testb $0x1, %bl
je 0x561b
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x561b
callq 0x2160
testb $0x1, %bl
je 0x5628
movq %r13, %rdi
callq 0x2160
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x563b
callq 0x2160
movq %r14, %rdi
callq 0x2290