// File: /workspace/github_c_makefile_star2_O3/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
movl %r9d, %ebp
movq %r8, 0x18(%rsp)
movq %rcx, (%rsp)
movl %edx, %r14d
movq %rsi, 0x20(%rsp)
movq %rdi, 0x8(%rsp)
movslq 0x237e24(%rip), %rbx    # 0x244610
testq %rbx, %rbx
movl %r9d, 0x14(%rsp)
movl %edx, 0x2c(%rsp)
jle 0xc846
movq 0x1e80(%rsp), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
addl $0x40, %edx
movl %edx, 0x30(%rsp,%rcx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0xc804
testl %r14d, %r14d
jg 0xc84f
movq (%rsp), %rax
movq (%rax), %r12
testl %ebx, %ebx
jle 0xc908
leaq (,%rbx,4), %rdx
leaq 0x700(%rsp), %rdi
xorl %esi, %esi
callq 0x1030
jmp 0xc908
testl %r14d, %r14d
jle 0xc901
movq 0x8(%rsp), %rbx
movq (%rbx), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xbc12
movq (%rbx), %rax
movq %rax, 0x12a0(%rsp)
xorl %ebx, %ebx
movl $0x1, %r13d
cmpl $0x1, %r14d
je 0xca11
movl %r14d, %r14d
movl $0x1, %r13d
movl $0x1, %r15d
leaq 0x130(%rsp), %r12
leaq 0x30(%rsp), %rbp
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0xbe9c
cmpl $0x2, %eax
je 0xc8d9
cmpl $0x1, %eax
jne 0xc8f0
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rax
movslq %r13d, %r13
movq %rax, 0x12a0(%rsp,%r13,8)
incl %r13d
jmp 0xc8f0
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rax
movq %rax, 0x12a0(%rsp)
movl $0x1, %r13d
incq %r15
cmpq %r15, %r14
jne 0xc8a2
movl 0x14(%rsp), %ebp
jmp 0xca11
movq (%rsp), %rax
movq (%rax), %r12
movslq (%r12), %rcx
movl $0x1, 0x700(%rsp,%rcx,4)
movslq 0x4(%r12), %rax
movl $0x1, %edx
movl $0x1, %esi
cmpl %eax, %ecx
je 0xc947
movl $0x2, 0x700(%rsp,%rax,4)
movq 0x20(%r12), %rax
movq %rax, 0x12a8(%rsp)
movl $0x2, %esi
leaq 0x130(%rsp), %rax
cmpl %ebx, %esi
jge 0xc9bb
movl $0x1, %edx
movq %r12, %rcx
movq 0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0xc9a0
movslq 0x4(%rdi), %r9
movl 0x700(%rsp,%r9,4), %r8d
testl %r8d, %r8d
jne 0xc993
movq 0x20(%rdi), %r8
movslq %esi, %rsi
movq %r8, 0x12a0(%rsp,%rsi,8)
incl %esi
movl %esi, 0x700(%rsp,%r9,4)
movl 0x30(%rsp,%r9,4), %r8d
movl %r8d, (%rax)
addq $0x4, %rax
movq 0x10(%rdi), %rdi
jmp 0xc95f
movl $0x0, (%rax)
addq $0x4, %rax
movq 0x12a0(%rsp,%rdx,8), %rcx
incq %rdx
cmpl %ebx, %esi
jl 0xc95b
jmp 0xc9be
movq %r12, %rcx
cmpl %ebx, %edx
jg 0xca01
movl %edx, %edx
movq 0x10(%rcx), %rsi
cmpq %rcx, %rsi
je 0xc9e4
movslq 0x4(%rsi), %rdi
movl 0x700(%rsp,%rdi,4), %edi
movl %edi, (%rax)
addq $0x4, %rax
movq 0x10(%rsi), %rsi
jmp 0xc9c8
movl $0x0, (%rax)
addq $0x4, %rax
movq 0x12a0(%rsp,%rdx,8), %rcx
leaq 0x1(%rdx), %rsi
cmpl %edx, %ebx
movq %rsi, %rdx
jg 0xc9c4
movq %r12, 0x700(%rsp)
movl $0x1, %ebx
xorl %r13d, %r13d
cmpl %ebp, %ebx
jge 0xca7c
movl %ebx, %r15d
movl %ebp, %r14d
leaq 0x130(%rsp), %rbp
leaq 0x30(%rsp), %r12
movq (%rsp), %rax
movq (%rax,%r15,8), %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0xbd27
cmpl $0x2, %eax
je 0xca5c
cmpl $0x1, %eax
jne 0xca74
movq (%rsp), %rax
movq (%rax,%r15,8), %rax
movslq %ebx, %rbx
movq %rax, 0x700(%rsp,%rbx,8)
incl %ebx
jmp 0xca74
movq (%rsp), %rax
movq (%rax,%r15,8), %rax
movq %rax, 0x700(%rsp)
movl $0x1, %ebx
xorl %r13d, %r13d
incq %r15
cmpq %r15, %r14
jne 0xca28
movq 0x20(%rsp), %rax
movl 0x2c(%rsp), %ecx
subl %ecx, %eax
movq %rax, 0x20(%rsp)
jle 0xcae0
movslq %ecx, %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
xorl %r12d, %r12d
leaq 0x30(%rsp), %r15
movq (%r14,%r12,8), %rbp
movq %rbp, %rdi
leaq 0x130(%rsp), %rsi
movq %r15, %rdx
callq 0xc011
cmpl $0x1, %eax
je 0xcac8
cmpl $0x2, %eax
jne 0xcad6
jmp 0xcbd5
movslq %r13d, %r13
movq %rbp, 0x12a0(%rsp,%r13,8)
incl %r13d
incq %r12
cmpl %r12d, 0x20(%rsp)
jne 0xcaa2
movq 0x18(%rsp), %rax
movl 0x14(%rsp), %ecx
subl %ecx, %eax
movq %rax, 0x18(%rsp)
jle 0xcb43
movslq %ecx, %rax
movq (%rsp), %rcx
leaq (%rcx,%rax,8), %rbp
xorl %r14d, %r14d
leaq 0x30(%rsp), %r15
movq (%rbp,%r14,8), %r12
movq %r12, %rdi
leaq 0x130(%rsp), %rsi
movq %r15, %rdx
callq 0xc13b
cmpl $0x1, %eax
je 0xcb2c
cmpl $0x2, %eax
jne 0xcb39
jmp 0xcbd5
movslq %ebx, %rbx
movq %r12, 0x700(%rsp,%rbx,8)
incl %ebx
incq %r14
cmpl %r14d, 0x18(%rsp)
jne 0xcb05
movq 0x1e90(%rsp), %rax
movq 0x1e88(%rsp), %rcx
movl %r13d, (%rax)
leal (%rbx,%r13), %edx
movl %edx, (%rcx)
movl $0x1, %eax
cmpl $0x2, %edx
jl 0xcbd7
leaq 0x1b183(%rip), %r14     # 0x27cf0
testl %r13d, %r13d
jle 0xcb99
movl %r13d, %r12d
xorl %ebp, %ebp
movq %r14, %r15
movq 0x12a0(%rsp,%rbp,8), %rdi
movq %r15, %rsi
callq 0xc265
incq %rbp
addq $0xba0, %r15            # imm = 0xBA0
cmpq %rbp, %r12
jne 0xcb7a
testl %ebx, %ebx
jle 0xcbce
movslq %r13d, %rax
movl %ebx, %ebx
imulq $0xba0, %rax, %rax      # imm = 0xBA0
addq %rax, %r14
xorl %r15d, %r15d
movq 0x700(%rsp,%r15,8), %rdi
movq %r14, %rsi
callq 0xc396
incq %r15
addq $0xba0, %r14            # imm = 0xBA0
cmpq %r15, %rbx
jne 0xcbaf
movl $0x1, %eax
jmp 0xcbd7
xorl %eax, %eax
addq $0x1e48, %rsp           # imm = 0x1E48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq