// File: /workspace/github_c_makefile_star2_O0/mishun[P]plantri/plantri.c
// Function: quadr_P3_legal
static void
quadr_P3_legal(EDGE *ref, EDGE *good_or[], int *ngood_or, int *ngood_ref,
               EDGE *good_mir[], int *ngood_mir, int *ngood_mir_ref)

/* The P3-operation with reference edge *ref has just been performed.
   Make a list in good_or[0..*ngood_or-1] of the reference edges of
   legal P3-reductions (oriented editions) that might be canonical,
   with the first *ngood_ref of those being ref.
   Make a list in good_mir[0..*ngood_mir-1] of the
   reference edges of legal four-reductions (mirror-image editions)
   that might be canonical, with the first *ngood_mir_ref of those being
   ref->next.
   *ngood_ref and *ngood_mir_ref might each be 0-4.  If they are
   both 0, nothing else need be correct.
   All the edges in good_or[] and good_mir[] must start with the same
   vertex degree and end with the same vertex degree (actually, colour
   as passed to canon_edge_oriented).
   P3-reductions have a priority (colour) based on the degrees of the
   end vertex and two side vertices.  It cannot be changed without
   changing find_extensions_quad too.
*/

{
    EDGE *e,*elast,*e1;
    int maxdeg;
    int col,col1,col2,maxcol;
    int i,j,nor,nmir;

#define QORCOL3(e) \
      (((long)degree[e->next->end]<<10)+(long)degree[e->prev->end])
#define QMIRCOL3(e) \
      (((long)degree[e->prev->end]<<10)+(long)degree[e->next->end])

    RESETMARKS;

    maxdeg = 0;
    e1 = ref->next;

    for (j = 0; j < 4; ++j)
    {
	if (degree[e1->start] > maxdeg)
	{
	    maxdeg = degree[e1->start];
	    maxcol = QORCOL3(e1);
            nor = nmir = 0;
	    good_or[nor++] = e1;

	    col = QMIRCOL3(e1);
	    if (col > maxcol)
	    {
		nor = nmir = 0;
		good_mir[nmir++] = e1;
		maxcol = col;
	    }
	    else if (col == maxcol)
		good_mir[nmir++] = e1;
	}
	else if (degree[e1->start] == maxdeg)
	{
	    col = QORCOL3(e1);
	    if (col > maxcol)
            {
                nor = nmir = 0; 
                good_or[nor++] = e1;
                maxcol = col;
            }
            else if (col == maxcol)
                good_or[nor++] = e1;

            col = QMIRCOL3(e1);
            if (col > maxcol)
            {
                nor = nmir = 0; 
                good_mir[nmir++] = e1;
                maxcol = col;
            }
            else if (col == maxcol)
                good_mir[nmir++] = e1;
        }

	MARKLO(e1);
	e1 = e1->prev->invers->prev;
    }

    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

    for (i = 0; i < nv; ++i)
        if (degree[i] > maxdeg)
        {
	    e = elast = firstedge[i];
	    do
	    {
	        if (!ISMARKEDLO(e) && legal_P3_reduction(e->prev))
	        {
		    *ngood_ref = *ngood_mir_ref = 0;
		    return;
	        }
		e = e->next;
            } while (e != elast);
        }
	else if (degree[i] == maxdeg)
	{
	    e = elast = firstedge[i];
	    do
	    {
		if (!ISMARKEDLO(e))
		{
		    col1 = QORCOL3(e);
		    col2 = QMIRCOL3(e);
		    if (col1 > maxcol || col2 > maxcol)
		    {
			if (legal_P3_reduction(e->prev))
			{
                            *ngood_ref = *ngood_mir_ref = 0;
                            return;
			}
		    }
		    else if ((col1 == maxcol || col2 == maxcol)
		                           && legal_P3_reduction(e->prev))
		    {
			if (col1 == maxcol) good_or[nor++] = e;
			if (col2 == maxcol) good_mir[nmir++] = e;
		    }
                }
	        e = e->next;
	    } while (e != elast);
        }
    
    if (nor > *ngood_ref || nmir > *ngood_mir_ref)
        prune_oriented_lists(good_or,&nor,ngood_ref,
                             good_mir,&nmir,ngood_mir_ref);

    *ngood_or = nor;
    *ngood_mir = nmir;    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl 0x26f3a(%rip), %eax     # 0x3c084
addl $0x2, %eax
movl %eax, 0x26f31(%rip)     # 0x3c084
cmpl $0x7530, %eax           # imm = 0x7530
jle 0x1519a
movl $0x2, 0x26f20(%rip)     # 0x3c084
movl $0x0, -0x70(%rbp)
cmpl $0x1198, -0x70(%rbp)    # imm = 0x1198
jge 0x15198
movslq -0x70(%rbp), %rcx
leaq 0x2454b1(%rip), %rax    # 0x25a630
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x0, 0x30(%rax)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x1516b
jmp 0x1519a
movl $0x0, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x64(%rbp)
cmpl $0x4, -0x64(%rbp)
jge 0x1545a
movq -0x48(%rbp), %rax
movslq (%rax), %rcx
leaq 0x28a34(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jle 0x152e5
movq -0x48(%rbp), %rax
movslq (%rax), %rcx
leaq 0x28a1a(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x28a01(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x48(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x289e6(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x68(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x68(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x289a1(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x48(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x28986(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x152bc
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x152e0
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x152de
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x152e0
jmp 0x1542b
movq -0x48(%rbp), %rax
movslq (%rax), %rcx
leaq 0x2890d(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jne 0x15429
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x288ee(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x48(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x288d3(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x1536f
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x68(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x68(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x15393
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x15391
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x68(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x68(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x15393
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2885a(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x48(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x2883f(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x15403
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x50(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x15427
movl -0x50(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x15425
movq -0x48(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x15427
jmp 0x15429
jmp 0x1542b
movl 0x26c53(%rip), %ecx     # 0x3c084
movq -0x48(%rbp), %rax
movl %ecx, 0x30(%rax)
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x151b4
movl -0x68(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x6c(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl 0x2451a4(%rip), %eax    # 0x25a620
jge 0x15689
movslq -0x60(%rbp), %rcx
leaq 0x28773(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jle 0x15501
movslq -0x60(%rbp), %rcx
leaq 0x28560(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x26bcb(%rip), %eax     # 0x3c084
je 0x154e6
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x15b20
cmpl $0x0, %eax
je 0x154e6
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x156ce
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x154ac
jmp 0x15679
movslq -0x60(%rbp), %rcx
leaq 0x286f4(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jne 0x15677
movslq -0x60(%rbp), %rcx
leaq 0x284dd(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x26b48(%rip), %eax     # 0x3c084
je 0x1565b
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x286ab(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x38(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x28690(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x28673(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x38(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x28658(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x155c2
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x155ef
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x15b20
cmpl $0x0, %eax
je 0x155ed
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x156ce
jmp 0x15659
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
je 0x155ff
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x15657
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x15b20
cmpl $0x0, %eax
je 0x15657
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x15633
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x68(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x68(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x15655
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x6c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x6c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x15657
jmp 0x15659
jmp 0x1565b
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jne 0x1552f
jmp 0x15677
jmp 0x15679
jmp 0x1567b
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x15473
movl -0x68(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x1569f
movl -0x6c(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x156bc
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r9
leaq -0x68(%rbp), %rsi
leaq -0x6c(%rbp), %r8
callq 0x12be0
movl -0x68(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x6c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)