// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xe0, %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)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x14bd2(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x14bbb(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x14ba0(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x14b85(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0xa8(%rbp)
movl $0x0, -0xa4(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jl 0x29109
movq -0x48(%rbp), %rax
movl %eax, -0x9c(%rbp)
movq -0x50(%rbp), %rax
movl %eax, -0xa0(%rbp)
movq -0x58(%rbp), %rax
shlq $0xa, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
shlq $0xa, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0x290ec
movq -0x70(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x290f7
movq -0x78(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x29184
movq -0x50(%rbp), %rax
movl %eax, -0x9c(%rbp)
movq -0x48(%rbp), %rax
movl %eax, -0xa0(%rbp)
movq -0x60(%rbp), %rax
shlq $0xa, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
shlq $0xa, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x88(%rbp), %rax
jle 0x29164
movq -0x80(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x29172
movq -0x88(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0x291c7
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
jle 0x291ae
movq -0x90(%rbp), %rax
movq %rax, -0xe0(%rbp)
jmp 0x291bc
movq -0x98(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jl 0x29227
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x291fb
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa4(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x78(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x29225
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa8(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x29227
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jg 0x2928a
movq -0x80(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x2925b
movq -0x40(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa4(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x29288
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa8(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2928a
movl -0xa4(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0xa8(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl 0x12ddc(%rip), %eax     # 0x3c084
addl $0x2, %eax
movl %eax, 0x12dd3(%rip)     # 0x3c084
cmpl $0x7530, %eax           # imm = 0x7530
jle 0x29307
movl $0x2, 0x12dc2(%rip)     # 0x3c084
movl $0x0, -0xc4(%rbp)
cmpl $0x1198, -0xc4(%rbp)    # imm = 0x1198
jge 0x29305
movslq -0xc4(%rbp), %rcx
leaq 0x23134a(%rip), %rax    # 0x25a630
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x0, 0x30(%rax)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x292cc
jmp 0x29307
movl 0x12d77(%rip), %ecx     # 0x3c084
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movl 0x12d66(%rip), %ecx     # 0x3c084
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpl 0x2312e1(%rip), %eax    # 0x25a620
jge 0x296f8
movslq -0xac(%rbp), %rcx
leaq 0x148ad(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x9c(%rbp), %eax
jle 0x293ef
movslq -0xac(%rbp), %rcx
leaq 0x14690(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x1486c(%rip), %rax     # 0x3dc00
cmpl $0x4, (%rax,%rcx,4)
jne 0x293c8
movq -0xb8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2b710
cmpl $0x0, %eax
je 0x293c8
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2974f
movq -0xb8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x29382
jmp 0x296e2
movslq -0xac(%rbp), %rcx
leaq 0x14803(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x9c(%rbp), %eax
jne 0x296e0
movslq -0xac(%rbp), %rcx
leaq 0x145e6(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x147c2(%rip), %rax     # 0x3dc00
cmpl $0x4, (%rax,%rcx,4)
jne 0x296b8
movq -0xb8(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x12c2c(%rip), %eax     # 0x3c084
je 0x296b8
movq -0xb8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xb0(%rbp)
movslq -0xb0(%rbp), %rcx
leaq 0x14768(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0xa0(%rbp), %rcx
cmpq %rcx, %rax
jle 0x294d7
movq -0x38(%rbp), %rdi
callq 0x2b710
cmpl $0x0, %eax
je 0x294d7
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2974f
movq -0x50(%rbp), %rax
movslq -0xa0(%rbp), %rcx
cmpq %rcx, %rax
jne 0x296b4
movl -0x9c(%rbp), %eax
cmpl -0xa0(%rbp), %eax
jg 0x2950b
movl -0xac(%rbp), %eax
cmpl -0xb0(%rbp), %eax
jge 0x296b4
movq -0x38(%rbp), %rdi
callq 0x2b710
cmpl $0x0, %eax
je 0x296b4
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x146d0(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x146b5(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
shlq $0xa, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
shlq $0xa, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jg 0x29587
movq -0x78(%rbp), %rax
cmpq -0x68(%rbp), %rax
jle 0x295a0
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2974f
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x295ca
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa4(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x78(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x295f4
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa8(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xa0(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jne 0x296b2
movq -0x60(%rbp), %rax
shlq $0xa, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
shlq $0xa, %rax
addq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x68(%rbp), %rax
jg 0x29640
movq -0x88(%rbp), %rax
cmpq -0x68(%rbp), %rax
jle 0x29659
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2974f
movq -0x80(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x29683
movq -0x40(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa4(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x88(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x296b0
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0xa8(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa8(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x296b2
jmp 0x296b4
jmp 0x296b6
jmp 0x296b8
movq -0xb8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x2942c
jmp 0x296e0
jmp 0x296e2
jmp 0x296e4
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x29333
movl -0xa4(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x29714
movl -0xa8(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x29737
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r9
leaq -0xa4(%rbp), %rsi
leaq -0xa8(%rbp), %r8
callq 0x12be0
movl -0xa4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0xa8(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)