// File: /workspace/github_c_makefile_star2_O0/pwelke[P]GraphMiningTools/cactustree.c
// Function: computeComponentTree
struct Graph *computeComponentTree(struct Vertex **representatives,  struct ShallowGraph * bComponents, int numComponents, struct ShallowGraph **rootedComponents, struct GraphPool *gPool){
    struct Graph * componentTree = createGraph(numComponents, gPool);
    struct ShallowGraph *tmp, *shlp;
    int oldNumber, newNumber;
    struct Vertex *currentRoot;
    //TODO error behviour for componentTree 
    //printf("constructing component Tree\n");
    shlp=bComponents;
    while(shlp){
        currentRoot=shlp->edges->startPoint;
        oldNumber=currentRoot->number;
        newNumber=currentRoot->d;
        //No root should be processed twice, to avoid double edges.
        if(!(currentRoot->visited)){
            currentRoot->visited=1;
            //setting backreference to original graph.
            componentTree->vertices[newNumber]->d=oldNumber;
            //printf("testing for representative\n");
            if(representatives[oldNumber]){
                //printf("adding edge between original (%i,%i) and new (%i,%i)\n",representatives[shlp->edges->startPoint->number]->number, 
                        //shlp->edges->startPoint->number, newNumber, representatives[oldNumber]->d);
                addEdgeBetweenVertices(newNumber,representatives[oldNumber]->d,NULL,componentTree,gPool);
            }
            shlp->data=1;
            rootedComponents[newNumber]=shlp;
            shlp=shlp->next;
            rootedComponents[newNumber]->next=NULL; 
        }
        else{
            tmp=shlp->next;
            //data is used to keep track of componnents assigned to a root.
            shlp->data=rootedComponents[newNumber]->data+1;
            shlp->next=rootedComponents[newNumber];
            rootedComponents[newNumber]=shlp;
            shlp=tmp;
        }
    }
    return componentTree;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movl %edx, 0x44(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movl 0x44(%rsp), %edi
movq 0x30(%rsp), %rsi
callq 0xb850
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x3273
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rax
movl 0x28(%rax), %eax
movl %eax, 0x10(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x3210
movq 0x8(%rsp), %rax
movl $0x1, 0x1c(%rax)
movl 0x14(%rsp), %ecx
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rax
movslq 0x10(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0x28(%rax)
movq 0x50(%rsp), %rax
movslq 0x14(%rsp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x31cb
movl 0x10(%rsp), %edi
movq 0x50(%rsp), %rax
movslq 0x14(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x28(%rax), %esi
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
xorl %eax, %eax
movl %eax, %edx
callq 0xb670
movq 0x18(%rsp), %rax
movl $0x1, 0x28(%rax)
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x18(%rax)
jmp 0x326e
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rax
movslq 0x10(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3129
movq 0x28(%rsp), %rax
addq $0x58, %rsp
retq
nopl (%rax)