// File: /workspace/github_c_makefile_star2_O1/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 0x4720
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 0x46c8
movq 0x10(%r9), %r10
movq 0x18(%r9), %r11
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x465b
cmpq %r11, 0x18(%r10)
jne 0x4648
orl %edx, 0x24(%r10)
movq 0x8(%r9), %r9
testq %r9, %r9
jne 0x4723
movq (%r8), %r9
movq %r9, (%rsi,%rax,8)
movq (%r8), %r9
movq 0x10(%r9), %r10
movq 0x18(%r9), %r11
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x46bf
cmpq %r11, 0x18(%r10)
jne 0x467a
andl %ecx, 0x24(%r10)
jmp 0x46bf
movq 0x10(%r9), %r11
movq 0x18(%r9), %r10
movq %r11, %rbx
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x46ac
cmpq %r10, 0x18(%rbx)
jne 0x469a
andl %ecx, 0x24(%rbx)
movq 0x8(%r10), %r10
testq %r10, %r10
je 0x46bf
cmpq %r11, 0x18(%r10)
jne 0x46ac
orl %edx, 0x24(%r10)
movq 0x8(%r9), %r9
testq %r9, %r9
jne 0x468f
movq 0x18(%r8), %r8
testq %r8, %r8
jne 0x462f
movq (%rdi), %rax
testq %rax, %rax
je 0x4713
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
movq %rsi, %r8
movq 0x8(%r8), %r8
testq %r8, %r8
je 0x46fb
cmpq %rdx, 0x18(%r8)
jne 0x46e8
andl %ecx, 0x24(%r8)
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x470d
cmpq %rsi, 0x18(%rdx)
jne 0x46fb
andl %ecx, 0x24(%rdx)
movq 0x8(%rax), %rax
jmp 0x46d8
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
jne 0x46d5
xorl %eax, %eax
jmp 0x4743
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 0x4743
cmpq %rsi, 0x18(%rdx)
jne 0x472f
andl %ecx, 0x24(%rdx)
popq %rbx
retq