// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/hp_cactus.c
// Function: isWeaklyTraceableUnsafe
char isWeaklyTraceableUnsafe(struct Graph* g, struct ShallowGraphPool* sgp) {
	struct ShallowGraph* biconnectedComponents = listBiconnectedComponents(g, sgp);
	int* criticality = computeCriticality(biconnectedComponents, g->n);
	int v; 
	struct ShallowGraph* c;

	// test if every vertex has criticality at most 2
	for (v=0; v<g->n; ++v) {
		if (criticality[v] > 2) {
			free(criticality);
			dumpShallowGraphCycle(sgp, biconnectedComponents);
			return 0;
		}
	}

	// test if every biconnected component contains at most two critical vertices.
	for (c=biconnectedComponents; c!=NULL; c=c->next) {
		struct VertexList* e;
		int criticalVertexCount = 0;

		// TODO measure if the alg is faster with or without this line
		if (c->m == 1) continue;

		// init ->visited = 0
		for (e=c->edges; e!=NULL; e=e->next) {
			e->startPoint->visited = 0;
			e->endPoint->visited = 0;
		}
		// count critical vertices
		for (e=c->edges; e!=NULL; e=e->next) {
			criticalVertexCount += visit(e->startPoint, criticality);
			criticalVertexCount += visit(e->endPoint, criticality);
		}
		if (criticalVertexCount > 2) {
			free(criticality);
			dumpShallowGraphCycle(sgp, biconnectedComponents);
			return 0;
		 } else {
			/* this is where misclassification might occur.
			we would need to check, if there is a Hamiltonian path in the biconnected
			component starting at one critical vertex and stopping at the other, if 
			there is a Hamiltonian path starting at the single critical vertex, or if there 
			is no critical vertex, if the biconnected block is traceable in any way. */
		}
	}

	// otherwise, there might exist a Hamiltonian path
	return 1;
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x10700
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movq 0x38(%rsp), %rax
movl (%rax), %esi
callq 0x10310
movq %rax, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movq 0x38(%rsp), %rcx
cmpl (%rcx), %eax
jge 0xd30f
movq 0x20(%rsp), %rax
movslq 0x1c(%rsp), %rcx
cmpl $0x2, (%rax,%rcx,4)
jle 0xd300
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x20000
movb $0x0, 0x47(%rsp)
jmp 0xd420
jmp 0xd302
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
jmp 0xd2c0
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x10(%rsp)
je 0xd41b
movl $0x0, 0x4(%rsp)
movq 0x10(%rsp), %rax
cmpl $0x1, 0x10(%rax)
jne 0xd33d
jmp 0xd408
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0xd382
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl $0x0, 0x1c(%rax)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x0, 0x1c(%rax)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0xd34a
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0xd3dd
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0xd1d0
addl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rsp), %rsi
callq 0xd1d0
addl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0xd38f
cmpl $0x2, 0x4(%rsp)
jle 0xd404
movq 0x20(%rsp), %rdi
callq 0x1030
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x20000
movb $0x0, 0x47(%rsp)
jmp 0xd420
jmp 0xd406
jmp 0xd408
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0xd319
movb $0x1, 0x47(%rsp)
movb 0x47(%rsp), %al
addq $0x48, %rsp
retq
nopl (%rax)