// File: /workspace/github_c_makefile_star2_O3/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 0x19bc6(%rip), %rcx     # 0x26094
testq %rcx, %rcx
js 0xc4e9
leaq 0x1b716(%rip), %rdx     # 0x27bf0
movl $0x2, %eax
cmpl $0x2, (%rdx,%rcx,4)
je 0xc66e
movl 0x19b9d(%rip), %eax     # 0x2608c
leal 0x2(%rax), %ecx
movl %ecx, 0x19b94(%rip)     # 0x2608c
cmpl $0x752f, %eax           # imm = 0x752F
jl 0xc52d
movl $0x2, 0x19b83(%rip)     # 0x2608c
movl $0x30, %eax
leaq 0x23810b(%rip), %rcx    # 0x244620
movl $0x0, (%rax,%rcx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0xc515
movl $0x2, %ecx
pushq %r15
pushq %r14
pushq %rbx
leaq 0x1b6b7(%rip), %rsi     # 0x27bf0
movq 0x27e7f0(%rip), %rdx    # 0x28ad30
testq %rdx, %rdx
je 0xc592
movslq (%rdx), %rax
cmpl $0x4, (%rsi,%rax,4)
jl 0xc592
movl %ecx, 0x30(%rdx)
movq 0x20(%rdx), %rax
movq 0x10(%rax), %rdi
movslq 0x4(%rdi), %rax
cmpl $0x4, (%rsi,%rax,4)
jl 0xc592
movq 0x20(%rdi), %rdi
movq 0x10(%rdi), %rdi
movl %ecx, 0x30(%rdi)
movq 0x10(%rdx), %rdi
movq 0x18(%rdx), %rdx
movq 0x18(%rdx), %rdx
cmpq %rdi, %rdx
je 0xc592
movq 0x20(%rdx), %r8
movq 0x10(%r8), %r8
cmpl %eax, 0x4(%r8)
jne 0xc576
jmp 0xc664
movl $0xffffffff, 0x19af8(%rip) # imm = 0xFFFFFFFF
movq $0x0, 0x27e789(%rip) # 0x28ad30
movl 0x238063(%rip), %edx    # 0x244610
movl $0x3, %eax
testl %edx, %edx
jle 0xc669
xorl %edi, %edi
cmpl $0x2, (%rsi)
je 0xc655
incq %rdi
addq $0x4, %rsi
cmpq %rdi, %rdx
jne 0xc5bc
cmpl $0x1, %edx
je 0xc669
decl %edx
xorl %esi, %esi
leaq 0x1b60b(%rip), %rdi     # 0x27bf0
leaq 0x1b404(%rip), %r8      # 0x279f0
cmpl $0x4, (%rdi,%rsi,4)
jl 0xc64b
movq (%r8,%rsi,8), %r10
movq %r10, %r9
cmpl %ecx, 0x30(%r9)
jge 0xc642
movl %ecx, 0x30(%r9)
movq 0x20(%r9), %r11
movq 0x10(%r11), %rbx
movslq 0x4(%rbx), %r11
cmpl $0x4, (%rdi,%r11,4)
jl 0xc642
movq 0x20(%rbx), %rbx
movq 0x10(%rbx), %rbx
movl %ecx, 0x30(%rbx)
movq 0x10(%r9), %rbx
movq 0x18(%r9), %r14
movq 0x18(%r14), %r14
cmpq %rbx, %r14
je 0xc642
movq 0x20(%r14), %r15
movq 0x10(%r15), %r15
cmpl %r11d, 0x4(%r15)
jne 0xc629
jmp 0xc65d
movq 0x18(%r9), %r9
cmpq %r10, %r9
jne 0xc5f9
incq %rsi
cmpq %rdx, %rsi
jne 0xc5ec
jmp 0xc669
movl %edi, 0x19a39(%rip)     # 0x26094
jmp 0xc664
movq %r9, 0x27e6cc(%rip)     # 0x28ad30
movl $0x2, %eax
popq %rbx
popq %r14
popq %r15
retq