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

/* The five-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 five-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 five-reductions (mirror-image editions)
   that might be canonical, with the first *ngood_mir_ref of those being
   ref.
   *ngood_ref and *ngood_mir_ref might each be 0 or 1.  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).
*/
{
    EDGE *e;
    long deg1,deg2,deg3,bestdeg;
#define FIVETYPE(d1,d2,d3) (((d1)<<21)+((d2)<<11)+(d3))
    long besttype,type1,type2;
    int nor,nmir,i,j,v,w;
    EDGE *ez,*ezlast;

    e = ref;
    bestdeg = degree[e->end];
    deg2 = degree[e->prev->end];
    deg3 = degree[e->next->end];

    type1 = FIVETYPE(bestdeg,deg2,deg3);
    type2 = FIVETYPE(bestdeg,deg3,deg2);
    besttype = type1 > type2 ? type1 : type2;

    nor = nmir = 0;
    if (type1 == besttype) good_or[nor++] = e;
    if (type2 == besttype) good_mir[nmir++] = e;

    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

    for (i = 0; i < nv; ++i)
    if (degree[i] == 5)
    {
	for (e = firstedge[i], j = 0; j < 5; ++j, e = e->next)
        {
	    if (e == ref) continue;
            deg1 = degree[e->end];
	    if (deg1 < bestdeg) continue;
	    deg2 = degree[e->prev->end];
	    if (deg2 == 4) continue;
	    deg3 = degree[e->next->end];
	    if (deg3 == 4) continue;

	    v = e->next->next->end;
	    w = e->next->next->next->end;
	    ez = e->invers;
	    ezlast = ez->prev;
	    for (ez = ez->next->next; ez != ezlast; ez = ez->next)
	        if (ez->end == w || ez->end == v) break;
	    if (ez != ezlast) continue;

	    if (deg1 > bestdeg)
	    {
		*ngood_ref = *ngood_mir_ref = 0;
		return;
	    }

	    type1 = FIVETYPE(deg1,deg2,deg3);
    	    type2 = FIVETYPE(deg1,deg3,deg2);

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

    *ngood_or = nor;
    *ngood_mir = nmir;    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x10(%rsp)
movq %r8, -0x20(%rsp)
movq %rdx, -0x18(%rsp)
movq %rsi, -0x28(%rsp)
movslq 0x4(%rdi), %rdx
leaq 0xd451(%rip), %rax      # 0x25be0
movslq (%rax,%rdx,4), %r10
movq 0x10(%rdi), %rsi
movq 0x18(%rdi), %rdx
movslq 0x4(%rsi), %rsi
movslq (%rax,%rsi,4), %rsi
movslq 0x4(%rdx), %rdx
movslq (%rax,%rdx,4), %r8
movq %r10, %r11
shlq $0x15, %r11
leaq (%r11,%r8), %r9
addq %rsi, %r11
movq %rsi, %rdx
shlq $0xb, %rdx
addq %r9, %rdx
shlq $0xb, %r8
addq %r8, %r11
xorl %r8d, %r8d
movq %r11, %rbx
movl $0x0, %r9d
cmpq %r11, %rdx
cmovgq %rdx, %rbx
jl 0x187ed
movl $0x1, %r9d
movq -0x28(%rsp), %rsi
movq %rdi, (%rsi)
movq 0x38(%rsp), %rsi
cmpq %rdx, %r11
jl 0x18805
movq -0x20(%rsp), %rdx
movq %rdi, (%rdx)
movl $0x1, %r8d
movq %rcx, -0x30(%rsp)
movl %r9d, -0x38(%rsp)
movl %r9d, (%rcx)
movl %r8d, -0x34(%rsp)
movl %r8d, (%rsi)
movl 0x229de0(%rip), %ecx    # 0x242600
xorl %r12d, %r12d
testl %ecx, %ecx
cmovlel %r12d, %ecx
movq %rcx, -0x8(%rsp)
cmpq %rcx, %r12
je 0x18959
cmpl $0x5, (%rax,%r12,4)
jne 0x1893f
leaq 0xd197(%rip), %rcx      # 0x259e0
leaq (%rcx,%r12,8), %r14
xorl %r9d, %r9d
cmpl $0x5, %r9d
je 0x1893a
movq (%r14), %r14
cmpq %rdi, %r14
je 0x18893
movslq 0x4(%r14), %rcx
movslq (%rax,%rcx,4), %rdx
cmpl %r10d, %edx
jl 0x18893
movq 0x10(%r14), %rcx
movslq 0x4(%rcx), %rcx
movslq (%rax,%rcx,4), %r13
cmpq $0x4, %r13
je 0x18893
movq 0x18(%r14), %rsi
movslq 0x4(%rsi), %rcx
movslq (%rax,%rcx,4), %rcx
cmpq $0x4, %rcx
jne 0x1889c
incl %r9d
addq $0x18, %r14
jmp 0x18850
movq 0x18(%rsi), %rsi
movl 0x4(%rsi), %r8d
movq 0x18(%rsi), %rsi
movl 0x4(%rsi), %r11d
movq 0x20(%r14), %r15
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rbp
movq 0x18(%rbp), %rbp
cmpq %rsi, %rbp
je 0x188d1
movl 0x4(%rbp), %r15d
cmpl %r11d, %r15d
je 0x18893
cmpl %r8d, %r15d
jne 0x188b8
jmp 0x18893
cmpl %r10d, %edx
jg 0x18947
shlq $0x15, %rdx
movq %r13, %r8
shlq $0xb, %r8
addq %rdx, %r8
addq %rcx, %r8
cmpq %rbx, %r8
jg 0x18947
shlq $0xb, %rcx
addq %r13, %rdx
addq %rcx, %rdx
cmpq %rbx, %rdx
jg 0x18947
cmpq %rbx, %r8
jne 0x18916
movl -0x38(%rsp), %esi
movslq %esi, %rcx
incl %esi
movl %esi, -0x38(%rsp)
movq -0x28(%rsp), %rsi
movq %r14, (%rsi,%rcx,8)
cmpq %rbx, %rdx
jne 0x18893
movl -0x34(%rsp), %edx
movslq %edx, %rcx
incl %edx
movl %edx, -0x34(%rsp)
movq -0x20(%rsp), %rdx
movq %r14, (%rdx,%rcx,8)
jmp 0x18893
movq -0x8(%rsp), %rcx
incq %r12
jmp 0x1882e
movq 0x38(%rsp), %rax
andl $0x0, (%rax)
movq -0x30(%rsp), %rax
andl $0x0, (%rax)
jmp 0x1896f
movq -0x18(%rsp), %rax
movl -0x38(%rsp), %ecx
movl %ecx, (%rax)
movq -0x10(%rsp), %rax
movl -0x34(%rsp), %ecx
movl %ecx, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq