// File: /workspace/github_c_makefile_star2_O2/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 $0x78, %rsp
movq %r9, 0x70(%rsp)
movq %r8, 0x20(%rsp)
movq %rcx, 0x38(%rsp)
movq %rdx, 0x68(%rsp)
movq %rsi, 0x18(%rsp)
movslq (%rdi), %rax
leaq 0x13dbd(%rip), %rsi     # 0x25be0
movl (%rsi,%rax,4), %r10d
movslq 0x4(%rdi), %rax
movl (%rsi,%rax,4), %edx
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
movslq 0x4(%rax), %rax
movl (%rsi,%rax,4), %r8d
movslq 0x4(%rcx), %rax
leal (%rdx,%r10), %ecx
movl %ecx, 0x64(%rsp)
movslq %ecx, %rcx
shlq $0xa, %rcx
movq %rcx, 0x58(%rsp)
cmpl %edx, %r10d
movq %rdx, 0x40(%rsp)
cmovll %r10d, %edx
movl (%rsi,%rax,4), %ecx
movslq %edx, %rax
cmpl %ecx, %r8d
movl %ecx, %edx
cmovll %r8d, %edx
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
leal (%rcx,%r8), %esi
movslq %esi, %rcx
shlq $0xa, %rcx
movq %rcx, 0x50(%rsp)
movslq %edx, %rdx
movl 0x121e7(%rip), %r8d     # 0x2407c
leal 0x2(%r8), %r12d
movl %r12d, 0x121dc(%rip)    # 0x2407c
movl 0xc0(%rsp), %esi
pushq $0x2
popq %rcx
cmpl $0x752f, %r8d           # imm = 0x752F
jl 0x11edf
movl $0x2, 0x121bf(%rip)     # 0x2407c
pushq $0x30
popq %r8
leaq 0x230748(%rip), %r9     # 0x242610
cmpq $0x46630, %r8           # imm = 0x46630
je 0x11edc
andl $0x0, (%r8,%r9)
addq $0x40, %r8
jmp 0x11ec8
movl %ecx, %r12d
movq %r10, 0x48(%rsp)
movq 0xb8(%rsp), %rcx
addq %rax, 0x58(%rsp)
addq %rdx, 0x50(%rsp)
movl %r12d, 0x30(%rdi)
movq %rdi, 0x8(%rsp)
movq 0x20(%rdi), %rax
movq %rcx, %rdi
movl %r12d, 0x30(%rax)
movl %esi, %r9d
xorl %edx, %edx
xorl %esi, %esi
leaq 0x13cc8(%rip), %r8      # 0x25be0
movl %r9d, %eax
decq %r9
movslq %esi, %rbp
movslq %edx, %r14
testl %eax, %eax
jle 0x1210a
movq (%rdi,%r9,8), %r10
movl %r12d, 0x30(%r10)
movq 0x20(%r10), %r11
movl %r12d, 0x30(%r11)
movq 0x10(%r10), %r11
movslq 0x4(%r11), %r11
movl (%r8,%r11,4), %r11d
cmpl $0x6, %r11d
jl 0x11fc9
movq 0x18(%r10), %rbx
movslq 0x4(%rbx), %rbx
movl (%r8,%rbx,4), %r15d
cmpl $0x6, %r15d
jl 0x11fc9
movslq (%r10), %rbx
movl (%r8,%rbx,4), %r13d
movslq 0x4(%r10), %rbx
movl (%r8,%rbx,4), %ebx
leal (%rbx,%r13), %ecx
movslq %ecx, %rcx
shlq $0xa, %rcx
cmpl %ebx, %r13d
movl %ebx, %r8d
cmovll %r13d, %r8d
movslq %r8d, %r8
addq %rcx, %r8
cmpq 0x58(%rsp), %r8
jne 0x11fbc
leal (%r15,%r11), %ecx
shlq $0xa, %rcx
cmpl %r15d, %r11d
movl %r15d, %r8d
cmovbl %r11d, %r8d
addq %rcx, %r8
cmpq 0x50(%rsp), %r8
jg 0x1240d
leaq 0x13c28(%rip), %r8      # 0x25be0
jne 0x11fc9
jmp 0x11fd0
leaq 0x13c1d(%rip), %r8      # 0x25be0
jg 0x1240d
decl %eax
jmp 0x11f1b
movl %esi, %eax
addl %edx, %eax
jne 0x12098
movq 0x48(%rsp), %rax
cmpl 0x40(%rsp), %eax
jge 0x11ff2
movq 0x28(%rsp), %rax
cmpl %eax, 0x30(%rsp)
jle 0x12040
jmp 0x1205e
movq 0x28(%rsp), %rax
cmpl %eax, 0x30(%rsp)
jl 0x1200d
incl %esi
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax,%rbp,8)
movq 0x28(%rsp), %rax
cmpl %eax, 0x30(%rsp)
jle 0x12025
movq 0x48(%rsp), %rax
cmpl 0x40(%rsp), %eax
jle 0x1205e
jmp 0x12087
incl %edx
movq 0x20(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax,%r14,8)
movq 0x48(%rsp), %rax
cmpl 0x40(%rsp), %eax
jg 0x12087
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movslq %esi, %rcx
incl %esi
movq 0x18(%rsp), %r8
movq %rax, (%r8,%rcx,8)
leaq 0x13b82(%rip), %r8      # 0x25be0
movq 0x28(%rsp), %rax
cmpl %eax, 0x30(%rsp)
jl 0x12087
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movslq %edx, %rcx
incl %edx
movq 0x20(%rsp), %r8
movq %rax, (%r8,%rcx,8)
leaq 0x13b59(%rip), %r8      # 0x25be0
movq 0x38(%rsp), %rax
movl %esi, (%rax)
movq 0xb0(%rsp), %rax
movl %edx, (%rax)
cmpl %ebx, %r13d
jl 0x120c3
cmpl %r15d, %r11d
jb 0x120b0
movslq %esi, %rax
incl %esi
movq 0x18(%rsp), %rcx
movq %r10, (%rcx,%rax,8)
cmpl %r15d, %r11d
ja 0x120c3
movslq %edx, %rax
incl %edx
movq 0x20(%rsp), %rcx
movq %r10, (%rcx,%rax,8)
cmpl %ebx, %r13d
jg 0x11f18
cmpl %r15d, %r11d
ja 0x120ea
movq 0x20(%r10), %rax
movslq %esi, %rcx
incl %esi
movq 0x18(%rsp), %r8
movq %rax, (%r8,%rcx,8)
leaq 0x13af6(%rip), %r8      # 0x25be0
cmpl %r15d, %r11d
jb 0x11f18
movq 0x20(%r10), %rax
movslq %edx, %rcx
incl %edx
movq 0x20(%rsp), %r8
movq %rax, (%r8,%rcx,8)
jmp 0x11f11
movl %esi, 0x4(%rsp)
movl %edx, (%rsp)
movl %esi, %eax
addl %edx, %eax
jne 0x12136
movq 0x48(%rsp), %r15
cmpl 0x40(%rsp), %r15d
jge 0x12145
movq 0x30(%rsp), %r10
cmpl 0x28(%rsp), %r10d
movq 0x8(%rsp), %r9
jle 0x1218a
jmp 0x121a0
movq 0x38(%rsp), %rax
movq 0x48(%rsp), %r15
jmp 0x121cd
movq 0x30(%rsp), %r10
cmpl 0x28(%rsp), %r10d
movq 0x8(%rsp), %r9
jl 0x12165
incl %esi
movl %esi, 0x4(%rsp)
movq 0x18(%rsp), %rax
movq %r9, (%rax,%rbp,8)
cmpl 0x28(%rsp), %r10d
jle 0x12175
cmpl 0x40(%rsp), %r15d
jle 0x121a0
jmp 0x121bc
incl %edx
movl %edx, (%rsp)
movq 0x20(%rsp), %rax
movq %r9, (%rax,%r14,8)
cmpl 0x40(%rsp), %r15d
jg 0x121bc
movq 0x20(%r9), %rax
movslq %esi, %rcx
incl %esi
movl %esi, 0x4(%rsp)
movq 0x18(%rsp), %rdi
movq %rax, (%rdi,%rcx,8)
cmpl 0x28(%rsp), %r10d
jl 0x121bc
movq 0x20(%r9), %rax
movslq %edx, %rcx
incl %edx
movl %edx, (%rsp)
movq 0x20(%rsp), %rdi
movq %rax, (%rdi,%rcx,8)
movq 0x38(%rsp), %rax
movl %esi, (%rax)
movq 0xb0(%rsp), %rcx
movl %edx, (%rcx)
movl (%rax), %eax
cmpl %eax, %esi
jg 0x121e1
movq 0xb0(%rsp), %rcx
movl (%rcx), %ecx
cmpl %ecx, %edx
jle 0x12217
leaq 0x4(%rsp), %rsi
movq %rsp, %r8
movq 0x18(%rsp), %rdi
movq 0x38(%rsp), %rbx
movq %rbx, %rdx
movq 0x20(%rsp), %rcx
movq 0xb0(%rsp), %r14
movq %r14, %r9
callq 0xd354
leaq 0x139ce(%rip), %r8      # 0x25be0
movl (%rbx), %eax
movl (%r14), %ecx
addl %eax, %ecx
je 0x1247e
movq 0x40(%rsp), %rcx
leal (%rcx,%r15), %eax
incl %eax
cltd
pushq $0x2
popq %rsi
idivl %esi
movl %eax, %edx
cmpl %ecx, %r15d
cmovgl %r15d, %ecx
movq %rcx, 0x40(%rsp)
movl 0x2303bc(%rip), %ecx    # 0x242600
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
movl (%rsp), %eax
movl %eax, 0x14(%rsp)
movl %edx, 0x48(%rsp)
movq %rcx, %rax
testl %eax, %eax
jle 0x12422
leaq -0x1(%rax), %rcx
movl -0x4(%r8,%rax,4), %esi
cmpl %edx, %esi
jl 0x12257
movq %rcx, 0x28(%rsp)
xorl %ebx, %ebx
cmpl 0x40(%rsp), %esi
setg %bl
movl 0x64(%rsp), %ecx
subl %esi, %ecx
addl %ecx, %ebx
leaq 0x13754(%rip), %rcx     # 0x259e0
movq -0x8(%rcx,%rax,8), %r13
movq %r13, %r14
cmpl %r12d, 0x30(%r14)
je 0x12326
movslq 0x4(%r14), %rax
movl (%r8,%rax,4), %r15d
cmpl %ebx, %r15d
jl 0x12326
movq 0x10(%r14), %rax
movslq 0x4(%rax), %rax
movl (%r8,%rax,4), %r12d
cmpl $0x6, %r12d
jl 0x12326
movq 0x18(%r14), %rax
movslq 0x4(%rax), %rax
movl (%r8,%rax,4), %ebp
cmpl $0x6, %ebp
jl 0x12326
leal (%r15,%rsi), %eax
cltq
shlq $0xa, %rax
cmpl %r15d, %esi
movl %r15d, %ecx
cmovll %esi, %ecx
movslq %ecx, %rcx
addq %rax, %rcx
cmpq 0x58(%rsp), %rcx
jg 0x12309
leal (%r12,%rbp), %eax
shlq $0xa, %rax
cmpl %ebp, %r12d
movl %ebp, %ecx
cmovbl %r12d, %ecx
addq %rax, %rcx
cmpq 0x50(%rsp), %rcx
jle 0x12347
movq %r14, %rdi
movq %rsi, %r15
callq 0x16e0b
movq %r15, %rsi
leaq 0x138c2(%rip), %r8      # 0x25be0
testl %eax, %eax
je 0x1240d
movl 0x11d4f(%rip), %r12d    # 0x2407c
movq 0x20(%r14), %rax
movl %r12d, 0x30(%rax)
movq 0x18(%r14), %r14
cmpq %r13, %r14
jne 0x12294
jmp 0x123ff
jne 0x12326
movq %rsi, 0x30(%rsp)
movq %r14, %rdi
callq 0x16e0b
testl %eax, %eax
je 0x12368
leaq 0x1387f(%rip), %r8      # 0x25be0
movq 0x30(%rsp), %rsi
jmp 0x12326
movq 0x30(%rsp), %rsi
cmpl %r15d, %esi
leaq 0x13869(%rip), %r8      # 0x25be0
jl 0x123af
cmpl %ebp, %r12d
jb 0x12394
movl 0x8(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x8(%rsp)
movq 0x18(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
cmpl %ebp, %r12d
ja 0x123af
movl 0x14(%rsp), %ecx
movslq %ecx, %rax
incl %ecx
movl %ecx, 0x14(%rsp)
movq 0x20(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
cmpl %r15d, %esi
jg 0x12326
cmpl %ebp, %r12d
ja 0x123d7
movq 0x20(%r14), %rax
movl 0x8(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, 0x8(%rsp)
movq 0x18(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
cmpl %ebp, %r12d
jb 0x12326
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)
jmp 0x12326
movl 0x48(%rsp), %edx
movq 0x28(%rsp), %rcx
jmp 0x12257
movq 0xb0(%rsp), %rax
andl $0x0, (%rax)
movq 0x38(%rsp), %rax
andl $0x0, (%rax)
jmp 0x1247e
movl 0x8(%rsp), %ecx
movl %ecx, 0x4(%rsp)
movl 0x14(%rsp), %esi
movl %esi, (%rsp)
movq 0x38(%rsp), %rdx
cmpl (%rdx), %ecx
jg 0x12446
movq 0xb0(%rsp), %rax
cmpl (%rax), %esi
jle 0x12470
leaq 0x4(%rsp), %rbx
movq %rsp, %r14
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
movq 0x20(%rsp), %rcx
movq %r14, %r8
movq 0xb0(%rsp), %r9
callq 0xd354
movl (%rbx), %ecx
movl (%r14), %esi
movq 0x68(%rsp), %rax
movl %ecx, (%rax)
movq 0x70(%rsp), %rax
movl %esi, (%rax)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq