// File: /workspace/github_c_makefile_star2_O3/mishun[P]plantri/plantri.c
// Function: testcanon_mirror_init
static int 
testcanon_mirror_init(EDGE *givenedge, int representation[], int colour[])

/* Tests whether starting from a given edge and constructing the code in
   "->prev" direction, an automorphism or even a better representation can 
   be found. A better representation will be completely constructed and 
   returned in "representation".  It works pretty similar to testcanon except 
   for obviously necessary changes, so for extensive comments see testcanon */
{
    EDGE *temp, *run;  
    EDGE *startedge[MAXN+1]; 
    int number[MAXN], i; 
    int better = 0; /* is the representation already better ? */
    int last_number, actual_number, vertex;

    for (i = 0; i < nv; i++) number[i] = 0;

    number[givenedge->start] = 1;
    if (givenedge->start != givenedge->end)
      {
	number[givenedge->end] = 2;
	last_number = 2;
	startedge[1] = givenedge->invers;
      }
    else last_number = 1; 

    actual_number = 1;
    temp = givenedge;

    while (last_number < nv)
    {  
        for (run = temp->prev; run != temp; run = run->prev)
          { vertex = run->end;
            if (!number[vertex])
              { startedge[last_number] = run->invers;
                last_number++; number[vertex] = last_number; 
                vertex = colour[vertex]; }
            else vertex=number[vertex];
            if (better) *representation = vertex; 
            else { if (vertex > (*representation)) return 0;
                   else if (vertex < (*representation)) 
                     { better = 1; *representation = vertex; }
                 }
            representation++; 
          }
        if ((*representation) != 0) { better = 1; *representation = 0; }
        representation++;
        temp = startedge[actual_number];  actual_number++;
    }

    while (actual_number <= nv) 
    {  
        for (run = temp->prev; run != temp; run = run->prev)
          { vertex = number[run->end]; 
            if (better) *representation = vertex;
            else                  
              {
                if (vertex > (*representation)) return 0;
                if (vertex < (*representation))
                  { better = 1; *representation = vertex; }
              }
            representation++;
          }
       if ((*representation) != 0) { better = 1; *representation = 0; }
       representation++;
       temp = startedge[actual_number];  actual_number++;
    }

    if (better) return 2;
    return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x2388cb(%rip), %r12    # 0x244610
testq %r12, %r12
jle 0xbd5c
leaq (,%r12,4), %rdx
movq %rsp, %rdi
xorl %esi, %esi
callq 0x1030
movslq (%r14), %rsi
movl $0x1, (%rsp,%rsi,4)
movslq 0x4(%r14), %rax
movl $0x1, %ecx
movl $0x1, %edx
cmpl %eax, %esi
je 0xbd90
movl $0x2, (%rsp,%rax,4)
movq 0x20(%r14), %rax
movq %rax, 0x108(%rsp)
movl $0x2, %edx
xorl %eax, %eax
cmpl %r12d, %edx
jge 0xbe1c
xorl %eax, %eax
movl $0x1, %ecx
movq 0x10(%r14), %rsi
cmpq %r14, %rsi
je 0xbdf8
movslq 0x4(%rsi), %r8
movl (%rsp,%r8,4), %edi
testl %edi, %edi
jne 0xbdd0
movq 0x20(%rsi), %rdi
movslq %edx, %rdx
movq %rdi, 0x100(%rsp,%rdx,8)
incl %edx
movl %edx, (%rsp,%r8,4)
movl (%r15,%r8,4), %edi
testl %eax, %eax
jne 0xbde7
movl (%rbx), %r8d
cmpl %r8d, %edi
jg 0xbe8b
xorl %eax, %eax
cmpl %r8d, %edi
jge 0xbdee
movl %edi, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x10(%rsi), %rsi
jmp 0xbda6
cmpl $0x0, (%rbx)
je 0xbe08
movl $0x0, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x100(%rsp,%rcx,8), %r14
incq %rcx
cmpl %r12d, %edx
jl 0xbda2
cmpl %r12d, %ecx
jle 0xbe2e
cmpl $0x1, %eax
movl $0x2, %eax
sbbl $0x0, %eax
jmp 0xbe8d
movl %ecx, %ecx
movq 0x10(%r14), %rdx
cmpq %r14, %rdx
je 0xbe61
movslq 0x4(%rdx), %rsi
movl (%rsp,%rsi,4), %esi
testl %eax, %eax
jne 0xbe50
movl (%rbx), %edi
cmpl %edi, %esi
jg 0xbe8b
xorl %eax, %eax
cmpl %edi, %esi
jge 0xbe57
movl %esi, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x10(%rdx), %rdx
jmp 0xbe34
cmpl $0x0, (%rbx)
je 0xbe71
movl $0x0, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x100(%rsp,%rcx,8), %r14
leaq 0x1(%rcx), %rdx
cmpl %ecx, %r12d
movq %rdx, %rcx
jg 0xbe30
jmp 0xbe21
xorl %eax, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r14
popq %r15
retq