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

/* 
   IT IS ASSUMED that the values of the colour function are positive and
   at most INT_MAX-MAXN.

   In case edgelist[0] == edgelist[1]->inverse, it checks whether 
   edgelist[0] or edgelist[1] are canonical. Otherwise only
   edgelist[0] is checked to be canonical.

   It is only compared with the other edges contained in edgelist.
   The number of those edges in the list is given in num_edges.
   Returns 1 if yes, 0 if not. 

   Edges given are not in minimal form -- but it is guaranteed that all
   colours of the startpoints are the same and all colours of the endpoints
   are the same.

   In case of only the identity automorphism, the entries of can_numberings[][]
   are undefined.

   Otherwise 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 are orientation reversing.

   In case of an orientation preserving numbering the edges 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, test;
    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 */

/* First we have to determine the smallest representation of edgelist[0] */

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

    if ((num_edges>1) && (edgelist[0]==edgelist[1]->invers))
      { test = testcanon_init(edgelist[1], representation, colour);
        if (test == 1) { numblist[numbs] = edgelist[1]; numbs++; }
        else if (test == 2) 
          { numbs_mirror = 0; numbs = 1; numblist[0] = edgelist[1]; }
        test = testcanon_mirror_init(edgelist[1],representation, colour);
        if (test == 1)  
          { numblist_mirror[numbs_mirror] = edgelist[1]; 
            numbs_mirror++; }
        else if (test == 2) 
          { numbs_mirror = 1; numbs = 0; 
            numblist_mirror[0] = edgelist[1]; }
        i=2; /* start rejecting at the second entry */
      }
    else i=1; /* start rejecting at the first entry */
/* Now we know the best representation we can obtain with testedge.
   Next we will check all the others. We can return 0 at once if we find a 
   better one */

    for ( ; i < num_edges; i++)
      { test = testcanon(edgelist[i], representation, colour);
        if (test == 1) { numblist[numbs] = edgelist[i]; numbs++; }
        else if (test == 2) return 0;
        test = testcanon_mirror(edgelist[i], representation, colour);
        if (test == 1) 
          { numblist_mirror[numbs_mirror] = edgelist[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]);
      }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e48, %rsp           # imm = 0x1E48
movq %rcx, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, %r13d
movq %rdi, %r14
movslq 0x22d671(%rip), %rax    # 0x244610
testq %rax, %rax
jle 0x16fc4
shlq $0x2, %rax
xorl %ecx, %ecx
leaq 0x10c3f(%rip), %rdx     # 0x27bf0
movl (%rcx,%rdx), %esi
addl $0x40, %esi
movl %esi, 0x30(%rsp,%rcx)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x16fb1
movq (%r14), %rdi
leaq 0x130(%rsp), %rbx
leaq 0x30(%rsp), %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0xbc12
movq (%r14), %rdi
movq %rdi, 0x12a0(%rsp)
movq %rbx, %rsi
movq %r12, %rdx
callq 0xbd27
cmpl $0x2, %eax
je 0x1701b
cmpl $0x1, %eax
jne 0x17034
movq (%r14), %rax
movq %rax, 0x700(%rsp)
movl $0x1, %ebp
movl $0x1, %eax
movq %rax, 0x8(%rsp)
jmp 0x17042
movq (%r14), %rax
movq %rax, 0x700(%rsp)
movl $0x1, %eax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x17042
movq $0x0, 0x8(%rsp)
movl $0x1, %ebp
movl $0x1, %ecx
cmpl $0x2, %r13d
jl 0x1705e
movq (%r14), %rax
movq 0x8(%r14), %rdi
cmpq 0x20(%rdi), %rax
je 0x171a0
cmpl %r13d, %ecx
jge 0x170f7
movq %r14, 0x28(%rsp)
movl %ecx, %r14d
movl %r13d, %eax
movq %rax, 0x20(%rsp)
leaq 0x130(%rsp), %r12
leaq 0x30(%rsp), %r15
movq 0x28(%rsp), %rax
movq (%rax,%r14,8), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xc011
xorl %r13d, %r13d
cmpl $0x1, %eax
je 0x170ad
cmpl $0x2, %eax
jne 0x170ba
jmp 0x1718b
movslq %ebp, %rbp
movq %rbx, 0x12a0(%rsp,%rbp,8)
incl %ebp
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0xc13b
cmpl $0x1, %eax
je 0x170d7
cmpl $0x2, %eax
jne 0x170ed
jmp 0x1718b
movq 0x8(%rsp), %rax
cltq
movq %rbx, 0x700(%rsp,%rax,8)
incl %eax
movq %rax, 0x8(%rsp)
incq %r14
cmpq %r14, 0x20(%rsp)
jne 0x17084
movq 0x10(%rsp), %rax
movl %ebp, (%rax)
movq 0x8(%rsp), %rdx
leal (%rdx,%rbp), %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movl $0x1, %r13d
cmpl $0x2, %eax
jl 0x1718b
movq %rdx, 0x8(%rsp)
leaq 0x10bcc(%rip), %rbx     # 0x27cf0
testl %ebp, %ebp
jle 0x17150
movl %ebp, %r15d
xorl %r12d, %r12d
movq %rbx, %r14
movq 0x12a0(%rsp,%r12,8), %rdi
movq %r14, %rsi
callq 0xc265
incq %r12
addq $0xba0, %r14            # imm = 0xBA0
cmpq %r12, %r15
jne 0x17131
movq 0x8(%rsp), %rcx
testl %ecx, %ecx
jle 0x1718b
movslq %ebp, %rax
movl %ecx, %r14d
imulq $0xba0, %rax, %rax      # imm = 0xBA0
addq %rax, %rbx
xorl %r15d, %r15d
movq 0x700(%rsp,%r15,8), %rdi
movq %rbx, %rsi
callq 0xc396
incq %r15
addq $0xba0, %rbx            # imm = 0xBA0
cmpq %r15, %r14
jne 0x1716c
movl %r13d, %eax
addq $0x1e48, %rsp           # imm = 0x1E48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x130(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xbe9c
movq 0x8(%r14), %rdi
cmpl $0x2, %eax
je 0x171ce
cmpl $0x1, %eax
jne 0x171e4
movl %ebp, %eax
movq %rdi, 0x12a0(%rsp,%rax,8)
incl %ebp
jmp 0x171e4
movq %rdi, 0x12a0(%rsp)
movq $0x0, 0x8(%rsp)
movl $0x1, %ebp
leaq 0x130(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xbd27
movl $0x2, %ecx
cmpl $0x2, %eax
je 0x17228
cmpl $0x1, %eax
jne 0x1705e
movq 0x8(%r14), %rax
movq 0x8(%rsp), %rsi
movl %esi, %edx
movq %rax, 0x700(%rsp,%rdx,8)
incl %esi
movq %rsi, 0x8(%rsp)
jmp 0x1705e
movq 0x8(%r14), %rax
movq %rax, 0x700(%rsp)
movl $0x1, %eax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x1705e