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

/* The A-operation with reference edge *ref has just been performed.
   prevA[0..nprevA-1] are all earlier As since the last B or C.
   Make a list in good_or[0..*ngood_or-1] of the reference edges of
   legal A-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-2.  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).
   A-reductions have a priority (colour) based on the degrees of the
   four central vertices.  It cannot be changed without changing
   extensions_min5 too.
*/
{
    EDGE *e;
    int deg1,deg2,deg3,deg4,d1,d2,d3,d4;
    long bestcol1,bestcol2,col1,col2;
    int nor,nmir,i;
    int mind1,mind2,maxdeg12,sumdeg12;
    EDGE *ei,*eilast,*hint;
#define PAIR(x,y) (((long)((x)+(y))<<10)+(long)(x))
#define UPAIR(x,y) ((x)<(y) ? PAIR(x,y) : PAIR(y,x))

    e = ref;
    deg1 = degree[e->start];
    deg2 = degree[e->end];
    deg3 = degree[e->prev->end];
    deg4 = degree[e->next->end];

    bestcol1 = UPAIR(deg1,deg2);
    bestcol2 = UPAIR(deg3,deg4);

    RESETMARKS;
    MARKLO(e);
    MARKLO(e->invers);

    nor = nmir = 0;

    for (i = nprevA; --i >= 0;)
    {
	hint = prevA[i];
 	MARKLO(hint);
 	MARKLO(hint->invers);
        if ((d3 = degree[hint->prev->end]) >= 6
                      && (d4 = degree[hint->next->end]) >= 6)
        {
           /* Theorem: The reference edges of the A-expansions since the
              most recent B- or C-expansion are not on essential 5-cycles. */
            d1 = degree[hint->start];
            d2 = degree[hint->end];
            col1 = UPAIR(d1,d2);
	    if (col1 == bestcol1)
	    {
                col2 = UPAIR(d3,d4);
                if (col2 > bestcol2)
                {
                    *ngood_ref = *ngood_mir_ref = 0;
                    return;
                }
	        else if (col2 == bestcol2)
    	        {   
		    if (nor + nmir == 0)
		    {
    		        if (deg1 >= deg2)
    		        {
        		    if (deg3 >= deg4) good_or[nor++] = e;
        		    if (deg3 <= deg4) good_mir[nmir++] = e;
    		        }
    		        if (deg1 <= deg2)
    		        {
        		    if (deg3 <= deg4) good_or[nor++] = e->invers;
        		    if (deg3 >= deg4) good_mir[nmir++] = e->invers;
    		        }
		        *ngood_ref = nor;
    		        *ngood_mir_ref = nmir;
		    }
    
        	    if (d1 >= d2)
        	    {   
            	        if (d3 >= d4) good_or[nor++] = hint;
            	        if (d3 <= d4) good_mir[nmir++] = hint;
        	    }
        	    if (d1 <= d2)
        	    {
            	        if (d3 <= d4) good_or[nor++] = hint->invers;
            	        if (d3 >= d4) good_mir[nmir++] = hint->invers;
        	    }
    	        }
	    }
	    else if (col1 > bestcol1)
            {   
                *ngood_ref = *ngood_mir_ref = 0;
                return;
            }
	}
    }

    if (nor + nmir == 0)
    {
        if (deg1 >= deg2)
        {
            if (deg3 >= deg4) good_or[nor++] = e;
            if (deg3 <= deg4) good_mir[nmir++] = e;
        }
        if (deg1 <= deg2)
        {
            if (deg3 <= deg4) good_or[nor++] = e->invers;
            if (deg3 >= deg4) good_mir[nmir++] = e->invers;
        }
    
        *ngood_ref = nor;
        *ngood_mir_ref = nmir;
    }

    if (nor > *ngood_ref || nmir > *ngood_mir_ref)
        prune_oriented_lists(good_or,&nor,ngood_ref,
                             good_mir,&nmir,ngood_mir_ref);

    if (*ngood_ref+*ngood_mir_ref == 0) return;

    sumdeg12 = deg1 + deg2;
    mind1 = (sumdeg12 + 1) / 2;
    maxdeg12 = MAX(deg1,deg2);

    for (i = nv; --i >= 0;)
    if ((d1 = degree[i]) >= mind1)
    {
	if (d1 <= maxdeg12) mind2 = sumdeg12 - d1;
	else                mind2 = sumdeg12 - d1 + 1;

	ei = eilast = firstedge[i];
	do
	{
            if (!ISMARKEDLO(ei) && (d2 = degree[ei->end]) >= mind2
                                && (d3 = degree[ei->prev->end]) >= 6
                                && (d4 = degree[ei->next->end]) >= 6)
	    {
		col1 = UPAIR(d1,d2);

		if (col1 > bestcol1)
		{
		    if (!on_nf_5_cycle(ei))
		    {
			*ngood_ref = *ngood_mir_ref = 0;
			return;
		    }
		}
		else
		{
		    col2 = UPAIR(d3,d4);
		    if (col2 > bestcol2)
                    {
                        if (!on_nf_5_cycle(ei))
                        {
                            *ngood_ref = *ngood_mir_ref = 0;
                            return;
                        }
                    }
		    else if (col2 == bestcol2 && !on_nf_5_cycle(ei))
		    {
	                if (d1 >= d2)
    		        {
        		    if (d3 >= d4) good_or[nor++] = ei;
        		    if (d3 <= d4) good_mir[nmir++] = ei;
    		        }
    		        if (d1 <= d2)
    		        {
        		    if (d3 <= d4) good_or[nor++] = ei->invers;
        		    if (d3 >= d4) good_mir[nmir++] = ei->invers;
    		        }
		    }
	        }
	    }
	    MARKLO(ei->invers);
	    ei = ei->next;
	} while (ei != eilast);
    }

    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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x80(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x78(%rsp)
movq %rsi, 0x28(%rsp)
movslq (%rdi), %rax
leaq 0x14a2f(%rip), %rbp     # 0x27bf0
movl (%rbp,%rax,4), %r8d
movslq 0x4(%rdi), %rax
movl (%rbp,%rax,4), %r9d
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %eax
movslq 0x4(%rcx), %rcx
movl (%rbp,%rcx,4), %ecx
leal (%r9,%r8), %esi
movq %rsi, 0x70(%rsp)
movslq %esi, %rdx
shlq $0xa, %rdx
movq %rdx, 0x68(%rsp)
cmpl %r9d, %r8d
movq %r9, 0x10(%rsp)
movl %r9d, %edx
movq %r8, 0x48(%rsp)
cmovll %r8d, %edx
movslq %edx, %rdx
cmpl %ecx, %eax
movl %ecx, %esi
cmovll %eax, %esi
movq %rax, 0x20(%rsp)
leal (%rcx,%rax), %r8d
movslq %r8d, %r8
shlq $0xa, %r8
movq %r8, 0x60(%rsp)
movslq %esi, %r8
movl 0x12e53(%rip), %r9d     # 0x2608c
leal 0x2(%r9), %r14d
movl %r14d, 0x12e48(%rip)    # 0x2608c
movl 0xd0(%rsp), %esi
cmpl $0x752f, %r9d           # imm = 0x752F
jl 0x13286
movl $0x2, 0x12e2e(%rip)     # 0x2608c
movl $0x30, %r9d
leaq 0x2313b5(%rip), %r10    # 0x244620
movl $0x0, (%r9,%r10)
addq $0x40, %r9
cmpq $0x46630, %r9           # imm = 0x46630
jne 0x1326b
movl $0x2, %r14d
addq %rdx, 0x68(%rsp)
addq %r8, 0x60(%rsp)
movl %r14d, 0x30(%rdi)
movq 0x20(%rdi), %rdx
movl %r14d, 0x30(%rdx)
testl %esi, %esi
jle 0x134d4
movq 0xc8(%rsp), %r8
movl %esi, %r9d
incq %r9
xorl %esi, %esi
xorl %edx, %edx
movq -0x10(%r8,%r9,8), %r10
movl %r14d, 0x30(%r10)
movq 0x20(%r10), %r11
movl %r14d, 0x30(%r11)
movq 0x10(%r10), %r11
movslq 0x4(%r11), %r11
movl (%rbp,%r11,4), %r11d
cmpl $0x6, %r11d
jl 0x134c5
movq 0x18(%r10), %r15
movslq 0x4(%r15), %r15
movl (%rbp,%r15,4), %r15d
cmpl $0x6, %r15d
jl 0x134c5
movslq (%r10), %r12
movl (%rbp,%r12,4), %r12d
movslq 0x4(%r10), %r13
movl (%rbp,%r13,4), %r13d
leal (%r12,%r13), %ebp
movslq %ebp, %rbp
shlq $0xa, %rbp
cmpl %r13d, %r12d
movl %r13d, %ebx
cmovll %r12d, %ebx
movslq %ebx, %rbx
addq %rbp, %rbx
cmpq 0x68(%rsp), %rbx
jne 0x13371
leal (%r15,%r11), %ebx
shlq $0xa, %rbx
cmpl %r15d, %r11d
movl %r15d, %ebp
cmovbl %r11d, %ebp
addq %rbx, %rbp
cmpq 0x60(%rsp), %rbp
jg 0x13843
jne 0x13383
movl %esi, %ebx
addl %edx, %ebx
leaq 0x1489b(%rip), %rbp     # 0x27bf0
jne 0x1345d
movq 0x10(%rsp), %rbx
cmpl %ebx, 0x48(%rsp)
jge 0x1338f
cmpl %ecx, 0x20(%rsp)
jle 0x133e2
jmp 0x13419
leaq 0x14878(%rip), %rbp     # 0x27bf0
jle 0x134c5
jmp 0x13843
leaq 0x14866(%rip), %rbp     # 0x27bf0
jmp 0x134c5
cmpl %ecx, 0x20(%rsp)
jl 0x133a4
movslq %esi, %rbx
incl %esi
movq 0x28(%rsp), %rbp
movq %rdi, (%rbp,%rbx,8)
cmpl %ecx, 0x20(%rsp)
jle 0x133c1
movq 0x10(%rsp), %rbx
cmpl %ebx, 0x48(%rsp)
leaq 0x14836(%rip), %rbp     # 0x27bf0
jle 0x13419
jmp 0x1344c
movslq %edx, %rbx
incl %edx
movq 0x30(%rsp), %rbp
movq %rdi, (%rbp,%rbx,8)
movq 0x10(%rsp), %rbx
cmpl %ebx, 0x48(%rsp)
leaq 0x14810(%rip), %rbp     # 0x27bf0
jg 0x1344c
movq 0x20(%rdi), %rbx
movq %rbx, 0x40(%rsp)
movslq %esi, %rbx
movq %rbx, 0x58(%rsp)
incl %esi
movq 0x28(%rsp), %rbx
movq 0x40(%rsp), %rbp
movq %rcx, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq %rbp, (%rbx,%rax,8)
movq 0x50(%rsp), %rcx
leaq 0x147d7(%rip), %rbp     # 0x27bf0
cmpl %ecx, 0x20(%rsp)
jl 0x1344c
movq 0x20(%rdi), %rbx
movq %rbx, 0x40(%rsp)
movslq %edx, %rbx
movq %rbx, 0x58(%rsp)
incl %edx
movq 0x30(%rsp), %rbx
movq 0x40(%rsp), %rbp
movq 0x58(%rsp), %rax
movq %rbp, (%rbx,%rax,8)
leaq 0x147a4(%rip), %rbp     # 0x27bf0
movq 0x38(%rsp), %rbx
movl %esi, (%rbx)
movq 0xc0(%rsp), %rbx
movl %edx, (%rbx)
cmpl %r13d, %r12d
jl 0x13491
cmpl %r15d, %r11d
jb 0x13476
movslq %esi, %rbx
incl %esi
movq 0x28(%rsp), %rbp
movq %r10, (%rbp,%rbx,8)
cmpl %r15d, %r11d
ja 0x1348a
movslq %edx, %rbx
incl %edx
movq 0x30(%rsp), %rbp
movq %r10, (%rbp,%rbx,8)
leaq 0x1475f(%rip), %rbp     # 0x27bf0
cmpl %r13d, %r12d
jg 0x134c5
cmpl %r15d, %r11d
ja 0x134ae
movq 0x20(%r10), %rbx
movslq %esi, %r12
incl %esi
movq 0x28(%rsp), %r13
movq %rbx, (%r13,%r12,8)
cmpl %r15d, %r11d
jb 0x134c5
movq 0x20(%r10), %r10
movslq %edx, %r11
incl %edx
movq 0x30(%rsp), %rbx
movq %r10, (%rbx,%r11,8)
decq %r9
cmpq $0x1, %r9
ja 0x132b6
jmp 0x134d8
xorl %edx, %edx
xorl %esi, %esi
movl %esi, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movl %esi, %r8d
addl %edx, %r8d
jne 0x1357f
movq 0x10(%rsp), %r8
cmpl %r8d, 0x48(%rsp)
jl 0x13528
cmpl %ecx, 0x20(%rsp)
jl 0x13510
movslq %esi, %r8
incl %esi
movl %esi, 0xc(%rsp)
movq 0x28(%rsp), %r9
movq %rdi, (%r9,%r8,8)
cmpl %ecx, 0x20(%rsp)
jg 0x13528
movslq %edx, %r8
incl %edx
movl %edx, 0x8(%rsp)
movq 0x30(%rsp), %r9
movq %rdi, (%r9,%r8,8)
movq 0x10(%rsp), %r8
cmpl %r8d, 0x48(%rsp)
jg 0x1356c
cmpl %ecx, 0x20(%rsp)
jg 0x13550
movq 0x20(%rdi), %r8
movslq %esi, %r9
incl %esi
movl %esi, 0xc(%rsp)
movq 0x28(%rsp), %r10
movq %r8, (%r10,%r9,8)
cmpl %ecx, 0x20(%rsp)
jl 0x1356c
movq 0x20(%rdi), %rax
movslq %edx, %rcx
incl %edx
movl %edx, 0x8(%rsp)
movq 0x30(%rsp), %rdi
movq %rax, (%rdi,%rcx,8)
movq 0x38(%rsp), %rax
movl %esi, (%rax)
movq 0xc0(%rsp), %rcx
movl %edx, (%rcx)
jmp 0x13584
movq 0x38(%rsp), %rax
movl (%rax), %eax
cmpl %eax, %esi
jg 0x13598
movq 0xc0(%rsp), %rcx
movl (%rcx), %ecx
cmpl %ecx, %edx
jle 0x135c9
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %r8
movq 0x28(%rsp), %rdi
movq 0x38(%rsp), %rbx
movq %rbx, %rdx
movq 0x30(%rsp), %rcx
movq 0xc0(%rsp), %r15
movq %r15, %r9
callq 0xe49a
movl (%rbx), %eax
movl (%r15), %ecx
addl %eax, %ecx
je 0x138c3
movq 0x48(%rsp), %rcx
movq 0x10(%rsp), %rdx
cmpl %edx, %ecx
movl %edx, %esi
cmovgl %ecx, %esi
movl %esi, 0x20(%rsp)
movslq 0x231023(%rip), %r9     # 0x244610
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edi
testq %r9, %r9
jle 0x13858
movl %edi, 0x1c(%rsp)
movl %esi, 0x50(%rsp)
leal (%rdx,%rcx), %eax
incl %eax
shrl $0x1f, %eax
movq 0x70(%rsp), %rcx
addl %ecx, %eax
incl %eax
sarl %eax
movl %eax, 0x48(%rsp)
movq %r9, %rdx
leaq -0x1(%rdx), %rsi
movl -0x4(%rbp,%rdx,4), %edi
cmpl 0x48(%rsp), %edi
jge 0x1363c
cmpq $0x1, %rdx
movq %rsi, %rdx
jg 0x13620
jmp 0x1385f
xorl %r12d, %r12d
cmpl 0x20(%rsp), %edi
setg %r12b
movq 0x70(%rsp), %rax
subl %edi, %eax
addl %eax, %r12d
leaq 0x14398(%rip), %rax     # 0x279f0
movq (%rax,%rsi,8), %r15
movq %r15, %rbx
cmpl %r14d, 0x30(%rbx)
je 0x137d6
movslq 0x4(%rbx), %rax
movl (%rbp,%rax,4), %r13d
cmpl %r12d, %r13d
jl 0x137d6
movq 0x10(%rbx), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %r14d
cmpl $0x6, %r14d
jl 0x137d6
movq 0x18(%rbx), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %ebp
cmpl $0x6, %ebp
jl 0x137cf
leal (%rdi,%r13), %eax
cltq
shlq $0xa, %rax
cmpl %r13d, %edi
movl %r13d, %ecx
cmovll %edi, %ecx
movslq %ecx, %rcx
addq %rax, %rcx
cmpq 0x68(%rsp), %rcx
jle 0x136f5
movq %rdi, %rbp
movq %rbx, %rdi
movq %rdx, %r14
movq %rsi, %r13
callq 0x184cf
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
testl %eax, %eax
leaq 0x14506(%rip), %rbp     # 0x27bf0
jne 0x137d6
jmp 0x13843
movq %rsi, 0x10(%rsp)
leal (%r14,%rbp), %eax
shlq $0xa, %rax
cmpl %ebp, %r14d
movl %ebp, %ecx
cmovbl %r14d, %ecx
addq %rax, %rcx
cmpq 0x60(%rsp), %rcx
jle 0x13742
movq %rdi, %r13
movq %rbx, %rdi
movq %rdx, %r14
callq 0x184cf
movq %r13, %rdi
movq %r14, %rdx
testl %eax, %eax
leaq 0x144be(%rip), %rbp     # 0x27bf0
movq 0x10(%rsp), %rsi
jne 0x137d6
jmp 0x13843
jne 0x13772
movq %rdi, 0x58(%rsp)
movq %rdx, 0x40(%rsp)
movq %rbx, %rdi
callq 0x184cf
testl %eax, %eax
je 0x13780
leaq 0x1448f(%rip), %rbp     # 0x27bf0
movq 0x40(%rsp), %rdx
movq 0x10(%rsp), %rsi
movq 0x58(%rsp), %rdi
jmp 0x137d6
leaq 0x14477(%rip), %rbp     # 0x27bf0
movq 0x10(%rsp), %rsi
jmp 0x137d6
movq 0x58(%rsp), %rdi
cmpl %r13d, %edi
movq 0x40(%rsp), %rdx
movq 0x10(%rsp), %rsi
jl 0x137ca
cmpl %ebp, %r14d
jb 0x137af
movl 0x50(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x50(%rsp)
movq 0x28(%rsp), %rcx
movq %rbx, (%rcx,%rax,8)
cmpl %ebp, %r14d
ja 0x137ca
movl 0x1c(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x1c(%rsp)
movq 0x30(%rsp), %rcx
movq %rbx, (%rcx,%rax,8)
cmpl %r13d, %edi
jle 0x137f7
leaq 0x1441a(%rip), %rbp     # 0x27bf0
movl 0x128af(%rip), %r14d    # 0x2608c
movq 0x20(%rbx), %rax
movl %r14d, 0x30(%rax)
movq 0x18(%rbx), %rbx
cmpq %r15, %rbx
jne 0x1365f
jmp 0x1362e
cmpl %ebp, %r14d
ja 0x13816
movq 0x20(%rbx), %rax
movl 0x50(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x50(%rsp)
movq 0x28(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
cmpl %ebp, %r14d
jb 0x13835
movq 0x20(%rbx), %rax
movl 0x1c(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x1c(%rsp)
movq 0x30(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
leaq 0x143b4(%rip), %rbp     # 0x27bf0
movq 0x40(%rsp), %rdx
jmp 0x137d6
xorl %eax, %eax
movq 0xc0(%rsp), %rcx
movl %eax, (%rcx)
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x138c3
movq 0x38(%rsp), %rdx
jmp 0x1386e
movq 0x38(%rsp), %rdx
movl (%rdx), %eax
movl 0x50(%rsp), %esi
movl 0x1c(%rsp), %edi
movl %esi, 0xc(%rsp)
movl %edi, 0x8(%rsp)
cmpl %eax, %esi
jg 0x13886
movq 0xc0(%rsp), %rax
cmpl (%rax), %edi
jle 0x138b2
leaq 0xc(%rsp), %rbx
leaq 0x8(%rsp), %r15
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq 0x30(%rsp), %rcx
movq %r15, %r8
movq 0xc0(%rsp), %r9
callq 0xe49a
movl (%rbx), %esi
movl (%r15), %edi
movq 0x78(%rsp), %rax
movl %esi, (%rax)
movq 0x80(%rsp), %rax
movl %edi, (%rax)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq