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

/* The Q-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 Q-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 P-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 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).
*/
{
    int i,j,w,z1,z2;
    long thistype,besttype;
    EDGE *e,*e1,*ew,*ewlast;

    besttype = ((long)degree[ref->end]<<10)
               + degree[ref->next->end] + degree[ref->prev->end];
    good_or[0] = ref;
    *ngood_or = *ngood_ref = 1;

    e = ref->next;
    thistype = ((long)degree[e->end]<<10)
               + degree[e->next->end] + degree[e->prev->end];
    if (thistype >= besttype)
    {
        good_mir[0] = e;
	*ngood_mir = *ngood_mir_ref = 1;
    }
    else
	*ngood_mir = *ngood_mir_ref = 0;

    if (thistype > besttype)
    {
	*ngood_or = *ngood_ref = 0;
	besttype = thistype;
    }
 
    for (i = 0; i < nv; ++i)
    if (degree[i] == 4)
    {
        e = firstedge[i];
        e1 = e->next->next;
        for (j = 0; j < 4; ++j, e=e->next, e1=e1->next)
        {
            if (degree[e->prev->end] < 6 || degree[e1->end] < 6) continue;
            if (e == ref) continue;
            w = e1->invers->prev->prev->end;

	    z1 = e->end;
	    z2 = e->next->end;
            ew = ewlast = firstedge[w];
            do
            {
                if (ew->end == z1 || ew->end == z2) break;
                ew = ew->next;
            } while (ew != ewlast);
            if (ew->end == z1 || ew->end == z2) continue;

            thistype = ((long)degree[z1]<<10)
				+ degree[z2] + degree[e->prev->end];
            if (thistype > besttype)
            {
                *ngood_ref = *ngood_mir_ref = 0;
                return;
            }
	    else if (thistype == besttype)
                good_or[(*ngood_or)++] = e;

	    thistype = ((long)degree[z2]<<10) + degree[z1] + degree[e1->end];
            if (thistype > besttype)
            {   
                *ngood_ref = *ngood_mir_ref = 0;
                return;
            }
            else if (thistype == besttype)
                good_mir[(*ngood_mir)++] = e->next;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x20(%rsp)
movq %r8, -0x30(%rsp)
movq 0x38(%rsp), %r9
movslq 0x4(%rdi), %rax
leaq 0x9f3c(%rip), %r10      # 0x27bf0
movslq (%r10,%rax,4), %rax
shlq $0xa, %rax
movq 0x10(%rdi), %r11
movq 0x18(%rdi), %r8
movslq 0x4(%r8), %r8
movslq (%r10,%r8,4), %r8
addq %rax, %r8
movslq 0x4(%r11), %rax
movslq (%r10,%rax,4), %r11
addq %r8, %r11
movq %rsi, -0x10(%rsp)
movq %rdi, (%rsi)
movl $0x1, %eax
movl %eax, (%rcx)
movq %rdx, -0x28(%rsp)
movl %eax, (%rdx)
movq 0x18(%rdi), %r8
movslq 0x4(%r8), %rax
movslq (%r10,%rax,4), %rax
shlq $0xa, %rax
movq 0x10(%r8), %rdx
movq 0x18(%r8), %rsi
movslq 0x4(%rsi), %rsi
movslq (%r10,%rsi,4), %rsi
addq %rax, %rsi
movslq 0x4(%rdx), %rax
movslq (%r10,%rax,4), %rax
addq %rsi, %rax
xorl %edx, %edx
cmpq %r11, %rax
jl 0x1dd32
movq -0x30(%rsp), %rdx
movq %r8, (%rdx)
movl $0x1, %edx
movl %edx, (%r9)
movq -0x20(%rsp), %rsi
movl %edx, (%rsi)
cmpq %r11, %rax
jle 0x1dd4f
xorl %edx, %edx
movl %edx, (%rcx)
movq -0x28(%rsp), %rsi
movl %edx, (%rsi)
movq %rax, %r11
movq %rcx, -0x18(%rsp)
movslq 0x2268b5(%rip), %rax    # 0x244610
movq %rax, -0x8(%rsp)
testq %rax, %rax
jle 0x1dea6
xorl %r14d, %r14d
leaq 0x9c7d(%rip), %rdx      # 0x279f0
cmpl $0x4, (%r10,%r14,4)
jne 0x1de86
movq (%rdx,%r14,8), %r12
movq 0x18(%r12), %r13
xorl %ebp, %ebp
movq 0x18(%r13), %r13
movq 0x10(%r12), %rax
movslq 0x4(%rax), %rax
movslq (%r10,%rax,4), %rbx
cmpq $0x6, %rbx
jge 0x1ddb1
incl %ebp
movq 0x18(%r12), %r12
cmpl $0x4, %ebp
jne 0x1dd89
jmp 0x1de86
movslq 0x4(%r13), %rax
movl (%r10,%rax,4), %eax
cmpl $0x6, %eax
jl 0x1dda0
cmpq %rdi, %r12
je 0x1dda0
movq 0x20(%r13), %rcx
movq 0x10(%rcx), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rsi
movslq 0x4(%r12), %rcx
movq 0x18(%r12), %r8
movslq 0x4(%r8), %r8
movq (%rdx,%rsi,8), %r9
movq %r9, %r15
movl 0x4(%r15), %esi
cmpl %ecx, %esi
je 0x1de02
cmpl %r8d, %esi
je 0x1de02
movq 0x18(%r15), %r15
cmpq %r9, %r15
jne 0x1dde8
movl 0x4(%r15), %esi
cmpl %ecx, %esi
je 0x1dda0
cmpl %r8d, %esi
je 0x1dda0
movslq (%r10,%rcx,4), %rsi
movq %rsi, %r9
shlq $0xa, %r9
movslq (%r10,%r8,4), %r15
addq %r15, %rbx
addq %r9, %rbx
cmpq %r11, %rbx
jg 0x1de96
jne 0x1de4e
movq -0x28(%rsp), %r9
movslq (%r9), %rax
leal 0x1(%rax), %esi
movl %esi, (%r9)
movq -0x10(%rsp), %rsi
movq %r12, (%rsi,%rax,8)
movslq (%r10,%r8,4), %r15
movslq (%r10,%rcx,4), %rsi
movslq 0x4(%r13), %rax
movl (%r10,%rax,4), %eax
shlq $0xa, %r15
cltq
addq %rsi, %rax
addq %r15, %rax
cmpq %r11, %rax
jg 0x1de96
jne 0x1dda0
movq 0x18(%r12), %rax
movq -0x20(%rsp), %r8
movslq (%r8), %rcx
leal 0x1(%rcx), %esi
movl %esi, (%r8)
movq -0x30(%rsp), %rsi
movq %rax, (%rsi,%rcx,8)
jmp 0x1dda0
incq %r14
cmpq -0x8(%rsp), %r14
jne 0x1dd73
jmp 0x1dea6
xorl %eax, %eax
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
movq -0x18(%rsp), %rcx
movl %eax, (%rcx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq