// File: /workspace/github_cpp_makefile_star2_O2/biotomas[P]ipasir/app/genipalsp/genipalsp.cpp
// Function: loadGraph(char const*, bool)
Graph loadGraph(const char* filename, bool backEdges = false) {
	FILE* f = fopen(filename, "r");
	if (f == NULL) {
		log("File '%s' cannot be opened\n", filename);
		exit(1);
	}
	Graph g;
	int c = 0;
	bool edge = true;

	while (c != EOF) {
		c = fgetc(f);

		// problem definition line
		if (c == 'p') {
			char pline[512];
			int i = 0;
			while (c != '\n') {
				pline[i++] = c;
				c = fgetc(f);
			}
			pline[i] = 0;
			if (2 != sscanf(pline, "p edge %d %d", &(g.verticesCount), &(g.edgesCount))) {
				edge = false;
				if (2 != sscanf(pline, "p sp %d %d", &(g.verticesCount), &(g.edgesCount))) {
					log("Failed to parse the problem definition line (%s)\n", pline);
				}
			}
			continue;
		}
		// comment
		if (c == 'c') {
			// skip this line
			while(c != '\n') {
				c = fgetc(f);
			}
			continue;
		}
		// edge
		if (c == 'e' || c == 'a') {
			char pline[512];
			int i = 0;
			while (c != '\n') {
				pline[i++] = c;
				c = fgetc(f);
			}
			pline[i] = 0;
			size_t start, end, weight;
			if (edge && 2 != sscanf(pline, "e %lu %lu", &start , &end)) {
				log("Invalid edge line (%s)\n", pline);
				exit(1);
			}
			if (!edge && 3 != sscanf(pline, "a %lu %lu %lu", &start , &end, &weight)) {
				log("Invalid edge line (%s)\n", pline);
				exit(1);
			}
			while (g.neighbours.size() <= start) {
				g.neighbours.push_back(vector<int>());
			}
			g.neighbours[start].push_back(end);

			if (edge && backEdges) {
				while (g.neighbours.size() <= end) {
					g.neighbours.push_back(vector<int>());
				}
				g.neighbours[end].push_back(start);
			}
			continue;
		}
	}
	fclose(f);
	return g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %edx, 0x1c(%rsp)
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10668(%rip), %rsi     # 0x12bcb
movq %rbx, %rdi
callq 0x21c0
testq %rax, %rax
je 0x27e9
movq %rax, %r15
leaq 0x8(%r14), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r14)
andq $0x0, 0x18(%r14)
leaq 0x4(%r14), %rax
movq %rax, 0x40(%rsp)
movb $0x1, %cl
pushq $0xa
popq %r12
leaq 0x20(%rsp), %rbp
xorl %eax, %eax
movl %ecx, %edx
andb 0x1c(%rsp), %dl
movb %dl, 0x7(%rsp)
cmpl $-0x1, %eax
je 0x27b1
movl %ecx, %r13d
movq %r15, %rdi
callq 0x2280
cmpl $0x63, %eax
je 0x25fc
cmpl $0x70, %eax
je 0x2725
movl %eax, %ecx
andl $-0x5, %ecx
cmpl $0x61, %ecx
movl %r13d, %ecx
jne 0x25a8
xorl %r12d, %r12d
cmpl $0xa, %eax
je 0x2609
movb %al, 0x50(%rsp,%r12)
incq %r12
movq %r15, %rdi
callq 0x2280
movl %r13d, %ecx
jmp 0x25da
movq %r15, %rdi
callq 0x2280
cmpl $0xa, %eax
jne 0x25f4
movl %r12d, %eax
movl %r13d, %ecx
jmp 0x25a8
movl %r12d, %eax
movb $0x0, 0x50(%rsp,%rax)
leaq 0x50(%rsp), %rdi
testb $0x1, %cl
je 0x2638
leaq 0xdabb(%rip), %rsi      # 0x100dd
leaq 0x10(%rsp), %rdx
leaq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x2130
cmpl $0x2, %eax
jmp 0x2658
leaq 0xdac0(%rip), %rsi      # 0x100ff
leaq 0x10(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x48(%rsp), %r8
xorl %eax, %eax
callq 0x2130
cmpl $0x3, %eax
pushq $0xa
popq %r12
jne 0x27ce
movq 0x8(%r14), %rdi
movq 0x10(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq 0x10(%rsp), %rcx
cmpq %rcx, %rax
ja 0x26a2
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x306e
movq %rbp, %rdi
callq 0x303a
jmp 0x2662
imulq $0x18, %rcx, %rax
addq %rax, %rdi
movl 0x8(%rsp), %eax
movl %eax, 0x20(%rsp)
movq %rbp, %rsi
callq 0x3280
cmpb $0x0, 0x7(%rsp)
movl %r13d, %ecx
je 0x271d
movq 0x8(%r14), %rdi
movq 0x10(%r14), %rax
subq %rdi, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
movq 0x8(%rsp), %rcx
cmpq %rcx, %rax
ja 0x2703
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x306e
movq %rbp, %rdi
callq 0x303a
jmp 0x26c3
imulq $0x18, %rcx, %rax
addq %rax, %rdi
movl 0x10(%rsp), %eax
movl %eax, 0x20(%rsp)
movq %rbp, %rsi
callq 0x3280
movl %r13d, %ecx
movl %r12d, %eax
jmp 0x25a8
xorl %r12d, %r12d
pushq $0x70
popq %rax
cmpl $0xa, %eax
je 0x2742
movb %al, 0x50(%rsp,%r12)
incq %r12
movq %r15, %rdi
callq 0x2280
jmp 0x272b
movl %r12d, %eax
movb $0x0, 0x50(%rsp,%rax)
leaq 0x50(%rsp), %r12
movq %r12, %rdi
leaq 0xd93a(%rip), %rsi      # 0x10093
movq %r14, %rdx
movq 0x40(%rsp), %rcx
xorl %eax, %eax
callq 0x2130
cmpl $0x2, %eax
je 0x27a2
xorl %r13d, %r13d
movq %r12, %rdi
leaq 0xd926(%rip), %rsi      # 0x100a0
movq %r14, %rdx
movq 0x40(%rsp), %rcx
xorl %eax, %eax
callq 0x2130
cmpl $0x2, %eax
je 0x27a2
xorl %r13d, %r13d
leaq 0xd913(%rip), %rdi      # 0x100ab
movq %r12, %rsi
xorl %eax, %eax
callq 0x246b
pushq $0xa
popq %r12
movl %r12d, %eax
movl %r13d, %ecx
jmp 0x259e
movq %r15, %rdi
callq 0x2140
movq %r14, %rax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd912(%rip), %rdi      # 0x100e7
leaq 0x50(%rsp), %rsi
xorl %eax, %eax
callq 0x246b
pushq $0x1
popq %rdi
callq 0x21f0
leaq 0xd887(%rip), %rdi      # 0x10077
movq %rbx, %rsi
jmp 0x27da
jmp 0x27f7
movq %rax, %r14
jmp 0x280b
jmp 0x27fe
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x303a
movq %rbx, %rdi
callq 0x2f54
movq %r14, %rdi
callq 0x22d0