// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %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 -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x13e25(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x13e0a(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x13def(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
shlq $0x15, %rax
movq -0x48(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
shlq $0x15, %rax
movq -0x50(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jle 0x29e66
movq -0x68(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0x29e71
movq -0x70(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x29eae
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x74(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x29ed2
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x78(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x74(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x78(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl 0x23072c(%rip), %eax    # 0x25a620
jge 0x2a178
movslq -0x7c(%rbp), %rcx
leaq 0x13cfb(%rip), %rax     # 0x3dc00
cmpl $0x5, (%rax,%rcx,4)
jne 0x2a168
movslq -0x7c(%rbp), %rcx
leaq 0x13ae6(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0x5, -0x80(%rbp)
jge 0x2a166
movq -0x38(%rbp), %rax
cmpq -0x8(%rbp), %rax
jne 0x29f42
jmp 0x2a14c
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x13caf(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x29f68
jmp 0x2a14c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x13c85(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x48(%rbp)
cmpq $0x4, -0x48(%rbp)
jne 0x29f8f
jmp 0x2a14c
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x13c5e(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
movq %rax, -0x50(%rbp)
cmpq $0x4, -0x50(%rbp)
jne 0x29fb6
jmp 0x2a14c
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
je 0x2a067
movq -0x90(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x88(%rbp), %eax
je 0x2a04f
movq -0x90(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x84(%rbp), %eax
jne 0x2a051
jmp 0x2a067
jmp 0x2a053
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x90(%rbp)
jmp 0x2a01b
movq -0x90(%rbp), %rax
cmpq -0x98(%rbp), %rax
je 0x2a07c
jmp 0x2a14c
movq -0x40(%rbp), %rax
cmpq -0x58(%rbp), %rax
jle 0x2a09f
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2a18a
movq -0x40(%rbp), %rax
shlq $0x15, %rax
movq -0x48(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
addq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x40(%rbp), %rax
shlq $0x15, %rax
movq -0x50(%rbp), %rcx
shlq $0xb, %rcx
addq %rcx, %rax
addq -0x48(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jg 0x2a0e9
movq -0x70(%rbp), %rax
cmpq -0x60(%rbp), %rax
jle 0x2a102
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x2a18a
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x2a126
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x74(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
cmpq -0x60(%rbp), %rax
jne 0x2a14a
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x78(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2a14c
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x29f29
jmp 0x2a168
jmp 0x2a16a
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x29eeb
movl -0x74(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x78(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
addq $0x20, %rsp
popq %rbp
retq