// File: /workspace/github_c_makefile_star2_O2/mishun[P]plantri/plantri.c
// Function: con_quad
static int
con_quad(void)

/* tests and returns the connectivity of a simple quadrangulation.
   Possible values are 2 and 3 */
{

  int i,othervertex;
  EDGE *start, *run, *end, *runend, *buffer;
  static EDGE *lastprob=NULL;
  static int lastdeg= -1;
  /* the last two remember edges or vertices where the last time there
     was a problem -- test these first */

  if (lastdeg>=0) { if (degree[lastdeg]==2)  return 2;}

  RESETMARKS;

  if ((lastprob != NULL) && (degree[lastprob->start]>3))
    { MARK(lastprob);
      buffer=lastprob->invers->prev;
      othervertex=buffer->end;
      if (degree[othervertex]>3)
	{
	  MARK(buffer->invers->prev);
	  runend=lastprob->prev;
	  run=lastprob->next->next;
	  while (run!=runend)
	    { if (run->invers->prev->end==othervertex) return 2;
	    run=run->next; }
	}
    }

  lastdeg= -1;
  lastprob=NULL;

  for (i=0;i<nv;i++) if (degree[i]==2) { lastdeg=i; return 2;}

  /* Note: edges on the other side of degree 3 vertices in a 
     quadrangle can be marked as non-starts. but this makes it
     much slower (doing it in the loop or doing it before. 
     Don't ask why... */

  for (i=0;i<nv-1;i++) /* the faces around nv are all tested from
			  the other side */
   { if (degree[i]>3)
      { start=end=firstedge[i]; /* checking face on the right */
      do
	{
	  if (!ISMARKED(start))
	    { MARK(start);
	      buffer=start->invers->prev;
	      othervertex=buffer->end;
	      if (degree[othervertex]>3)
		{
		  MARK(buffer->invers->prev);
		  runend=start->prev;
		  run=start->next->next;
		  while (run!=runend)
		    { if (run->invers->prev->end==othervertex) 
		      { lastprob=start; return 2; }
		      run=run->next; }
		}
	      /* Makes it slower... -- also outside the edge-loop
	      if (degree[i]==4) 
		{ MARK(start->next->next);
		MARK(start->prev->invers->next->invers);
		}
	      */
	    }
	  start=start->next;
	} while (start!=end);
      }
   }
      
  return 3;

}

// Assembly:
movslq 0x18ace(%rip), %rcx     # 0x24084
movl $0x2, %eax
testq %rcx, %rcx
js 0xb5d1
leaq 0x1a619(%rip), %rdx     # 0x25be0
cmpl $0x2, (%rdx,%rcx,4)
je 0xb762
movl 0x18aa5(%rip), %edx     # 0x2407c
leal 0x2(%rdx), %ecx
movl %ecx, 0x18a9c(%rip)     # 0x2407c
cmpl $0x752f, %edx           # imm = 0x752F
jl 0xb61b
movl $0x2, 0x18a8a(%rip)     # 0x2407c
movabsq $0x30, %rdx
movl $0x2, %ecx
leaq 0x237008(%rip), %rsi    # 0x242610
cmpq $0x46630, %rdx          # imm = 0x46630
je 0xb61b
andl $0x0, (%rdx,%rsi)
addq $0x40, %rdx
jmp 0xb608
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x1a5b7(%rip), %rdx     # 0x25be0
movq 0x27d6f0(%rip), %rdi    # 0x288d20
testq %rdi, %rdi
je 0xb683
movslq (%rdi), %rsi
cmpl $0x4, (%rdx,%rsi,4)
jl 0xb683
movl %ecx, 0x30(%rdi)
movq 0x20(%rdi), %rsi
movq 0x10(%rsi), %r8
movslq 0x4(%r8), %rsi
cmpl $0x4, (%rdx,%rsi,4)
jl 0xb683
movq 0x20(%r8), %r8
movq 0x10(%r8), %r8
movl %ecx, 0x30(%r8)
movq 0x10(%rdi), %r8
movq 0x18(%rdi), %rdi
movq 0x18(%rdi), %rdi
cmpq %r8, %rdi
je 0xb683
movq 0x20(%rdi), %r9
movq 0x10(%r9), %r9
cmpl %esi, 0x4(%r9)
jne 0xb667
jmp 0xb75b
orl $-0x1, 0x189fa(%rip)    # 0x24084
andq $0x0, 0x27d68e(%rip)    # 0x288d20
movl 0x236f68(%rip), %esi    # 0x242600
xorl %edi, %edi
testl %esi, %esi
movl $0x0, %r8d
cmovgl %esi, %r8d
cmpq %rdi, %r8
je 0xb6bd
cmpl $0x2, (%rdx)
je 0xb74c
incq %rdi
addq $0x4, %rdx
jmp 0xb6a6
cmpl $0x2, %esi
movl $0x1, %edx
cmovgel %esi, %edx
decl %edx
xorl %esi, %esi
movl $0x3, %edi
leaq 0x1a508(%rip), %r8      # 0x25be0
leaq 0x1a301(%rip), %r9      # 0x259e0
cmpq %rdx, %rsi
je 0xb763
cmpl $0x4, (%r8,%rsi,4)
jl 0xb747
movq (%r9,%rsi,8), %r11
movq %r11, %r10
cmpl %ecx, 0x30(%r10)
jge 0xb73e
movl %ecx, 0x30(%r10)
movq 0x20(%r10), %rbx
movq 0x10(%rbx), %r14
movslq 0x4(%r14), %rbx
cmpl $0x4, (%r8,%rbx,4)
jl 0xb73e
movq 0x20(%r14), %r14
movq 0x10(%r14), %r14
movl %ecx, 0x30(%r14)
movq 0x10(%r10), %r14
movq 0x18(%r10), %r15
movq 0x18(%r15), %r15
cmpq %r14, %r15
je 0xb73e
movq 0x20(%r15), %r12
movq 0x10(%r12), %r12
cmpl %ebx, 0x4(%r12)
jne 0xb723
jmp 0xb754
movq 0x18(%r10), %r10
cmpq %r11, %r10
jne 0xb6f2
incq %rsi
jmp 0xb6df
movl %edi, 0x18932(%rip)     # 0x24084
jmp 0xb75b
movq %r10, 0x27d5c5(%rip)    # 0x288d20
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl %edi, %eax
jmp 0xb75b