// File: /workspace/github_c_makefile_star2_O3/mishun[P]plantri/plantri.c
// Function: testcanon_first_init
static void
testcanon_first_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 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; 
                *representation = colour[vertex]; }
            else *representation = number[vertex]; 
            representation++;
          }
        *representation = 0;
        representation++;
        temp = startedge[actual_number];  actual_number++;
    }

    while (actual_number <= nv) 
    {  
        for (run = temp->next; run != temp; run = run->next)
          { 
            *representation = number[run->end]; representation++;
          }
        *representation = 0;
        representation++;
        temp = startedge[actual_number];  actual_number++;
    }

    return;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movslq 0x2389e0(%rip), %r12    # 0x244610
testq %r12, %r12
jle 0xbc47
leaq (,%r12,4), %rdx
movq %rsp, %rdi
xorl %esi, %esi
callq 0x1030
movslq (%r14), %rsi
movl $0x1, (%rsp,%rsi,4)
movslq 0x4(%r14), %rdx
movl $0x1, %eax
movl $0x1, %ecx
cmpl %edx, %esi
je 0xbc7b
movl $0x2, (%rsp,%rdx,4)
movq 0x20(%r14), %rcx
movq %rcx, 0x108(%rsp)
movl $0x2, %ecx
cmpl %r12d, %ecx
jge 0xbcd7
movl $0x1, %eax
movq 0x18(%r14), %rdx
cmpq %r14, %rdx
je 0xbcbd
movslq 0x4(%rdx), %rdi
movl (%rsp,%rdi,4), %esi
testl %esi, %esi
jne 0xbcb1
movq 0x20(%rdx), %rsi
movslq %ecx, %rcx
movq %rsi, 0x100(%rsp,%rcx,8)
incl %ecx
movl %ecx, (%rsp,%rdi,4)
movl (%r15,%rdi,4), %esi
movl %esi, (%rbx)
addq $0x4, %rbx
movq 0x18(%rdx), %rdx
jmp 0xbc89
movl $0x0, (%rbx)
addq $0x4, %rbx
movq 0x100(%rsp,%rax,8), %r14
incq %rax
cmpl %r12d, %ecx
jl 0xbc85
cmpl %r12d, %eax
jg 0xbd18
movl %eax, %eax
movq 0x18(%r14), %rcx
cmpq %r14, %rcx
je 0xbcfa
movslq 0x4(%rcx), %rdx
movl (%rsp,%rdx,4), %edx
movl %edx, (%rbx)
addq $0x4, %rbx
movq 0x18(%rcx), %rcx
jmp 0xbce2
movl $0x0, (%rbx)
addq $0x4, %rbx
movq 0x100(%rsp,%rax,8), %r14
leaq 0x1(%rax), %rcx
cmpl %eax, %r12d
movq %rcx, %rax
jg 0xbcde
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r14
popq %r15
retq