// File: /workspace/github_c_makefile_star2_O3/mishun[P]plantri/plantri.c
// Function: compute_code
static void
compute_code(unsigned char code[])
 
/* computes a code by numbering the vertices in a breadth first manner and
   then listing them in code. Code is a sequence of numbers of length ne+nv+1.
   The first entry is the number of vertices.
   Then the numbers of the vertices adjacent to the vertex numbered 1 are
   given -- ended by a 0, and listed in clockwise orientation.
   Then those adjacent to 2, ended by a 0, etc. . In case of no
   double edges, the identification of the corresponding "half edges" leaving 
   each vertex is unique. Nevertheless also for this case the following rules
   apply (not in the definition of the code, but in this routine):

   In case of double edges, the first time a new vertex
   b occurs in the list, say it is in the list of vertex a, must be matched
   with the first occurence of vertex a in the list of b. In this routine
   it will always be the first position in the list of b.

   This spanning tree
   gives a unique matching for the other "half edges" -- provided the fact
   that the ordering comes from an embedding on the sphere. 

   In case of a given starting edge in code_edge, the start of this
   edge is numbered 1 and the end 2.
*/
{
    register EDGE *run;
    register int vertex;
    EDGE *temp;  
    EDGE *startedge[MAXN+1]; 
    int number[MAXN+1], i; 
    int last_number, actual_number;
    EDGE *givenedge;

    for (i = 0; i < nv; i++) number[i] = 0;
 
    *code=nv; code++;
    if (code_edge==NULL) givenedge=firstedge[0]; 
    else { givenedge=code_edge; number[nv]=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)
    {   *code=number[temp->end]; code++;
        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; 
                *code = last_number; }
            else *code = number[vertex]; 
            code++;
          }
        *code = 0;  code++;
        temp = startedge[actual_number];  actual_number++;
    }

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

// Assembly:
pushq %r14
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, %rbx
movslq 0x23950b(%rip), %r14    # 0x244610
testq %r14, %r14
jle 0xb11c
leaq (,%r14,4), %rdx
movq %rsp, %rdi
xorl %esi, %esi
callq 0x1030
movb %r14b, (%rbx)
movq 0x2394f2(%rip), %rax    # 0x244618
testq %rax, %rax
je 0xb135
movl $0x0, (%rsp,%r14,4)
jmp 0xb13c
movq 0x1c8b4(%rip), %rax     # 0x279f0
movslq (%rax), %rdi
movl $0x1, (%rsp,%rdi,4)
movslq 0x4(%rax), %rsi
movl $0x1, %ecx
movl $0x1, %edx
cmpl %esi, %edi
je 0xb170
movl $0x2, (%rsp,%rsi,4)
movq 0x20(%rax), %rdx
movq %rdx, 0x118(%rsp)
movl $0x2, %edx
cmpl %r14d, %edx
jge 0xb1d5
movl $0x1, %ecx
movslq 0x4(%rax), %rsi
movb (%rsp,%rsi,4), %sil
movb %sil, 0x1(%rbx)
addq $0x2, %rbx
movq 0x18(%rax), %rsi
cmpq %rax, %rsi
je 0xb1c2
movslq 0x4(%rsi), %r8
movl (%rsp,%r8,4), %edi
testl %edi, %edi
jne 0xb1b6
movq 0x20(%rsi), %r9
movslq %edx, %rdi
movq %r9, 0x110(%rsp,%rdi,8)
incl %edi
movl %edi, (%rsp,%r8,4)
movl %edi, %edx
movb %dil, (%rbx)
incq %rbx
movq 0x18(%rsi), %rsi
jmp 0xb18e
movb $0x0, (%rbx)
movq 0x110(%rsp,%rcx,8), %rax
incq %rcx
cmpl %r14d, %edx
jl 0xb17a
incq %rbx
cmpl %r14d, %ecx
jg 0xb22b
movl %ecx, %ecx
movslq 0x4(%rax), %rdx
movb (%rsp,%rdx,4), %dl
movb %dl, (%rbx)
leaq 0x1(%rbx), %rdx
movq 0x18(%rax), %rsi
cmpq %rax, %rsi
je 0xb210
movslq 0x4(%rsi), %rdi
movb (%rsp,%rdi,4), %dil
movb %dil, (%rdx)
incq %rdx
movq 0x18(%rsi), %rsi
cmpq %rax, %rsi
jne 0xb1f5
leaq -0x1(%rdx), %rbx
movb $0x0, (%rdx)
addq $0x2, %rbx
movq 0x110(%rsp,%rcx,8), %rax
leaq 0x1(%rcx), %rdx
cmpl %ecx, %r14d
movq %rdx, %rcx
jg 0xb1df
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r14
retq