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

/* Tests whether starting from a given edge and constructing the code in
   "->next" 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 */
{
    register EDGE *run;
    register int vertex;
    EDGE *temp;  
    EDGE *startedge[MAXN+1]; 
    int number[MAXN], i; 
    int better = 0; /* is the representation already better ? */
    int last_number, actual_number;

    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->next; run != temp; run = run->next)
          { 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->next; run != temp; run = run->next)
          { 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 0x238888(%rip), %r12    # 0x244610
testq %r12, %r12
jle 0xbd9f
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 0xbdd3
movl $0x2, (%rsp,%rax,4)
movq 0x20(%r14), %rax
movq %rax, 0x108(%rsp)
movl $0x2, %edx
xorl %eax, %eax
cmpl %r12d, %edx
jge 0xbe5f
xorl %eax, %eax
movl $0x1, %ecx
movq 0x18(%r14), %rsi
cmpq %r14, %rsi
je 0xbe3b
movslq 0x4(%rsi), %r8
movl (%rsp,%r8,4), %edi
testl %edi, %edi
jne 0xbe13
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 0xbe2a
movl (%rbx), %r8d
cmpl %r8d, %edi
jg 0xbece
xorl %eax, %eax
cmpl %r8d, %edi
jge 0xbe31
movl %edi, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x18(%rsi), %rsi
jmp 0xbde9
cmpl $0x0, (%rbx)
je 0xbe4b
movl $0x0, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x100(%rsp,%rcx,8), %r14
incq %rcx
cmpl %r12d, %edx
jl 0xbde5
cmpl %r12d, %ecx
jle 0xbe71
cmpl $0x1, %eax
movl $0x2, %eax
sbbl $0x0, %eax
jmp 0xbed0
movl %ecx, %ecx
movq 0x18(%r14), %rdx
cmpq %r14, %rdx
je 0xbea4
movslq 0x4(%rdx), %rsi
movl (%rsp,%rsi,4), %esi
testl %eax, %eax
jne 0xbe93
movl (%rbx), %edi
cmpl %edi, %esi
jg 0xbece
xorl %eax, %eax
cmpl %edi, %esi
jge 0xbe9a
movl %esi, (%rbx)
movl $0x1, %eax
addq $0x4, %rbx
movq 0x18(%rdx), %rdx
jmp 0xbe77
cmpl $0x0, (%rbx)
je 0xbeb4
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 0xbe73
jmp 0xbe64
xorl %eax, %eax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r14
popq %r15
retq