// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r13
movl 0x22cc66(%rip), %eax    # 0x242600
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
shlq $0x2, %rax
leaq 0x10234(%rip), %rdx     # 0x25be0
cmpq %rcx, %rax
je 0x159c1
movl (%rcx,%rdx), %esi
addl $0x40, %esi
movl %esi, 0x30(%rsp,%rcx)
addq $0x4, %rcx
jmp 0x159ac
movq (%r13), %rdi
leaq 0x130(%rsp), %rbx
leaq 0x30(%rsp), %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0xaccc
movq (%r13), %rdi
movq %rdi, 0x12a0(%rsp)
movq %rbx, %rsi
movq %r12, %rdx
callq 0xaddf
cmpl $0x2, %eax
movq %r14, 0x20(%rsp)
movq %r15, 0x18(%rsp)
je 0x15a1d
cmpl $0x1, %eax
jne 0x15a31
movq (%r13), %rax
movq %rax, 0x700(%rsp)
pushq $0x1
popq %r14
movl %r14d, %ebx
jmp 0x15a37
movq (%r13), %rax
movq %rax, 0x700(%rsp)
pushq $0x1
popq %rbx
xorl %r14d, %r14d
jmp 0x15a37
xorl %ebx, %ebx
pushq $0x1
popq %r14
pushq $0x1
popq %r15
cmpl $0x2, %ebp
movq %r13, 0x28(%rsp)
jl 0x15a57
movq (%r13), %rax
movq 0x8(%r13), %rdi
cmpq 0x20(%rdi), %rax
je 0x15b93
movq %rbx, 0x8(%rsp)
movslq %ebp, %rbp
leaq 0x30(%rsp), %r13
movslq %r14d, %r12
cmpq %rbp, %r15
jge 0x15aeb
movq 0x28(%rsp), %rax
movq (%rax,%r15,8), %rbx
movq %rbx, %rdi
leaq 0x130(%rsp), %rsi
movq %r13, %rdx
callq 0xb0d7
movl $0x0, 0x14(%rsp)
cmpl $0x1, %eax
je 0x15a9f
cmpl $0x2, %eax
jne 0x15aaa
jmp 0x15b7d
movq %rbx, 0x12a0(%rsp,%r12,8)
incl %r14d
movq %rbx, %rdi
leaq 0x130(%rsp), %rsi
movq %r13, %rdx
callq 0xb20a
cmpl $0x1, %eax
je 0x15acc
cmpl $0x2, %eax
jne 0x15ae3
jmp 0x15b7d
movq 0x8(%rsp), %rcx
movslq %ecx, %rax
movq %rbx, 0x700(%rsp,%rax,8)
incl %ecx
movq %rcx, 0x8(%rsp)
incq %r15
jmp 0x15a64
movq 0x18(%rsp), %rax
movl %r14d, (%rax)
movq 0x8(%rsp), %r13
leal (%r14,%r13), %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
pushq $0x1
popq %rcx
movl %ecx, 0x14(%rsp)
cmpl $0x2, %eax
jl 0x15b7d
xorl %r15d, %r15d
testl %r14d, %r14d
cmovlel %r15d, %r14d
leaq 0x101c0(%rip), %rbx     # 0x25ce0
cmpq %r15, %r14
je 0x15b41
movq 0x12a0(%rsp,%r15,8), %rdi
movq %rbx, %rsi
callq 0xb33d
incq %r15
addq $0xba0, %rbx            # imm = 0xBA0
jmp 0x15b20
xorl %r14d, %r14d
testl %r13d, %r13d
cmovlel %r14d, %r13d
imulq $0xba0, %r12, %rax      # imm = 0xBA0
leaq 0x10187(%rip), %rbx     # 0x25ce0
addq %rax, %rbx
cmpq %r14, %r13
je 0x15b7d
movq 0x700(%rsp,%r14,8), %rdi
movq %rbx, %rsi
callq 0xb476
incq %r14
addq $0xba0, %rbx            # imm = 0xBA0
jmp 0x15b5c
movl 0x14(%rsp), %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 0xaf5b
movq 0x8(%r13), %rdi
cmpl $0x2, %eax
je 0x15bc3
cmpl $0x1, %eax
jne 0x15bd1
movl %r14d, %eax
movq %rdi, 0x12a0(%rsp,%rax,8)
incl %r14d
jmp 0x15bd1
movq %rdi, 0x12a0(%rsp)
xorl %ebx, %ebx
pushq $0x1
popq %r14
leaq 0x130(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xaddf
pushq $0x2
popq %r15
cmpl $0x2, %eax
je 0x15c0a
cmpl $0x1, %eax
jne 0x15a57
movq 0x8(%r13), %rax
movl %ebx, %ecx
movq %rax, 0x700(%rsp,%rcx,8)
incl %ebx
jmp 0x15a57
movq 0x8(%r13), %rax
movq %rax, 0x700(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
jmp 0x15a5c