// File: /workspace/github_c_makefile_star2_O0/mishun[P]plantri/plantri.c
// Function: compute_edgecode
static void
compute_edgecode(unsigned char code[], int *length, int *headerlength)
 
/* Computes a code by numbering the edges and
   then listing them in code. Code consists of a header (of varying length
   -- see below) and a sequence of entries coding edge numbers and separators
   of length ne+nv-1. In this program unsigned char will always provide enough 
   room to number the edges.

   We will first describe how the default code works: 
   All entries are unsigned char. The first unsigned char encodes the 
   length of the code that follows (so it is not including the 1 byte for
   the header). The numbers of the edges are 0 to 254
   and the byte 255 is always used as a separator between 2 lists of edges.
   The first segment from entry 2 (so the first non-header-entry) until the 
   first separator contains
   the edges around vertex 1 in clockwise order. The second segment between
   the first separator and the second contains the edges around vertex 2 in
   clockwise order, etc. Every edgenumber occurs exactly twice.

   In case of a given directed starting edge in code_edge, this edge is 
   numbered 0 and starts at the vertex corresponding to the first list.

   In plantri it can't happen (at the moment) that 254 is not enough to 
   encode the edges, but it can happen that 255 is not sufficient to encode
   the length of the following code. In this case the first byte is 0 --
   meaning: interpret the second byte as information about sizes of
   the entries. The first 4 bits encode the number of bytes used to
   encode the codesize and the second 4 (those with lower value) encode 
   the number of bytes used to encode the edge numbers. In plantri it will
   never be necessary to use more than 1 byte for the edgenumbers and 2
   for the codesize. So in case the first byte is 0, the second will
   always be (2<<4)+1. The separator is always one byte with value 255.
 
   A sequence of bytes will always be interpreted in a big-endian way. So
   the first byte is the most significant one. In order to be able to
   recognize separators in cases where more than 1 byte is used to encode 
   edges, we never use numbers for the edges where the most significant
   8 bits are 1. So if n bytes are used for the edges, the largest number 
   used is (1<<n)-1-(1<<(n-1)).
*/
{
    register EDGE *run;
    int i,j, startvertex; 
    int edgenumber, limitnv;

    RESETMARKS;

    if (missing_vertex>=0) limitnv=nv+1; else limitnv=nv;

    i=nv+ne-1;

    if (i<256) { *code=i; code++; *length=i+1; *headerlength=1;}
    else 
      { *code=0; code++;
        *code=(2<<4)+1; code++;
	*code=i>>8; code++;
	*code=i&255; code++;
	*headerlength=4;
	*length=i+4;
      }

    if (code_edge==NULL) run=firstedge[0]; 
    else { run=code_edge; }
    startvertex=run->start;
    //MARK(run); 
    MARK(run->invers);
    //run->index=
    run->invers->index=*code=0;
    code++; run=run->next;

    edgenumber = 1;  

    for (j=1; j<degree[startvertex]; j++, run=run->next)
      {
	if (ISMARKED(run)) { *code = run->index; code++; }
	else { //MARK(run); 
	       MARK(run->invers);
	       //run->index=
	       run->invers->index= *code =edgenumber; code++;
	       edgenumber++;
	     }
      }
    *code=255; code++;

    for (i=0;i<limitnv;i++)
      if ((i!=startvertex) && (i!=missing_vertex))
	{
	  for (j=0, run=firstedge[i]; j<degree[i]; j++, run=run->next)
	    {
	      if (ISMARKED(run)) { *code = run->index; code++; }
	      else { //MARK(run); 
		MARK(run->invers);
		//run->index=
		run->invers->index=edgenumber;
		*code=edgenumber; code++;
		edgenumber++;
	      }
	    }
	  *code=255;  code++;
	}
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl 0x3005e(%rip), %eax     # 0x3c084
addl $0x2, %eax
movl %eax, 0x30055(%rip)     # 0x3c084
cmpl $0x7530, %eax           # imm = 0x7530
jle 0xc076
movl $0x2, 0x30044(%rip)     # 0x3c084
movl $0x0, -0x38(%rbp)
cmpl $0x1198, -0x38(%rbp)    # imm = 0x1198
jge 0xc074
movslq -0x38(%rbp), %rcx
leaq 0x24e5d5(%rip), %rax    # 0x25a630
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x0, 0x30(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xc047
jmp 0xc076
cmpl $0x0, 0x30003(%rip)     # 0x3c080
jl 0xc08d
movl 0x24e59b(%rip), %eax    # 0x25a620
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xc096
movl 0x24e58d(%rip), %eax    # 0x25a620
movl %eax, -0x34(%rbp)
movl 0x24e584(%rip), %eax    # 0x25a620
addl 0x24e582(%rip), %eax    # 0x25a624
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0xc0e0
movl -0x24(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
jmp 0xc152
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movb $0x21, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl -0x24(%rbp), %eax
sarl $0x8, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl -0x24(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movq -0x18(%rbp), %rax
movl $0x4, (%rax)
movl -0x24(%rbp), %ecx
addl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x24e4ce(%rip)    # 0x25a628
jne 0xc169
movq 0x3189d(%rip), %rax     # 0x3da00
movq %rax, -0x20(%rbp)
jmp 0xc174
movq 0x24e4b8(%rip), %rax    # 0x25a628
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl 0x2ff01(%rip), %ecx     # 0x3c084
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl $0x0, 0x34(%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x1, -0x30(%rbp)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
movslq -0x2c(%rbp), %rdx
leaq 0x31a28(%rip), %rcx     # 0x3dc00
cmpl (%rcx,%rdx,4), %eax
jge 0xc266
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x2fe96(%rip), %eax     # 0x3c084
jl 0xc20d
movq -0x20(%rbp), %rax
movl 0x34(%rax), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xc24a
movl 0x2fe71(%rip), %ecx     # 0x3c084
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
movb %al, (%rcx)
movzbl %al, %ecx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc24c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xc1ca
movq -0x8(%rbp), %rax
movb $-0x1, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xc382
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xc372
movl -0x24(%rbp), %eax
cmpl 0x2fddf(%rip), %eax     # 0x3c080
je 0xc372
movl $0x0, -0x28(%rbp)
movslq -0x24(%rbp), %rcx
leaq 0x31747(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movl -0x28(%rbp), %eax
movslq -0x24(%rbp), %rdx
leaq 0x31931(%rip), %rcx     # 0x3dc00
cmpl (%rcx,%rdx,4), %eax
jge 0xc35f
movq -0x20(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x2fd9f(%rip), %eax     # 0x3c084
jl 0xc304
movq -0x20(%rbp), %rax
movl 0x34(%rax), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xc343
movl 0x2fd7a(%rip), %ecx     # 0x3c084
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x34(%rax)
movl -0x30(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc345
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xc2c1
movq -0x8(%rbp), %rax
movb $-0x1, (%rax)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0xc374
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xc280
popq %rbp
retq
nopw %cs:(%rax,%rax)