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

/* The four-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 four-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).
   Four-reductions have a priority: (maxdeg, mindeg) where those are
   the two degrees on the subdivided diagonal.  Bigger = better.
*/
{
    EDGE *e,*er;
    long deg1,deg2,deg3,deg4;
#define FOURTYPE(d3,d4) (((d3)<<10)+(d4))
    long besttype,etype1,etype2,ertype1,ertype2,etype,ertype;
    int bestdeg,nextdeg,nor,nmir,i,w;
    EDGE *ei,*eilast;

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

    nor = nmir = 0;

    if (deg1 >= deg2)
    {
        bestdeg = deg1; nextdeg = deg2;
        etype1 = FOURTYPE(deg3,deg4);
        etype2 = FOURTYPE(deg4,deg3);
        besttype = etype = etype1 > etype2 ? etype1 : etype2;
    }

    if (deg1 <= deg2)
    {
        bestdeg = deg2; nextdeg = deg1;
        ertype1 = FOURTYPE(deg4,deg3);
        ertype2 = FOURTYPE(deg3,deg4);
	besttype = ertype = ertype1 > ertype2 ? ertype1 : ertype2;
    }

    if (deg1 == deg2) besttype = etype > ertype ? etype : ertype;

    if (deg1 >= deg2)
    {
	if (etype1 == besttype) good_or[nor++] = e;
	if (etype2 == besttype) good_mir[nmir++] = e;
    }
    if (deg1 <= deg2)
    {
        if (ertype1 == besttype) good_or[nor++] = er;
        if (ertype2 == besttype) good_mir[nmir++] = er;
    }

    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

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

    for (i = 0; i < nv; ++i)
    if (degree[i] > bestdeg)
    {
	ei = eilast = firstedge[i];
	do
	{
	    if (degree[ei->end] == 4 && is_min4_four(ei->invers))
	    {
		*ngood_ref = *ngood_mir_ref = 0;
		return;
	    }
	    ei = ei->next;
	} while (ei != eilast);
    }
    else if (degree[i] == bestdeg)
    {
        ei = eilast = firstedge[i];
        do
        {
            if (degree[ei->end] == 4 && !ISMARKEDLO(ei))
	    {
		e = ei->invers;
	  	er = e->next->next;
		w = er->end;
		deg2 = degree[w];
		if (deg2 > nextdeg && is_min4_four(e))
		{
                    *ngood_ref = *ngood_mir_ref = 0;
                    return;
                }
		else if (deg2 == nextdeg && (bestdeg > nextdeg || i < w)
					 && is_min4_four(e))
		{
		    deg3 = degree[e->prev->end];
		    deg4 = degree[e->next->end];
                    etype1 = FOURTYPE(deg3,deg4);
                    etype2 = FOURTYPE(deg4,deg3);

                    if (etype1 > besttype || etype2 > besttype)
                    {
                        *ngood_ref = *ngood_mir_ref = 0;
                        return;
                    }
                    if (etype1 == besttype) good_or[nor++] = e;
                    if (etype2 == besttype) good_mir[nmir++] = e;

		    if (nextdeg == bestdeg)
		    {
                	ertype1 = FOURTYPE(deg4,deg3);
                	ertype2 = FOURTYPE(deg3,deg4);

                	if (ertype1 > besttype || ertype2 > besttype)
                	{
                    	    *ngood_ref = *ngood_mir_ref = 0;
                    	    return;
                	}

                	if (ertype1 == besttype) good_or[nor++] = er;
                	if (ertype2 == besttype) good_mir[nmir++] = er;
		    }
		}
	    }
	    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, 0x70(%rsp)
movq %r8, 0x38(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x68(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %rdx
movq 0x18(%rdx), %rax
movslq 0x4(%rdi), %rsi
leaq 0xdb87(%rip), %r14      # 0x25be0
movl (%r14,%rsi,4), %ebx
movslq 0x4(%rax), %rsi
movl (%r14,%rsi,4), %ebp
movslq 0x4(%rcx), %rcx
movslq (%r14,%rcx,4), %rcx
movslq 0x4(%rdx), %rdx
movslq (%r14,%rdx,4), %r10
cmpl %ebp, %ebx
jl 0x18097
movq %rcx, %r8
shlq $0xa, %r8
addq %r10, %r8
movq %r10, %rdx
shlq $0xa, %rdx
addq %rcx, %rdx
cmpq %rdx, %r8
movq %rdx, %r9
cmovgq %r8, %r9
movq %r9, %r11
movl %ebx, 0x20(%rsp)
movl %ebp, 0x24(%rsp)
cmpl %ebp, %ebx
jg 0x180cc
movq %r10, %rsi
shlq $0xa, %rsi
addq %rcx, %rsi
shlq $0xa, %rcx
addq %r10, %rcx
cmpq %rcx, %rsi
movq %rcx, %r11
cmovgq %rsi, %r11
movq %r11, %r12
movl %ebp, 0x20(%rsp)
movl %ebx, 0x24(%rsp)
cmpq %r12, %r9
cmovgq %r9, %r12
movq $0x0, 0x8(%rsp)
movl $0x0, %r9d
movq %r9, 0x10(%rsp)
cmpl %ebp, %ebx
cmovneq %r11, %r12
jl 0x18136
movq $0x0, 0x8(%rsp)
movl $0x0, %r9d
movq %r9, 0x10(%rsp)
cmpq %r12, %r8
jne 0x18119
movq 0x30(%rsp), %r8
movq %rdi, (%r8)
pushq $0x1
popq %r8
movq %r8, 0x10(%rsp)
cmpq %r12, %rdx
jne 0x18136
pushq $0x1
popq %rdx
movq %rdx, 0x8(%rsp)
movl $0x1, 0x50(%rsp)
movq 0x38(%rsp), %rdx
movq %rdi, (%rdx)
cmpl %ebp, %ebx
jg 0x18178
cmpq %r12, %rsi
jne 0x1815c
movq 0x10(%rsp), %rsi
movl %esi, %edx
incl %esi
movl %esi, 0x54(%rsp)
movq 0x30(%rsp), %r8
movq %rax, (%r8,%rdx,8)
movl %esi, %edx
movq %rdx, 0x10(%rsp)
cmpq %r12, %rcx
jne 0x18178
movq 0x8(%rsp), %rdx
movl %edx, %ecx
incl %edx
movq %rdx, 0x8(%rsp)
movq 0x38(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
movq 0x28(%rsp), %rcx
movq 0x10(%rsp), %rdx
movl %edx, (%rcx)
movq 0x8(%rsp), %rcx
movq 0xc0(%rsp), %rdx
movl %ecx, (%rdx)
movl 0xbee3(%rip), %ecx      # 0x2407c
leal 0x2(%rcx), %r8d
movl %r8d, 0xbed8(%rip)      # 0x2407c
cmpl $0x752f, %ecx           # imm = 0x752F
jl 0x181d7
movl $0x2, 0xbec6(%rip)      # 0x2407c
pushq $0x30
popq %rcx
pushq $0x2
popq %r8
leaq 0x22a44c(%rip), %rdx    # 0x242610
cmpq $0x46630, %rcx          # imm = 0x46630
je 0x181d7
andl $0x0, (%rcx,%rdx)
addq $0x40, %rcx
jmp 0x181c4
movq 0x20(%rdi), %rcx
movl %r8d, 0x30(%rcx)
movq 0x20(%rax), %rax
movl %r8d, 0x30(%rax)
movl 0x22a413(%rip), %eax    # 0x242600
xorl %r13d, %r13d
testl %eax, %eax
cmovlel %r13d, %eax
movq %rax, 0x78(%rsp)
movl %ebx, 0x4c(%rsp)
movl %ebp, 0x48(%rsp)
movl %r8d, 0x1c(%rsp)
cmpq 0x78(%rsp), %r13
je 0x18445
movl 0x20(%rsp), %eax
cmpl %eax, (%r14,%r13,4)
jle 0x1825f
leaq 0xd7bc(%rip), %rax      # 0x259e0
movq (%rax,%r13,8), %rbx
movq %rbx, %r15
movslq 0x4(%r15), %rax
cmpl $0x4, (%r14,%rax,4)
jne 0x18247
movq 0x20(%r15), %rdi
callq 0x18e2c
testl %eax, %eax
jne 0x18420
movq 0x18(%r15), %r15
cmpq %rbx, %r15
jne 0x1822b
movq %r13, 0x58(%rsp)
movl 0x1c(%rsp), %r8d
jmp 0x18413
movq %r13, 0x58(%rsp)
jne 0x18413
leaq 0xd76f(%rip), %rax      # 0x259e0
movq (%rax,%r13,8), %r9
movq %r9, %r13
movq %r9, 0x40(%rsp)
movslq 0x4(%r13), %rax
cmpl $0x4, (%r14,%rax,4)
jne 0x183b0
cmpl %r8d, 0x30(%r13)
je 0x183b0
movq %r12, %rbx
movq 0x20(%r13), %rbp
movq 0x18(%rbp), %rax
movq %rax, 0x80(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x60(%rsp)
movslq 0x4(%rax), %r12
movq %r14, %r15
movl (%r14,%r12,4), %r14d
cmpl 0x24(%rsp), %r14d
jle 0x182d4
movq %rbp, %rdi
callq 0x18e2c
testl %eax, %eax
jne 0x18420
movl 0x24(%rsp), %edx
cmpl %edx, 0x20(%rsp)
setg %al
cmpq %r12, 0x58(%rsp)
setl %cl
cmpl %edx, %r14d
jne 0x183a0
orb %cl, %al
movq %r15, %r14
movq %rbx, %r12
je 0x183a6
movq %rbp, %rdi
callq 0x18e2c
testl %eax, %eax
movl 0x1c(%rsp), %r8d
je 0x183ab
movq 0x10(%rbp), %rax
movslq 0x4(%rax), %rax
movslq (%r14,%rax,4), %rdx
movq 0x80(%rsp), %rax
movslq 0x4(%rax), %rax
movslq (%r14,%rax,4), %rcx
movq %rdx, %rax
shlq $0xa, %rax
addq %rcx, %rax
cmpq %r12, %rax
jg 0x18420
shlq $0xa, %rcx
addq %rdx, %rcx
cmpq %r12, %rcx
jg 0x18420
cmpq %r12, %rax
jne 0x1836f
movq 0x10(%rsp), %rsi
movslq %esi, %rdx
incl %esi
movq %rsi, 0x10(%rsp)
movq 0x30(%rsp), %rsi
movq %rbp, (%rsi,%rdx,8)
movq 0x40(%rsp), %r9
cmpq %r12, %rcx
jne 0x183bf
movq 0x8(%rsp), %rdx
leal 0x1(%rdx), %ecx
movslq %edx, %rdx
movq 0x38(%rsp), %rsi
movq %rbp, (%rsi,%rdx,8)
movl 0x48(%rsp), %edx
cmpl %edx, 0x4c(%rsp)
je 0x183cb
movl %ecx, %eax
movq %rax, 0x8(%rsp)
jmp 0x183b0
movq %r15, %r14
movq %rbx, %r12
movl 0x1c(%rsp), %r8d
movq 0x40(%rsp), %r9
movq 0x18(%r13), %r13
cmpq %r9, %r13
jne 0x1827d
jmp 0x18413
movl 0x48(%rsp), %ecx
cmpl %ecx, 0x4c(%rsp)
je 0x183ef
jmp 0x183b0
movq 0x10(%rsp), %rsi
movslq %esi, %rdx
incl %esi
movq 0x30(%rsp), %rdi
movq 0x60(%rsp), %r10
movq %r10, (%rdi,%rdx,8)
movq %rcx, 0x8(%rsp)
movl %esi, %ecx
movq %rcx, 0x10(%rsp)
cmpq %r12, %rax
jne 0x183b0
movq 0x8(%rsp), %rcx
movslq %ecx, %rax
incl %ecx
movq %rcx, 0x8(%rsp)
movq 0x38(%rsp), %rcx
movq 0x60(%rsp), %rdx
movq %rdx, (%rcx,%rax,8)
jmp 0x183b0
movq 0x58(%rsp), %r13
incq %r13
jmp 0x18208
movq 0xc0(%rsp), %rax
andl $0x0, (%rax)
movq 0x28(%rsp), %rax
andl $0x0, (%rax)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdx
movl %edx, 0x54(%rsp)
movq 0x8(%rsp), %rcx
movl %ecx, 0x50(%rsp)
movq 0x28(%rsp), %rax
cmpl (%rax), %edx
jg 0x1846c
movq 0xc0(%rsp), %rax
cmpl (%rax), %ecx
jle 0x1849d
leaq 0x54(%rsp), %rbx
leaq 0x50(%rsp), %r14
movq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq 0x28(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq %r14, %r8
movq 0xc0(%rsp), %r9
callq 0xd354
movl (%rbx), %edx
movl (%r14), %ecx
movq 0x68(%rsp), %rax
movl %edx, (%rax)
movq 0x70(%rsp), %rax
movl %ecx, (%rax)
jmp 0x18433