// File: /workspace/github_c_makefile_star2_O3/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:
testq %rdi, %rdi
je 0x471a
pushq %rbx
movl %edx, %ecx
notl %ecx
movq $-0x1, %rax
movq %rdi, %r8
movq 0x8(%rsi,%rax,8), %r9
incq %rax
testq %r9, %r9
je 0x46c2
movq 0x10(%r9), %r10
movq 0x18(%r9), %r11
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x4658
cmpq %r11, 0x18(%r10)
jne 0x4645
orl %edx, 0x24(%r10)
movq 0x8(%r9), %r9
testq %r9, %r9
jne 0x471d
movq (%r8), %r9
movq %r9, (%rsi,%rax,8)
movq 0x10(%r9), %r10
movq 0x18(%r9), %r11
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x46b9
cmpq %r11, 0x18(%r10)
jne 0x4674
andl %ecx, 0x24(%r10)
jmp 0x46b9
movq 0x10(%r9), %r11
movq 0x18(%r9), %r10
movq %r11, %rbx
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x46a6
cmpq %r10, 0x18(%rbx)
jne 0x4694
andl %ecx, 0x24(%rbx)
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x46b9
cmpq %r11, 0x18(%r10)
jne 0x46a6
orl %edx, 0x24(%r10)
movq 0x8(%r9), %r9
testq %r9, %r9
jne 0x4689
movq 0x18(%r8), %r8
testq %r8, %r8
jne 0x462c
movq (%rdi), %rax
testq %rax, %rax
je 0x470d
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
movq %rsi, %r8
movq 0x8(%r8), %r8
testq %r8, %r8
je 0x46f5
cmpq %rdx, 0x18(%r8)
jne 0x46e2
andl %ecx, 0x24(%r8)
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x4707
cmpq %rsi, 0x18(%rdx)
jne 0x46f5
andl %ecx, 0x24(%rdx)
movq 0x8(%rax), %rax
jmp 0x46d2
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
jne 0x46cf
xorl %eax, %eax
jmp 0x473d
xorl %eax, %eax
retq
movq %r9, (%rsi,%rax,8)
movq 0x10(%r9), %rsi
movq 0x18(%r9), %rdx
movq 0x8(%rdx), %rdx
movb $0x1, %al
testq %rdx, %rdx
je 0x473d
cmpq %rsi, 0x18(%rdx)
jne 0x4729
andl %ecx, 0x24(%rdx)
popq %rbx
retq