// File: /workspace/github_c_makefile_star2_O2/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 %rbx
subq $0x2a0, %rsp            # imm = 0x2A0
movslq 0x238348(%rip), %rcx    # 0x242600
xorl %eax, %eax
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
cmpq %rax, %rdx
je 0xa2d3
andl $0x0, -0x80(%rsp,%rax,4)
incq %rax
jmp 0xa2c4
movb %cl, (%rdi)
movq 0x23832c(%rip), %rax    # 0x242608
testq %rax, %rax
je 0xa2e8
andl $0x0, -0x80(%rsp,%rcx,4)
jmp 0xa2ef
movq 0x1b6f1(%rip), %rax     # 0x259e0
movslq (%rax), %rsi
movl $0x1, -0x80(%rsp,%rsi,4)
movslq 0x4(%rax), %rdx
cmpl %edx, %esi
jne 0xa30a
movl $0x1, %r8d
jmp 0xa324
movl $0x2, -0x80(%rsp,%rdx,4)
movq 0x20(%rax), %rdx
movq %rdx, 0x98(%rsp)
movl $0x2, %r8d
movabsq $0x1, %rdx
xorl %esi, %esi
cmpl %ecx, %r8d
jge 0xa394
movslq 0x4(%rax), %r9
movb -0x80(%rsp,%r9,4), %r9b
movb %r9b, 0x1(%rdi)
addq $0x2, %rdi
movq %rax, %r9
movq 0x18(%r9), %r9
cmpq %rax, %r9
je 0xa382
movslq 0x4(%r9), %r11
movl -0x80(%rsp,%r11,4), %r10d
testl %r10d, %r10d
jne 0xa37a
movq 0x20(%r9), %rbx
movslq %r8d, %r10
movq %rbx, 0x90(%rsp,%r10,8)
incl %r10d
movl %r10d, -0x80(%rsp,%r11,4)
movl %r10d, %r8d
movb %r10b, (%rdi)
incq %rdi
jmp 0xa349
movb $0x0, (%rdi)
movq 0x90(%rsp,%rdx,8), %rax
incq %rdx
incl %esi
jmp 0xa330
incq %rdi
cmpl %esi, %ecx
cmovgl %ecx, %esi
incl %esi
cmpq %rsi, %rdx
je 0xa3d3
incq %rdi
movq %rax, %rcx
movslq 0x4(%rcx), %r8
movb -0x80(%rsp,%r8,4), %r8b
movb %r8b, -0x1(%rdi)
movq 0x18(%rcx), %rcx
incq %rdi
cmpq %rax, %rcx
jne 0xa3a9
movb $0x0, -0x1(%rdi)
movq 0x90(%rsp,%rdx,8), %rax
incq %rdx
jmp 0xa39e
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbx
retq