// File: /workspace/github_cpp_makefile_star2_O3/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)
cmpl $0x2, %edi
jl 0x55a7
movl %edi, 0x2c(%rsp)
movl %edi, %eax
movq %rax, 0x40(%rsp)
xorl %r15d, %r15d
movl $0x1, %r12d
leaq 0x10f6(%rip), %r14      # 0x62c4
xorl %r13d, %r13d
xorl %ebx, %ebx
movl $0x0, 0x10(%rsp)
movl $0x0, 0x14(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x38(%rsp), %rax
movq (%rax,%r12,8), %rbp
cmpb $0x2d, (%rbp)
jne 0x5587
movq %rbp, %rdi
callq 0x20a0
cmpb $0x2d, 0x1(%rbp)
jne 0x52c5
addq $0x2, %rbp
movq %rbp, %rdi
leaq 0x10c0(%rip), %rsi      # 0x62e8
callq 0x2210
testl %eax, %eax
je 0x5316
movq %rbp, %rdi
leaq 0xea7(%rip), %rsi       # 0x60e6
callq 0x2210
testl %eax, %eax
je 0x531f
movq %rbp, %rdi
leaq 0x10a1(%rip), %rsi      # 0x62f7
callq 0x2210
testl %eax, %eax
je 0x5328
movq %rbp, %rdi
leaq 0x1092(%rip), %rsi      # 0x62ff
callq 0x2210
testl %eax, %eax
je 0x532e
movq %rbp, %rdi
leaq 0x1084(%rip), %rsi      # 0x6308
callq 0x2210
testl %eax, %eax
je 0x5333
movq 0x38(%rsp), %rax
leaq (%rax,%r12,8), %rsi
movl 0x2c(%rsp), %edi
subl %r12d, %edi
movl %edi, 0xc(%rsp)
movq %rsi, 0x18(%rsp)
leaq 0x105d(%rip), %rdx      # 0x630e
callq 0x567d
testq %rax, %rax
je 0x5337
movq %rax, 0x30(%rsp)
jmp 0x53aa
movq %rax, %rcx
decq %rcx
je 0x53aa
movl $0x1, %ecx
movzbl (%rbp,%rcx), %edx
leal -0x6f(%rdx), %esi
cmpl $0x8, %esi
ja 0x5563
movslq (%r14,%rsi,4), %rsi
addq %r14, %rsi
jmpq *%rsi
orq $0x2, %r15
jmp 0x5309
movb $0x1, %r13b
jmp 0x5309
orq $0x8, %r15
jmp 0x5309
orq $0x1, %r15
jmp 0x5309
movb $0x1, %bl
incq %rcx
cmpq %rcx, %rax
jne 0x52d6
jmp 0x53aa
orq $0x2, %r15
jmp 0x53aa
orq $0x1, %r15
jmp 0x53aa
orq $0x8, %r15
jmp 0x53aa
movb $0x1, %r13b
jmp 0x53aa
movb $0x1, %bl
jmp 0x53aa
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0xfca(%rip), %rdx       # 0x6311
callq 0x567d
testq %rax, %rax
je 0x5358
movq %rax, 0x20(%rsp)
jmp 0x53aa
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0xfac(%rip), %rdx       # 0x6314
callq 0x567d
testq %rax, %rax
je 0x5380
movq %rax, %rdi
callq 0x3a63
movl %eax, 0x14(%rsp)
jmp 0x53aa
movl 0xc(%rsp), %edi
movq 0x18(%rsp), %rsi
leaq 0xf8b(%rip), %rdx       # 0x631b
callq 0x567d
testq %rax, %rax
je 0x55e7
movq %rax, %rdi
callq 0x3a63
movl %eax, 0x10(%rsp)
incq %r12
cmpq 0x40(%rsp), %r12
jne 0x51f5
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x55a7
cmpq $0x0, 0x20(%rsp)
movl 0x14(%rsp), %r14d
je 0x55b7
testl %r14d, %r14d
je 0x55c7
cmpl $0x0, 0x10(%rsp)
je 0x55d7
leaq 0x48(%rsp), %rdi
callq 0x3933
testb $0x1, %r13b
je 0x544b
movl $0x28, %edi
callq 0x2180
movq %rax, %r12
leaq 0x98(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x5a5c
leaq 0x88(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x4478
movq 0x88(%rsp), %rdi
jmp 0x548d
movl $0x20, %edi
callq 0x2180
movq %rax, %r12
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x5a5c
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x278c
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x5497
callq 0x2160
movl 0x8(%r12), %ebp
testb $0x1, %bl
je 0x54db
movq (%r12), %rax
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq *0x20(%rax)
leaq 0xb8(%rsp), %rbx
movq -0x10(%rbx), %rsi
leaq 0xf08(%rip), %rdi       # 0x63ce
xorl %eax, %eax
callq 0x2040
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x54db
callq 0x2160
leaq 0xc5a(%rip), %rsi       # 0x613c
movq 0x20(%rsp), %rdi
callq 0x21c0
leaq 0xa8(%rsp), %r9
movq %rax, (%r9)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r9)
movups %xmm0, 0x18(%r9)
movq $0x0, 0x28(%r9)
movq %r12, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r14d, %ecx
movl 0x10(%rsp), %r8d
callq 0x57db
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x5532
callq 0x2170
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x554f
callq 0x2160
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x68, %edx
jne 0x5574
callq 0x5712
xorl %edi, %edi
callq 0x21e0
movsbl %dl, %esi
leaq 0xdbd(%rip), %rdi       # 0x633b
xorl %eax, %eax
callq 0x2040
jmp 0x5598
leaq 0xdc7(%rip), %rdi       # 0x6355
movq %rbp, %rsi
xorl %eax, %eax
callq 0x2040
callq 0x5712
movl $0x1, %edi
callq 0x21e0
leaq 0xe3f(%rip), %rdi       # 0x63ed
leaq 0xdb3(%rip), %rsi       # 0x6368
jmp 0x5591
leaq 0xe2f(%rip), %rdi       # 0x63ed
leaq 0xdbb(%rip), %rsi       # 0x6380
jmp 0x5591
leaq 0xe1f(%rip), %rdi       # 0x63ed
leaq 0xdc4(%rip), %rsi       # 0x6399
jmp 0x5591
leaq 0xe0f(%rip), %rdi       # 0x63ed
leaq 0xdcd(%rip), %rsi       # 0x63b2
jmp 0x5591
leaq 0xd33(%rip), %rsi       # 0x6321
movq %rbp, %rdi
callq 0x2210
testl %eax, %eax
je 0x5568
leaq 0xd21(%rip), %rdi       # 0x6326
jmp 0x558e
movq %rax, %r14
jmp 0x5658
movq %rax, %r14
movq 0x68(%rsp), %rdi
jmp 0x5621
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %r13, %rdi
je 0x5632
callq 0x2160
jmp 0x5632
jmp 0x562f
movq %rax, %r14
movq %r12, %rdi
callq 0x2160
jmp 0x5662
jmp 0x563e
movq %rax, %r14
jmp 0x5662
movq %rax, %r14
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x5658
callq 0x2170
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5675
callq 0x2160
movq %r14, %rdi
callq 0x2290