// File: /workspace/github_c_makefile_star2_O1/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, 0x20(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x78(%rsp)
movq %rsi, 0x18(%rsp)
movslq (%rdi), %rax
leaq 0x14b2c(%rip), %rbp     # 0x27bf0
movl (%rbp,%rax,4), %esi
movslq 0x4(%rdi), %rax
movl (%rbp,%rax,4), %ebx
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %r9d
movslq 0x4(%rcx), %rax
leal (%rbx,%rsi), %edx
movq %rdx, 0x70(%rsp)
movslq %edx, %rcx
shlq $0xa, %rcx
movq %rcx, 0x60(%rsp)
cmpl %ebx, %esi
movl 0x12f92(%rip), %r8d     # 0x26094
leal 0x2(%r8), %ecx
movl %ecx, 0x12f88(%rip)     # 0x26094
movl %ebx, %edx
movq %rsi, 0x38(%rsp)
cmovll %esi, %edx
movl (%rbp,%rax,4), %ecx
movslq %edx, %rdx
cmpl %ecx, %r9d
movl %ecx, %eax
cmovll %r9d, %eax
movq %r9, 0x28(%rsp)
leal (%rcx,%r9), %esi
movslq %esi, %rsi
shlq $0xa, %rsi
movq %rsi, 0x58(%rsp)
movslq %eax, %rsi
movl 0xd0(%rsp), %eax
cmpl $0x752f, %r8d           # imm = 0x752F
jl 0x1317a
movl $0x2, 0x12f3c(%rip)     # 0x26094
movl $0x30, %r8d
leaq 0x2314bb(%rip), %r9     # 0x244620
movl $0x0, (%r8,%r9)
addq $0x40, %r8
cmpq $0x46630, %r8           # imm = 0x46630
jne 0x13165
addq %rdx, 0x60(%rsp)
addq %rsi, 0x58(%rsp)
movl 0x12f09(%rip), %r8d     # 0x26094
movl %r8d, 0x30(%rdi)
movq 0x20(%rdi), %rdx
movl %r8d, 0x30(%rdx)
xorl %edx, %edx
movl %edx, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movl $0x0, %esi
testl %eax, %eax
jle 0x1339a
movq 0xc8(%rsp), %r9
movl %eax, %r10d
incq %r10
xorl %esi, %esi
xorl %edx, %edx
movq -0x10(%r9,%r10,8), %r11
movl %r8d, 0x30(%r11)
movq 0x20(%r11), %rax
movl %r8d, 0x30(%rax)
movq 0x10(%r11), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %r12d
cmpl $0x6, %r12d
jl 0x1338d
movq 0x18(%r11), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %r13d
cmpl $0x6, %r13d
jl 0x1338d
movslq (%r11), %rax
movq %rbp, %r14
movl (%rbp,%rax,4), %ebp
movslq 0x4(%r11), %rax
movl (%r14,%rax,4), %eax
leal (%rax,%rbp), %r15d
movslq %r15d, %r15
shlq $0xa, %r15
cmpl %eax, %ebp
movl %eax, %r14d
cmovll %ebp, %r14d
movslq %r14d, %r14
addq %r15, %r14
cmpq 0x60(%rsp), %r14
jne 0x13380
leal (%r12,%r13), %r14d
shlq $0xa, %r14
cmpl %r13d, %r12d
movl %r13d, %r15d
cmovll %r12d, %r15d
addq %r14, %r15
cmpq 0x58(%rsp), %r15
jg 0x1374e
jne 0x13386
movl %esi, %r14d
addl %edx, %r14d
jne 0x1331b
cmpl %ebx, 0x38(%rsp)
jl 0x13296
cmpl %ecx, 0x28(%rsp)
jl 0x13282
movslq %esi, %r14
incl %esi
movq 0x18(%rsp), %r15
movq %rdi, (%r15,%r14,8)
cmpl %ecx, 0x28(%rsp)
jg 0x13296
movslq %edx, %r14
incl %edx
movq 0x20(%rsp), %r15
movq %rdi, (%r15,%r14,8)
cmpl %ebx, 0x38(%rsp)
jg 0x13308
cmpl %ecx, 0x28(%rsp)
jg 0x132d2
movq 0x20(%rdi), %r14
movq %r14, 0x50(%rsp)
movslq %esi, %r14
movq %r14, 0x48(%rsp)
incl %esi
movq 0x18(%rsp), %r14
movq 0x50(%rsp), %r15
movq %rbx, 0x40(%rsp)
movq 0x48(%rsp), %rbx
movq %r15, (%r14,%rbx,8)
movq 0x40(%rsp), %rbx
cmpl %ecx, 0x28(%rsp)
jl 0x13308
movq 0x20(%rdi), %r14
movq %r14, 0x50(%rsp)
movslq %edx, %r14
movq %r14, 0x48(%rsp)
incl %edx
movq 0x20(%rsp), %r14
movq 0x50(%rsp), %r15
movq %rcx, 0x40(%rsp)
movq 0x48(%rsp), %rcx
movq %r15, (%r14,%rcx,8)
movq 0x40(%rsp), %rcx
movq 0x30(%rsp), %r14
movl %esi, (%r14)
movq 0xc0(%rsp), %r14
movl %edx, (%r14)
cmpl %eax, %ebp
jl 0x13345
cmpl %r13d, %r12d
jl 0x13332
movslq %esi, %r14
incl %esi
movq 0x18(%rsp), %r15
movq %r11, (%r15,%r14,8)
cmpl %r13d, %r12d
jg 0x13345
movslq %edx, %r14
incl %edx
movq 0x20(%rsp), %r15
movq %r11, (%r15,%r14,8)
cmpl %eax, %ebp
jg 0x13386
cmpl %r13d, %r12d
leaq 0x1489d(%rip), %rbp     # 0x27bf0
jg 0x13367
movq 0x20(%r11), %rax
movslq %esi, %r14
incl %esi
movq 0x18(%rsp), %r15
movq %rax, (%r15,%r14,8)
cmpl %r13d, %r12d
jl 0x1338d
movq 0x20(%r11), %rax
movslq %edx, %r11
incl %edx
movq 0x20(%rsp), %r14
movq %rax, (%r14,%r11,8)
jmp 0x1338d
jg 0x1374e
leaq 0x14863(%rip), %rbp     # 0x27bf0
decq %r10
cmpq $0x1, %r10
jg 0x131c0
movl %esi, 0xc(%rsp)
movl %edx, 0x8(%rsp)
movl %esi, %eax
addl %edx, %eax
jne 0x1344c
movq 0x38(%rsp), %rax
cmpl %ebx, %eax
jl 0x133f1
cmpl %ecx, 0x28(%rsp)
jl 0x133d3
leal 0x1(%rsi), %eax
movl %eax, 0xc(%rsp)
movslq %esi, %rax
movq 0x18(%rsp), %rsi
movq %rdi, (%rsi,%rax,8)
movq 0x38(%rsp), %rax
cmpl %ecx, 0x28(%rsp)
jg 0x133f1
leal 0x1(%rdx), %eax
movl %eax, 0x8(%rsp)
movslq %edx, %rax
movq 0x20(%rsp), %rdx
movq %rdi, (%rdx,%rax,8)
movq 0x38(%rsp), %rax
cmpl %ebx, %eax
jg 0x13433
cmpl %ecx, 0x28(%rsp)
jg 0x13414
movq 0x20(%rdi), %rax
movslq 0xc(%rsp), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0xc(%rsp)
movq 0x18(%rsp), %rsi
movq %rax, (%rsi,%rdx,8)
cmpl %ecx, 0x28(%rsp)
jl 0x13433
movq 0x20(%rdi), %rax
movslq 0x8(%rsp), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x8(%rsp)
movq 0x20(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
movl 0xc(%rsp), %eax
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movl 0x8(%rsp), %eax
movq 0xc0(%rsp), %rcx
movl %eax, (%rcx)
movl 0xc(%rsp), %eax
movq 0x30(%rsp), %rdx
cmpl (%rdx), %eax
movq 0xc0(%rsp), %r14
jg 0x1346a
movl 0x8(%rsp), %eax
cmpl (%r14), %eax
jle 0x1348b
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %r8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rcx
movq %r14, %r9
callq 0xe385
movq 0x30(%rsp), %rdx
movl (%rdx), %eax
addl (%r14), %eax
je 0x1377b
movq 0x38(%rsp), %rax
cmpl %ebx, %eax
movl %ebx, %ecx
cmovgl %eax, %ecx
movl %ecx, 0x50(%rsp)
movslq 0x231163(%rip), %rsi    # 0x244610
movl 0xc(%rsp), %ecx
movl %ecx, 0x10(%rsp)
movl 0x8(%rsp), %ecx
movl %ecx, 0x14(%rsp)
testq %rsi, %rsi
jle 0x136eb
addl %ebx, %eax
incl %eax
shrl $0x1f, %eax
movq 0x70(%rsp), %rcx
addl %ecx, %eax
incl %eax
sarl %eax
movl %eax, 0x28(%rsp)
leaq -0x1(%rsi), %rdi
movl -0x4(%rbp,%rsi,4), %r8d
cmpl 0x28(%rsp), %r8d
jl 0x136de
xorl %ebx, %ebx
cmpl 0x50(%rsp), %r8d
setg %bl
movq 0x70(%rsp), %rax
subl %r8d, %eax
addl %eax, %ebx
leaq 0x144e5(%rip), %rax     # 0x279f0
movq (%rax,%rdi,8), %r13
movq %r13, %r14
movl %ebx, 0x38(%rsp)
movl 0x30(%r14), %eax
cmpl 0x12b74(%rip), %eax     # 0x26094
je 0x136c4
movslq 0x4(%r14), %rax
movl (%rbp,%rax,4), %r12d
cmpl %ebx, %r12d
jl 0x136c4
movq 0x10(%r14), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %r15d
cmpl $0x6, %r15d
jl 0x136c4
movq 0x18(%r14), %rax
movslq 0x4(%rax), %rax
movl (%rbp,%rax,4), %ebp
cmpl $0x6, %ebp
jl 0x136bd
leal (%r12,%r8), %eax
cltq
shlq $0xa, %rax
cmpl %r12d, %r8d
movl %r12d, %ecx
cmovll %r8d, %ecx
movslq %ecx, %rcx
addq %rax, %rcx
cmpq 0x60(%rsp), %rcx
jle 0x135a7
movq %r8, %rbx
movq %rdi, %r12
movq %rsi, %r15
movq %r14, %rdi
callq 0x1841e
testl %eax, %eax
je 0x13758
leaq 0x1464b(%rip), %rbp     # 0x27bf0
jmp 0x135e2
leal (%r15,%rbp), %eax
shlq $0xa, %rax
cmpl %ebp, %r15d
movl %ebp, %ecx
cmovll %r15d, %ecx
addq %rax, %rcx
cmpq 0x58(%rsp), %rcx
jle 0x135f4
movq %r8, %rbx
movq %rdi, %r12
movq %rsi, %r15
movq %r14, %rdi
callq 0x1841e
testl %eax, %eax
leaq 0x14614(%rip), %rbp     # 0x27bf0
je 0x13758
movq %r15, %rsi
movq %r12, %rdi
movq %rbx, %r8
movl 0x38(%rsp), %ebx
jmp 0x136c4
jne 0x136bd
movq %r8, 0x68(%rsp)
movq %rdi, 0x40(%rsp)
movq %rsi, 0x48(%rsp)
movq %r14, %rdi
callq 0x1841e
testl %eax, %eax
je 0x13630
leaq 0x145d4(%rip), %rbp     # 0x27bf0
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
movq 0x68(%rsp), %r8
jmp 0x136c4
movq 0x68(%rsp), %r8
cmpl %r12d, %r8d
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdi
jl 0x1367a
cmpl %ebp, %r15d
jl 0x1365f
movl 0x10(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x10(%rsp)
movq 0x18(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
cmpl %ebp, %r15d
jg 0x1367a
movl 0x14(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x14(%rsp)
movq 0x20(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
cmpl %r12d, %r8d
jg 0x136bd
cmpl %ebp, %r15d
jg 0x1369e
movq 0x20(%r14), %rax
movl 0x10(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x10(%rsp)
movq 0x18(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
cmpl %ebp, %r15d
jl 0x136bd
movq 0x20(%r14), %rax
movl 0x14(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x14(%rsp)
movq 0x20(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
leaq 0x1452c(%rip), %rbp     # 0x27bf0
movl 0x129ca(%rip), %eax     # 0x26094
movq 0x20(%r14), %rcx
movl %eax, 0x30(%rcx)
movq 0x18(%r14), %r14
cmpq %r13, %r14
jne 0x13516
cmpq $0x1, %rsi
movq %rdi, %rsi
jg 0x134dc
movl 0x10(%rsp), %ecx
movl %ecx, 0xc(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rdx
cmpl (%rdx), %ecx
jg 0x13714
movl 0x8(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl (%rcx), %eax
jle 0x13735
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %r8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rcx
movq 0xc0(%rsp), %r9
callq 0xe385
movl 0xc(%rsp), %eax
movq 0x78(%rsp), %rcx
movl %eax, (%rcx)
movl 0x8(%rsp), %eax
movq 0x80(%rsp), %rcx
jmp 0x13779
movl %esi, 0xc(%rsp)
movl %edx, 0x8(%rsp)
jmp 0x13768
movl 0x10(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x8(%rsp)
xorl %eax, %eax
movq 0xc0(%rsp), %rcx
movl %eax, (%rcx)
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq