// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/plantri.c
// Function: canon_edge_oriented
static int 
canon_edge_oriented(EDGE *edgelist_or[], int num_edges_or, int can_edges_or,
		    EDGE *edgelist_inv[], int num_edges_inv, int can_edges_inv,
		    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.

   This routine checks all num_edges_or elements of edgelist_or just for one 
   orientation and all num_edges_inv elements of the list edgelist_inv just
   for the other. It returns 1 if and only if one of the first can_edges_or
   elements of the first list or first can_edges_inv elements of the second 
   give an optimal numbering among all the possibilities provided by the
   lists.

   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 possible with
   edgelist_or */

    if (can_edges_or > 0)
      { testcanon_first_init(edgelist_or[0], representation, colour);
	numblist[0] = edgelist_or[0];
	for (i=1; i<can_edges_or; i++)
	  { test = testcanon_init(edgelist_or[i], representation, colour);
	    if (test == 1) { numblist[numbs] = edgelist_or[i]; numbs++; }
	    else if (test == 2) 
	      { numbs = 1; numblist[0] = edgelist_or[i]; }
	  }
	i=0; /* the next for-loop can start at the beginning */
      }
    else
      { numbs=0; numbs_mirror=1;
        testcanon_first_init_mirror(edgelist_inv[0], representation, colour);
        numblist_mirror[0] = edgelist_inv[0];
	i=1; /* the next for-loop must start at position 1 */
      }

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


    /* now we know the best we can get for a "canonical edge".
       Next we will check all the others. We can return 0 at once if we find a 
       better one */

    for (i=can_edges_or ; i < num_edges_or; i++)
      { test = testcanon(edgelist_or[i], representation, colour);
        if (test == 1) { numblist[numbs] = edgelist_or[i]; numbs++; }
        else if (test == 2) return 0;
      }
    for (i=can_edges_inv ; i < num_edges_inv; i++)
      { test = testcanon_mirror(edgelist_inv[i], representation, colour);
        if (test == 1) 
          { numblist_mirror[numbs_mirror] = edgelist_inv[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)
movl %edx, %ebp
movq %rdi, 0x8(%rsp)
movq 0x1e80(%rsp), %rax
movl 0x236d4f(%rip), %edx    # 0x242600
xorl %ecx, %ecx
testl %edx, %edx
movl $0x0, %r10d
cmovgl %edx, %r10d
cmpq %rcx, %r10
je 0xb8d3
movl (%rax,%rcx,4), %edi
addl $0x40, %edi
movl %edi, 0x30(%rsp,%rcx,4)
incq %rcx
jmp 0xb8bf
testl %ebp, %ebp
movl %r8d, 0x28(%rsp)
movl %esi, 0x18(%rsp)
movl %ebp, 0x2c(%rsp)
jle 0xb985
movl %r9d, 0x24(%rsp)
movq 0x8(%rsp), %rbx
movq (%rbx), %rdi
leaq 0xcd0(%rsp), %r13
leaq 0x30(%rsp), %r15
movq %r13, %rsi
movq %r15, %rdx
callq 0xaccc
movq (%rbx), %rax
movq %rax, 0x12a0(%rsp)
movl %ebp, %ebx
pushq $0x1
popq %r14
pushq $0x1
popq %r12
movl %r14d, %ebp
cmpq %r12, %rbx
je 0xb979
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0xaf5b
cmpl $0x2, %eax
je 0xb960
cmpl $0x1, %eax
jne 0xb974
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %rax
movslq %ebp, %rbp
movq %rax, 0x12a0(%rsp,%rbp,8)
incl %ebp
jmp 0xb974
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x12a0(%rsp)
movl %r14d, %ebp
incq %r12
jmp 0xb925
xorl %ebx, %ebx
movl 0x24(%rsp), %r9d
jmp 0xba9c
pushq $0x1
popq %r12
pushq $0x1
popq %rcx
movq 0x10(%rsp), %rax
movq (%rax), %rax
xorl %edi, %edi
cmpq %rdi, %r10
je 0xb9a8
andl $0x0, 0x130(%rsp,%rdi,4)
incq %rdi
jmp 0xb996
movslq (%rax), %rdi
movl $0x1, 0x130(%rsp,%rdi,4)
movslq 0x4(%rax), %r10
cmpl %r10d, %edi
je 0xb9db
movl $0x2, 0x130(%rsp,%r10,4)
movq 0x20(%rax), %rdi
movq %rdi, 0x12a8(%rsp)
pushq $0x2
popq %r12
leaq 0xcd0(%rsp), %r15
xorl %edi, %edi
movq %rax, %r14
cmpl %edx, %r12d
jge 0xba4b
addq $0x4, %r15
movq %r14, %r10
movq 0x10(%r10), %r10
cmpq %r14, %r10
je 0xba37
movslq 0x4(%r10), %rbx
movl 0x130(%rsp,%rbx,4), %r11d
testl %r11d, %r11d
jne 0xba2d
movq 0x20(%r10), %r11
movslq %r12d, %r12
movq %r11, 0x12a0(%rsp,%r12,8)
incl %r12d
movl %r12d, 0x130(%rsp,%rbx,4)
movl 0x30(%rsp,%rbx,4), %r11d
movl %r11d, -0x4(%r15)
addq $0x4, %r15
jmp 0xb9f4
andl $0x0, -0x4(%r15)
movq 0x12a0(%rsp,%rcx,8), %r14
incq %rcx
incl %edi
jmp 0xb9e8
cmpl %edi, %edx
cmovgl %edx, %edi
incl %edi
cmpq %rdi, %rcx
je 0xba8f
addq $0x4, %r15
movq %r14, %rdx
movq 0x10(%rdx), %rdx
cmpq %r14, %rdx
je 0xba7d
movslq 0x4(%rdx), %r10
movl 0x130(%rsp,%r10,4), %r10d
movl %r10d, -0x4(%r15)
addq $0x4, %r15
jmp 0xba5e
andl $0x0, -0x4(%r15)
movq 0x12a0(%rsp,%rcx,8), %r14
incq %rcx
jmp 0xba52
movq %rax, 0x130(%rsp)
pushq $0x1
popq %rbx
xorl %ebp, %ebp
movl %ebx, %r12d
movslq %r9d, %r14
leaq 0xcd0(%rsp), %r15
leaq 0x30(%rsp), %r13
cmpq %r14, %r12
jge 0xbb07
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xaddf
cmpl $0x2, %eax
je 0xbaea
cmpl $0x1, %eax
jne 0xbb02
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rax
movslq %ebx, %rbx
movq %rax, 0x130(%rsp,%rbx,8)
incl %ebx
jmp 0xbb02
movq 0x10(%rsp), %rax
movq (%rax,%r12,8), %rax
movq %rax, 0x130(%rsp)
xorl %ebp, %ebp
pushq $0x1
popq %rax
movl %eax, %ebx
incq %r12
jmp 0xbaaf
movslq 0x2c(%rsp), %r12
movslq 0x18(%rsp), %rax
movq %rax, 0x18(%rsp)
movslq %ebp, %r15
cmpq 0x18(%rsp), %r12
jge 0xbb59
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %r13
movq %r13, %rdi
leaq 0xcd0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xb0d7
cmpl $0x1, %eax
je 0xbb4a
cmpl $0x2, %eax
jne 0xbb54
jmp 0xbb9f
movq %r13, 0x12a0(%rsp,%r15,8)
incl %ebp
incq %r12
jmp 0xbb16
movslq 0x28(%rsp), %r13
cmpq %r13, %r14
jge 0xbba7
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %r12
movq %r12, %rdi
leaq 0xcd0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xb20a
cmpl $0x1, %eax
je 0xbb8d
cmpl $0x2, %eax
jne 0xbb9a
jmp 0xbb9f
movslq %ebx, %rax
movq %r12, 0x130(%rsp,%rax,8)
incl %ebx
incq %r14
jmp 0xbb5e
xorl %r12d, %r12d
jmp 0xbc33
movq 0x1e90(%rsp), %rax
movl %ebp, (%rax)
leal (%rbx,%rbp), %eax
movq 0x1e88(%rsp), %rcx
movl %eax, (%rcx)
pushq $0x1
popq %r12
cmpl $0x2, %eax
jl 0xbc33
xorl %r13d, %r13d
testl %ebp, %ebp
cmovlel %r13d, %ebp
leaq 0x1a109(%rip), %r14     # 0x25ce0
cmpq %r13, %rbp
je 0xbbf8
movq 0x12a0(%rsp,%r13,8), %rdi
movq %r14, %rsi
callq 0xb33d
incq %r13
addq $0xba0, %r14            # imm = 0xBA0
jmp 0xbbd7
xorl %r13d, %r13d
testl %ebx, %ebx
cmovlel %r13d, %ebx
imulq $0xba0, %r15, %rax      # imm = 0xBA0
leaq 0x1a0d1(%rip), %r14     # 0x25ce0
addq %rax, %r14
cmpq %r13, %rbx
je 0xbc33
movq 0x130(%rsp,%r13,8), %rdi
movq %r14, %rsi
callq 0xb476
incq %r13
addq $0xba0, %r14            # imm = 0xBA0
jmp 0xbc12
movl %r12d, %eax
addq $0x1e48, %rsp           # imm = 0x1E48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq