// File: /workspace/github_c_makefile_star2_O0/mishun[P]plantri/plantri.c
// Function: canon
static int 
canon(int lcolour[], EDGE *can_numberings[][MAXE], int *nbtot, int *nbop)

/* Checks whether the last vertex (number: nv-1) is canonical or not. 
   Returns 1 if yes, 0 if not. One of the criterions a canonical vertex 
   must fulfill is that its colour is minimal.

   IT IS ASSUMED that the values of the colour function are positive
   and at most INT_MAX-MAXN.
 
   A possible starting edge for the construction of a representation is 
   one with lexicographically minimal colour pair (start,INT_MAX-end).
   In can_numberings[][] the canonical numberings are stored as sequences 
   of oriented edges.  For every 0 <= i,j < *nbtot and every 
   0 <= k < ne the edges can_numberings[i][k] and can_numberings[j][k] can 
   be mapped onto each other by an automorphism. The first 
   *nbop numberings are orientation preserving while 
   the rest is orientation reversing.

   In case of only 1 automorphism, in can_numberings[0][0] the "canonical" 
   edge is given.  It is one edge emanating at the canonical vertex. The 
   rest of the numbering is not given. 

   In case of nontrivial automorphisms, can[0] starts with a list of edges 
   adjacent to nv-1. In case of an orientation preserving numbering the deges 
   are listed in ->next direction, otherwise in ->prev direction.

   Works OK if at least one vertex has valence >= 3. Otherwise some numberings 
   are computed twice, since changing the orientation (the cyclic order around 
   each vertex) doesn't change anything */
{
    int i, last_vertex, test;
    int minstart, maxend; /* (minstart,maxend) will be the chosen colour 
                                pair of an edge */
    EDGE *startlist_last[5], *startlist[5*MAXN], *run, *end;
    int list_length_last, list_length;
    int representation[MAXE];
    EDGE *numblist[MAXE], *numblist_mirror[MAXE]; /* lists of edges where 
                        starting gives a canonical representation */
    int numbs = 1, numbs_mirror = 0;
    int colour[MAXN];

    for (i=0; i<nv; i++) colour[i]=lcolour[i]+MAXN;
                               /* to distinguish colours from vertices */
    last_vertex = nv-1;
    minstart = colour[last_vertex];

/* determine the smallest possible end for the vertex "last_vertex" */

    list_length_last = 1; startlist_last[0] = end = firstedge[last_vertex];
    maxend = colour[end->end];

    for (run = end->next; run != end; run = run->next)
      { if (colour[run->end] > maxend)
          { startlist_last[0] = run; 
            list_length_last = 1; maxend = colour[run->end];}
        else if (colour[run->end] == maxend)
          { startlist_last[list_length_last] = run; list_length_last++; }
      }

/* Now we know the pair that SHOULD be minimal and we can determine a list 
   of all edges with this colour pair. If a new pair is found that is even 
   smaller, we can return 0 at once */

    list_length = 0;

    for (i = 0; i < last_vertex; i++) 
      { if (colour[i] < minstart) return 0;
        if (colour[i] == minstart)
          { run = end = firstedge[i];
            do
            {
              if (colour[run->end] > maxend) return 0;
              if (colour[run->end] == maxend)
                { startlist[list_length] = run; list_length++; }
              run = run->next;
            } while (run != end);
          }
      }

/* OK -- so there is no smaller pair and now we have to determine the 
   smallest representation around vertex "last_vertex": */

    testcanon_first_init(startlist_last[0], representation, colour);
    numblist[0] = startlist_last[0];
    test = testcanon_mirror_init(startlist_last[0], representation, colour);
    if (test == 1) 
      { numbs_mirror = 1; numblist_mirror[0] = startlist_last[0]; }
    else if (test == 2)  
      { numbs_mirror = 1; numbs = 0; 
        numblist_mirror[0] = startlist_last[0]; }

    for (i = 1; i < list_length_last; i++)
      { test = testcanon_init(startlist_last[i], representation, colour);
        if (test == 1) { numblist[numbs] = startlist_last[i]; numbs++; }
        else if (test == 2) 
          { numbs_mirror = 0; numbs = 1; numblist[0] = startlist_last[i]; }
            test = testcanon_mirror_init(startlist_last[i], 
                                                     representation, colour);
          if (test == 1)  
            { numblist_mirror[numbs_mirror] = startlist_last[i]; 
              numbs_mirror++; }
          else if (test == 2) 
            { numbs_mirror = 1; numbs = 0; 
              numblist_mirror[0] = startlist_last[i]; }
      }

/* Now we know the best representation we can obtain starting at last_vertex. 
   Now we will check all the others. We can return 0 at once if we find a 
   better one */

    for (i = 0; i < list_length; i++)
      { test = testcanon(startlist[i], representation, colour);
        if (test == 1) { numblist[numbs] = startlist[i]; numbs++; }
        else if (test == 2) return 0;
        test = testcanon_mirror(startlist[i], representation, colour);
        if (test == 1) 
          { numblist_mirror[numbs_mirror] = startlist[i]; numbs_mirror++; }
        else if (test == 2) return 0;
      }

    *nbop = numbs;
    *nbtot = numbs+numbs_mirror;

    if (*nbtot>1)
      { for (i = 0; i < numbs; i++) 
          construct_numb(numblist[i], can_numberings[i]); 
        for (i = 0; i < numbs_mirror; i++, numbs++) 
          construct_numb_mirror(numblist_mirror[i],can_numberings[numbs]);
      }
    else 
      { if (numbs) can_numberings[0][0] = numblist[0];
        else can_numberings[0][0] = numblist_mirror[0]; }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x28b0, %rsp           # imm = 0x28B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x1, -0x27a4(%rbp)
movl $0x0, -0x27a8(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x2531d1(%rip), %eax    # 0x25a620
jge 0x7475
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
addl $0x40, %ecx
movslq -0x2c(%rbp), %rax
movl %ecx, -0x28b0(%rbp,%rax,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7446
movl 0x2531a5(%rip), %eax    # 0x25a620
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movslq -0x30(%rbp), %rax
movl -0x28b0(%rbp,%rax,4), %eax
movl %eax, -0x38(%rbp)
movl $0x1, -0xa84(%rbp)
movslq -0x30(%rbp), %rcx
leaq 0x3655c(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0xa80(%rbp)
movq %rax, -0x70(%rbp)
movq -0xa80(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
movl %eax, -0x3c(%rbp)
movq -0xa80(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa78(%rbp)
movq -0xa78(%rbp), %rax
cmpq -0xa80(%rbp), %rax
je 0x7585
movq -0xa78(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x3c(%rbp), %eax
jle 0x7531
movq -0xa78(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x1, -0xa84(%rbp)
movq -0xa78(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
movl %eax, -0x3c(%rbp)
jmp 0x756c
movq -0xa78(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x3c(%rbp), %eax
jne 0x756a
movq -0xa78(%rbp), %rcx
movslq -0xa84(%rbp), %rax
movq %rcx, -0x70(%rbp,%rax,8)
movl -0xa84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa84(%rbp)
jmp 0x756c
jmp 0x756e
movq -0xa78(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa78(%rbp)
jmp 0x74da
movl $0x0, -0xa88(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x7686
movslq -0x2c(%rbp), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x38(%rbp), %eax
jge 0x75be
movl $0x0, -0x4(%rbp)
jmp 0x7a05
movslq -0x2c(%rbp), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x38(%rbp), %eax
jne 0x7676
movslq -0x2c(%rbp), %rcx
leaq 0x36423(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0xa80(%rbp)
movq %rax, -0xa78(%rbp)
movq -0xa78(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x3c(%rbp), %eax
jle 0x7612
movl $0x0, -0x4(%rbp)
jmp 0x7a05
movq -0xa78(%rbp), %rax
movslq 0x4(%rax), %rax
movl -0x28b0(%rbp,%rax,4), %eax
cmpl -0x3c(%rbp), %eax
jne 0x764e
movq -0xa78(%rbp), %rcx
movslq -0xa88(%rbp), %rax
movq %rcx, -0xa70(%rbp,%rax,8)
movl -0xa88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa88(%rbp)
movq -0xa78(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa78(%rbp)
movq -0xa78(%rbp), %rax
cmpq -0xa80(%rbp), %rax
jne 0x75ef
jmp 0x7676
jmp 0x7678
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7596
movq -0x70(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xcce0
movq -0x70(%rbp), %rax
movq %rax, -0x1c00(%rbp)
movq -0x70(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xcf40
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x76df
movl $0x1, -0x27a8(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x27a0(%rbp)
jmp 0x7706
cmpl $0x2, -0x34(%rbp)
jne 0x7704
movl $0x1, -0x27a8(%rbp)
movl $0x0, -0x27a4(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x27a0(%rbp)
jmp 0x7706
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xa84(%rbp), %eax
jge 0x7820
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xd2b0
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x776a
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rcx
movslq -0x27a4(%rbp), %rax
movq %rcx, -0x1c00(%rbp,%rax,8)
movl -0x27a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a4(%rbp)
jmp 0x7796
cmpl $0x2, -0x34(%rbp)
jne 0x7794
movl $0x0, -0x27a8(%rbp)
movl $0x1, -0x27a4(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rax
movq %rax, -0x1c00(%rbp)
jmp 0x7796
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xcf40
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x77e4
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rcx
movslq -0x27a8(%rbp), %rax
movq %rcx, -0x27a0(%rbp,%rax,8)
movl -0x27a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a8(%rbp)
jmp 0x7810
cmpl $0x2, -0x34(%rbp)
jne 0x780e
movl $0x1, -0x27a8(%rbp)
movl $0x0, -0x27a4(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rax
movq %rax, -0x27a0(%rbp)
jmp 0x7810
jmp 0x7812
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x770d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0xa88(%rbp), %eax
jge 0x7916
movslq -0x2c(%rbp), %rax
movq -0xa70(%rbp,%rax,8), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xd5f0
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x788a
movslq -0x2c(%rbp), %rax
movq -0xa70(%rbp,%rax,8), %rcx
movslq -0x27a4(%rbp), %rax
movq %rcx, -0x1c00(%rbp,%rax,8)
movl -0x27a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a4(%rbp)
jmp 0x789e
cmpl $0x2, -0x34(%rbp)
jne 0x789c
movl $0x0, -0x4(%rbp)
jmp 0x7a05
jmp 0x789e
movslq -0x2c(%rbp), %rax
movq -0xa70(%rbp,%rax,8), %rdi
leaq -0x1060(%rbp), %rsi
leaq -0x28b0(%rbp), %rdx
callq 0xd8e0
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x78f2
movslq -0x2c(%rbp), %rax
movq -0xa70(%rbp,%rax,8), %rcx
movslq -0x27a8(%rbp), %rax
movq %rcx, -0x27a0(%rbp,%rax,8)
movl -0x27a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a8(%rbp)
jmp 0x7906
cmpl $0x2, -0x34(%rbp)
jne 0x7904
movl $0x0, -0x4(%rbp)
jmp 0x7a05
jmp 0x7906
jmp 0x7908
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7827
movl -0x27a4(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x27a4(%rbp), %ecx
addl -0x27a8(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x79d5
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x27a4(%rbp), %eax
jge 0x7981
movslq -0x2c(%rbp), %rax
movq -0x1c00(%rbp,%rax,8), %rdi
movq -0x18(%rbp), %rsi
movslq -0x2c(%rbp), %rax
imulq $0xba0, %rax, %rax      # imm = 0xBA0
addq %rax, %rsi
callq 0xdbd0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7948
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x27a8(%rbp), %eax
jge 0x79d3
movslq -0x2c(%rbp), %rax
movq -0x27a0(%rbp,%rax,8), %rdi
movq -0x18(%rbp), %rsi
movslq -0x27a4(%rbp), %rax
imulq $0xba0, %rax, %rax      # imm = 0xBA0
addq %rax, %rsi
callq 0xde70
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x27a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27a4(%rbp)
jmp 0x7988
jmp 0x79fe
cmpl $0x0, -0x27a4(%rbp)
je 0x79ee
movq -0x1c00(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x79fc
movq -0x27a0(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x79fe
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x28b0, %rsp           # imm = 0x28B0
popq %rbp
retq
nopw %cs:(%rax,%rax)