// File: /workspace/github_c_makefile_star2_O1/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 0x19d10(%rip), %rcx     # 0x2609c
testq %rcx, %rcx
js 0xc3a7
leaq 0x1b858(%rip), %rdx     # 0x27bf0
movl $0x2, %eax
cmpl $0x2, (%rdx,%rcx,4)
je 0xc52c
movl 0x19ce7(%rip), %eax     # 0x26094
leal 0x2(%rax), %ecx
movl %ecx, 0x19cde(%rip)     # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0xc3e6
movl $0x2, 0x19ccd(%rip)     # 0x26094
movl $0x30, %eax
leaq 0x23824d(%rip), %rcx    # 0x244620
movl $0x0, (%rax,%rcx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0xc3d3
pushq %r15
pushq %r14
pushq %rbx
leaq 0x1b7fe(%rip), %rcx     # 0x27bf0
movq 0x27e937(%rip), %rax    # 0x28ad30
testq %rax, %rax
je 0xc450
movslq (%rax), %rdx
cmpl $0x4, (%rcx,%rdx,4)
jl 0xc450
movl 0x19c87(%rip), %esi     # 0x26094
movl %esi, 0x30(%rax)
movq 0x20(%rax), %rdx
movq 0x10(%rdx), %rdi
movslq 0x4(%rdi), %rdx
cmpl $0x4, (%rcx,%rdx,4)
jl 0xc450
movq 0x20(%rdi), %rdi
movq 0x10(%rdi), %rdi
movl %esi, 0x30(%rdi)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
cmpq %rsi, %rax
je 0xc450
movq 0x20(%rax), %rdi
movq 0x10(%rdi), %rdi
cmpl %edx, 0x4(%rdi)
jne 0xc435
jmp 0xc522
movl $0xffffffff, 0x19c42(%rip) # imm = 0xFFFFFFFF
movq $0x0, 0x27e8cb(%rip) # 0x28ad30
movslq 0x2381a4(%rip), %rdx    # 0x244610
testq %rdx, %rdx
jle 0xc48b
xorl %eax, %eax
movq %rcx, %rsi
cmpl $0x2, (%rsi)
je 0xc51c
incq %rax
addq $0x4, %rsi
cmpq %rax, %rdx
jne 0xc476
movl $0x3, %eax
cmpl $0x2, %edx
jl 0xc527
decl %edx
movl 0x19bf3(%rip), %esi     # 0x26094
xorl %edi, %edi
leaq 0x1b546(%rip), %r8      # 0x279f0
cmpl $0x4, (%rcx,%rdi,4)
jl 0xc509
movq (%r8,%rdi,8), %r10
movq %r10, %r9
cmpl %esi, 0x30(%r9)
jge 0xc500
movl %esi, 0x30(%r9)
movq 0x20(%r9), %r11
movq 0x10(%r11), %rbx
movslq 0x4(%rbx), %r11
cmpl $0x4, (%rcx,%r11,4)
jl 0xc500
movq 0x20(%rbx), %rbx
movq 0x10(%rbx), %rbx
movl %esi, 0x30(%rbx)
movq 0x10(%r9), %rbx
movq 0x18(%r9), %r14
movq 0x18(%r14), %r14
cmpq %rbx, %r14
je 0xc500
movq 0x20(%r14), %r15
movq 0x10(%r15), %r15
cmpl %r11d, 0x4(%r15)
jne 0xc4e7
jmp 0xc513
movq 0x18(%r9), %r9
cmpq %r10, %r9
jne 0xc4b7
incq %rdi
cmpq %rdx, %rdi
jne 0xc4aa
jmp 0xc527
movq %r9, 0x27e816(%rip)     # 0x28ad30
jmp 0xc522
movl %eax, 0x19b7a(%rip)     # 0x2609c
movl $0x2, %eax
popq %rbx
popq %r14
popq %r15
retq