// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movl 0x237691(%rip), %r9d    # 0x242600
xorl %eax, %eax
testl %r9d, %r9d
movl $0x0, %ecx
cmovgl %r9d, %ecx
cmpq %rax, %rcx
je 0xaf8c
andl $0x0, -0x80(%rsp,%rax,4)
incq %rax
jmp 0xaf7d
movslq (%rdi), %rcx
movl $0x1, -0x80(%rsp,%rcx,4)
movslq 0x4(%rdi), %rax
movl $0x1, %r10d
movl %r10d, %r11d
cmpl %eax, %ecx
je 0xafc2
movl $0x2, %r11d
movl $0x2, -0x80(%rsp,%rax,4)
movq 0x20(%rdi), %rax
movq %rax, 0x88(%rsp)
movabsq $0x1, %rax
xorl %ecx, %ecx
xorl %r8d, %r8d
cmpl %r9d, %r11d
jge 0xb050
addq $0x4, %rsi
movq %rdi, %rbx
movq 0x18(%rbx), %rbx
cmpq %rdi, %rbx
je 0xb034
movslq 0x4(%rbx), %r14
movl -0x80(%rsp,%r14,4), %ebp
testl %ebp, %ebp
jne 0xb00e
movq 0x20(%rbx), %r15
movslq %r11d, %r11
movq %r15, 0x80(%rsp,%r11,8)
incl %r11d
movl %r11d, -0x80(%rsp,%r14,4)
movl (%rdx,%r14,4), %ebp
testl %r8d, %r8d
jne 0xb028
movl -0x4(%rsi), %r14d
cmpl %r14d, %ebp
jg 0xb0b9
xorl %r8d, %r8d
cmpl %r14d, %ebp
jge 0xb02e
movl %ebp, -0x4(%rsi)
movl %r10d, %r8d
addq $0x4, %rsi
jmp 0xafdd
cmpl $0x0, -0x4(%rsi)
je 0xb041
andl $0x0, -0x4(%rsi)
movl %r10d, %r8d
movq 0x80(%rsp,%rax,8), %rdi
incq %rax
incl %ecx
jmp 0xafd1
cmpl %ecx, %r9d
cmovgl %r9d, %ecx
incl %ecx
movl $0x1, %edx
cmpq %rcx, %rax
je 0xb0c9
addq $0x4, %rsi
movq %rdi, %r9
movq 0x18(%r9), %r9
cmpq %rdi, %r9
je 0xb09f
movslq 0x4(%r9), %r10
movl -0x80(%rsp,%r10,4), %r10d
testl %r8d, %r8d
jne 0xb092
movl -0x4(%rsi), %r11d
cmpl %r11d, %r10d
jg 0xb0b9
xorl %r8d, %r8d
cmpl %r11d, %r10d
jge 0xb099
movl %r10d, -0x4(%rsi)
movl %edx, %r8d
addq $0x4, %rsi
jmp 0xb06a
cmpl $0x0, -0x4(%rsi)
je 0xb0ac
andl $0x0, -0x4(%rsi)
movl %edx, %r8d
movq 0x80(%rsp,%rax,8), %rdi
incq %rax
jmp 0xb05e
xorl %eax, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r8d
movl $0x2, %eax
sbbl $0x0, %eax
jmp 0xb0bb