// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/cactustree.c
// Function: nextSpanningTree
char nextSpanningTree(struct ShallowGraph *rootedComponent, struct VertexList **deletedEdges, int mask){
    int i =-1;
    struct ShallowGraph *shlp=rootedComponent;
    struct VertexList *ehlp;
    while(shlp){
        if(deletedEdges[++i]==NULL) shlp=shlp->next;
        else{//indicator for component of size > 1
            //Reinsert Edge into Graph
            markEdgeBetweenVertices(deletedEdges[i]->startPoint,deletedEdges[i]->endPoint,mask);
            //advance insertion point
            if(deletedEdges[i]->next==NULL){//The last edge removed was the last of the component.
                //reset to start of list, therfore we would have an already processed spanning tree and do not break but advance the next position.
                deletedEdges[i]=shlp->edges;
                unmarkEdgeBetweenVertices(shlp->edges->startPoint, shlp->edges->endPoint,mask);
                //we now have to reverse all edges, as we removed the first of that component/circle.
                for(ehlp=shlp->edges->next; ehlp; ehlp=ehlp->next){
                    unmarkEdgeBetweenVertices(ehlp->startPoint,ehlp->endPoint,mask);
                    markEdgeBetweenVertices(ehlp->endPoint, ehlp->startPoint,mask);
                }
                shlp=shlp->next;
            }
            else{
                deletedEdges[i]=deletedEdges[i]->next;
                //now remove the edge pointing in the other direction.
                unmarkEdgeBetweenVertices(deletedEdges[i]->endPoint, deletedEdges[i]->startPoint,mask);
                return 1;//we do not have to advance any further, this is a new spanning tree.
            }
        }
    }
    //We did not return early therefore we have now computed all possible spanning trees
    //No we unmark all the edges.
    for(shlp=rootedComponent;shlp;shlp=shlp->next){
        for(ehlp=shlp->edges;ehlp;ehlp=ehlp->next){
            unmarkEdgeBetweenVertices(ehlp->startPoint,ehlp->endPoint,mask);
            unmarkEdgeBetweenVertices(ehlp->endPoint,ehlp->startPoint,mask);
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
pushq $-0x1
popq %r12
movq %rdi, %r13
testq %r13, %r13
je 0x2887
movq 0x8(%r15,%r12,8), %rax
incq %r12
testq %rax, %rax
je 0x284e
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
movl %ebx, %edx
callq 0x2e05
movq (%r15,%r12,8), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x2890
movq (%r13), %rax
movq %rax, (%r15,%r12,8)
movq 0x10(%rax), %rdi
movq 0x18(%rax), %rsi
movl %ebx, %edx
callq 0x2df0
movq (%r13), %rbp
movq 0x8(%rbp), %rbp
testq %rbp, %rbp
je 0x284e
movq 0x10(%rbp), %rdi
movq 0x18(%rbp), %rsi
movl %ebx, %edx
callq 0x2df0
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdi
movl %ebx, %edx
callq 0x2e05
jmp 0x2825
movq 0x18(%r13), %r13
jmp 0x27d4
movq %r14, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x2883
movq 0x10(%r15), %rdi
movq 0x18(%r15), %rsi
movl %ebx, %edx
callq 0x2df0
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdi
movl %ebx, %edx
callq 0x2df0
addq $0x8, %r15
jmp 0x2857
movq 0x18(%r14), %r14
testq %r14, %r14
jne 0x2854
xorl %eax, %eax
jmp 0x28a5
movq %rax, (%r15,%r12,8)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdi
movl %ebx, %edx
callq 0x2df0
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq