// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movq %rdx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x38(%rsp), %rdi
callq 0x1fa40
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rdi
leaq 0x2182e(%rip), %rsi     # 0x35158
callq 0x11b0
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x13c47
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
movq 0x8(%rsp), %rcx
addq $0x4, %rcx
leaq 0x21c6c(%rip), %rsi     # 0x355c4
movb $0x0, %al
callq 0x1050
cmpl $0x2, %eax
jne 0x13c1d
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rax
movl (%rax), %esi
callq 0xaa00
cmpq $0x0, %rax
jne 0x139af
leaq 0x21c46(%rip), %rdi     # 0x355cc
movb $0x0, %al
callq 0x1090
movq 0x20(%rsp), %rdi
callq 0x1070
movq 0x8(%rsp), %rdi
callq 0x1030
movq $0x0, 0x50(%rsp)
jmp 0x13c79
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x13a9f
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x1f6a0
movq %rax, %rdx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq 0x34(%rsp), %rdi
shlq $0x0, %rdi
callq 0x1170
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x1, 0x24(%rax)
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
addq $0x18, %rdx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rcx
leaq 0x21bb2(%rip), %rsi     # 0x35613
movb $0x0, %al
callq 0x1050
cmpl $0x2, %eax
je 0x13a8d
movl 0x30(%rsp), %esi
leaq 0x21b7f(%rip), %rdi     # 0x355f7
movb $0x0, %al
callq 0x1090
movq $0x0, 0x50(%rsp)
jmp 0x13c79
jmp 0x13a8f
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x139b7
movl $0x0, 0x30(%rsp)
movl 0x30(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x13c1b
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x1f310
movq %rax, 0x18(%rsp)
movslq 0x34(%rsp), %rdi
shlq $0x0, %rdi
callq 0x1170
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rax
movq (%rax), %r8
leaq 0x21b17(%rip), %rsi     # 0x35610
leaq 0x2c(%rsp), %rdx
leaq 0x28(%rsp), %rcx
movb $0x0, %al
callq 0x1050
cmpl $0x3, %eax
jne 0x13be2
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x2c(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rax
movl $0x1, 0x28(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x18(%rsp), %rsi
callq 0xa660
cmpl $0x0, 0x44(%rsp)
je 0x13be0
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0xa310
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
callq 0xa660
jmp 0x13c09
movl 0x30(%rsp), %esi
leaq 0x21a2d(%rip), %rdi     # 0x3561a
movb $0x0, %al
callq 0x1090
movq 0x20(%rsp), %rdi
callq 0x1070
movq $0x0, 0x50(%rsp)
jmp 0x13c79
jmp 0x13c0b
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x13aa7
jmp 0x13c45
movq 0x48(%rsp), %rsi
leaq 0x21a08(%rip), %rdi     # 0x35631
movb $0x0, %al
callq 0x1090
movq 0x20(%rsp), %rdi
callq 0x1070
movq $0x0, 0x50(%rsp)
jmp 0x13c79
jmp 0x13c65
movq 0x48(%rsp), %rsi
leaq 0x219f9(%rip), %rdi     # 0x3564c
movb $0x0, %al
callq 0x1090
movq $0x0, 0x50(%rsp)
jmp 0x13c79
movq 0x20(%rsp), %rdi
callq 0x1070
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopw %cs:(%rax,%rax)