// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/loading.c
// Function: readSimpleFormat
struct Graph* readSimpleFormat(char* filename, int undirected, struct GraphPool *p, int strspace) {
	int i;
	int v, w;
	FILE* file = NULL;
	struct VertexList *e, *f;
	struct Graph* g = getGraph(p);

	if ((file = fopen(filename, "r")) ){

		/* read info on the graph */
		if (fscanf(file, "%i %i \n", &(g->n), &(g->m)) == 2) {
			/* create vertex pointer array. The actual vertices are taken from vp*/

			if (!setVertexNumber(g, g->n)) {
				printf("Error allocating memory for vertex array.\n");
				fclose(file);
				free(g);
				return NULL;
			}

			/* read vertex info */
			for (i=0; i<g->n; ++i) {
				g->vertices[i] = getVertex(p->vertexPool);
				g->vertices[i]->label = malloc(strspace * sizeof(char));
				/* the vertex is the primary owner of its label string, other vertices may refer to its 
				string but must not free it, if deleted*/
				g->vertices[i]->isStringMaster = 1;
				if (fscanf(file, "%i %s\n", &(g->vertices[i] ->number), g->vertices[i] ->label) != 2) {
					printf("Error reading vertex %i\n", i);
					return NULL;
				}
			}

			/* read info on edges */
			for (i=0; i< g->m; ++i) { 
				e = getVertexList(p->listPool);
				e->label = malloc(strspace * sizeof(char));
				if (fscanf(file, "%i %i %s\n", &v, &w, e->label) == 3) {
					e->startPoint = g->vertices[v];
					e->endPoint = g->vertices[w];
					/* the edge is the primary owner of its label string, other edges may refer to its 
					string but must not free it, if deleted*/
					e->isStringMaster = 1;

					/* if graph is undirected, add two edges, if it is directed add one edge */
					addEdge(g->vertices[e->startPoint->number], e);
					if (undirected) {
						f = shallowCopyEdge(e, p->listPool);
						f->startPoint = e->endPoint;
						f->endPoint = e->startPoint;
						addEdge(g->vertices[f->startPoint->number], f);						
					}
				} else {
					printf("Error reading edge %i\n", i);
					fclose(file);
					return NULL;
				}
			}


		} else {
			printf("Error reading the file %s\n", filename);
			fclose(file);
			return NULL;
		}
	} else {
		printf("Error opening the file %s\n", filename);
		return NULL;
	}

	fclose(file);
	return g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %r15
movl %esi, 0x4(%rsp)
movq %rdi, %r12
movq %rdx, %rdi
callq 0x11619
movq %rax, %rbx
leaq 0x128a1(%rip), %rsi     # 0x1d0fd
movq %r12, %rdi
callq 0x11c0
testq %rax, %rax
je 0xa915
movq %rax, %r14
movq %rbx, %rcx
addq $0x4, %rcx
leaq 0x12cfe(%rip), %rsi     # 0x1d57c
movq %rax, %rdi
movq %rbx, %rdx
movq %rcx, 0x10(%rsp)
xorl %eax, %eax
callq 0x1060
cmpl $0x2, %eax
jne 0xa92d
movl (%rbx), %esi
movq %rbx, %rdi
callq 0x5c80
testq %rax, %rax
je 0xa94d
movslq %ebp, %r13
leaq 0x12cea(%rip), %r12     # 0x1d5a0
xorl %ebp, %ebp
movslq (%rbx), %rax
cmpq %rax, %rbp
jge 0xa970
movq 0x10(%r15), %rdi
callq 0x114a5
movq 0x10(%rbx), %rcx
movq %rax, (%rcx,%rbp,8)
movq %r13, %rdi
callq 0x1180
movq 0x10(%rbx), %rcx
movq (%rcx,%rbp,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%rbp,8), %rdx
movl $0x1, 0x24(%rdx)
movq (%rdx), %rcx
addq $0x18, %rdx
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1060
cmpl $0x2, %eax
jne 0xaa33
incq %rbp
jmp 0xa8b8
leaq 0x12cbd(%rip), %rdi     # 0x1d5d9
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x10b0
jmp 0xaa45
leaq 0x12c8a(%rip), %rdi     # 0x1d5be
xorl %ebx, %ebx
movq %r12, %rsi
xorl %eax, %eax
callq 0x10b0
movq %r14, %rdi
callq 0x1090
jmp 0xaa45
leaq 0x12e8d(%rip), %rdi     # 0x1d7e1
callq 0x1070
movq %r14, %rdi
callq 0x1090
movq %rbx, %rdi
callq 0x1030
xorl %ebx, %ebx
jmp 0xaa45
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
cmpl (%rax), %ebp
jge 0xa940
movq 0x18(%r15), %rdi
callq 0x11307
movq %rax, %r12
movq %r13, %rdi
callq 0x1180
movq %rax, (%r12)
movq %r14, %rdi
leaq 0x12c00(%rip), %rsi     # 0x1d59d
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x1060
cmpl $0x3, %eax
jne 0xaa57
movq 0x10(%rbx), %rax
movslq 0xc(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq %rcx, 0x10(%r12)
movslq 0x8(%rsp), %rdx
movq (%rax,%rdx,8), %rdx
movq %rdx, 0x18(%r12)
movl $0x1, 0x28(%r12)
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x5b2c
cmpl $0x0, 0x4(%rsp)
je 0xaa2c
movq 0x18(%r15), %rsi
movq %r12, %rdi
callq 0x5a28
movq 0x18(%r12), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%r12), %rdx
movq %rdx, 0x18(%rax)
movq 0x10(%rbx), %rdx
movslq 0x18(%rcx), %rcx
movq (%rdx,%rcx,8), %rdi
movq %rax, %rsi
callq 0x5b2c
incl %ebp
jmp 0xa972
leaq 0x12b4a(%rip), %rdi     # 0x1d584
xorl %ebx, %ebx
movl %ebp, %esi
xorl %eax, %eax
callq 0x10b0
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12b49(%rip), %rdi     # 0x1d5a7
xorl %ebx, %ebx
movl %ebp, %esi
xorl %eax, %eax
callq 0x10b0
jmp 0xa940