// File: /workspace/github_c_makefile_star2_O2/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), %rbx
movslq 0x4(%rdi), %rax
leaq 0x9984(%rip), %r10      # 0x25be0
movslq (%r10,%rax,4), %rax
shlq $0xa, %rax
movq 0x10(%rdi), %r9
movq 0x18(%rdi), %r8
movslq 0x4(%r8), %r8
movslq (%r10,%r8,4), %r8
addq %rax, %r8
movslq 0x4(%r9), %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), %rdx
movslq 0x4(%rdx), %rsi
movslq (%r10,%rsi,4), %r9
shlq $0xa, %r9
movq 0x10(%rdx), %rsi
movq 0x18(%rdx), %r8
movslq 0x4(%r8), %r8
movslq (%r10,%r8,4), %r8
addq %r9, %r8
movslq 0x4(%rsi), %rsi
movslq (%r10,%rsi,4), %r9
addq %r8, %r9
xorl %esi, %esi
cmpq %r11, %r9
jl 0x1c2d7
movq -0x30(%rsp), %rsi
movq %rdx, (%rsi)
movl %eax, %esi
movl %esi, (%rbx)
movq -0x20(%rsp), %rax
movl %esi, (%rax)
cmpq %r11, %r9
jle 0x1c2f3
andl $0x0, (%rcx)
movq -0x28(%rsp), %rax
andl $0x0, (%rax)
movq %r9, %r11
movq %rcx, -0x18(%rsp)
movl 0x226302(%rip), %eax    # 0x242600
xorl %r14d, %r14d
testl %eax, %eax
cmovlel %r14d, %eax
movq %rax, -0x8(%rsp)
leaq 0x96cd(%rip), %r15      # 0x259e0
cmpq -0x8(%rsp), %r14
je 0x1c448
cmpl $0x4, (%r10,%r14,4)
jne 0x1c430
movq (%r15,%r14,8), %r12
movq 0x18(%r12), %r13
xorl %ebp, %ebp
cmpl $0x4, %ebp
je 0x1c430
movq 0x18(%r13), %r13
movq 0x10(%r12), %rax
movslq 0x4(%rax), %rax
movslq (%r10,%rax,4), %rbx
cmpq $0x6, %rbx
jge 0x1c35d
incl %ebp
movq 0x18(%r12), %r12
jmp 0x1c334
movslq 0x4(%r13), %rax
movl (%r10,%rax,4), %eax
cmpl $0x6, %eax
jl 0x1c354
cmpq %rdi, %r12
je 0x1c354
movq 0x20(%r13), %rcx
movq 0x10(%rcx), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
movslq 0x4(%r12), %rcx
movq 0x18(%r12), %rsi
movslq 0x4(%rsi), %r8
movq (%r15,%rdx,8), %rdx
movq %rdx, %r9
movl 0x4(%r9), %esi
cmpl %ecx, %esi
je 0x1c3ae
cmpl %r8d, %esi
je 0x1c3ae
movq 0x18(%r9), %r9
cmpq %rdx, %r9
jne 0x1c394
movl 0x4(%r9), %esi
cmpl %ecx, %esi
je 0x1c354
cmpl %r8d, %esi
je 0x1c354
movslq (%r10,%rcx,4), %rsi
movq %rsi, %rdx
shlq $0xa, %rdx
movslq (%r10,%r8,4), %r9
addq %r9, %rbx
addq %rdx, %rbx
cmpq %r11, %rbx
jg 0x1c438
jne 0x1c3f9
movq -0x28(%rsp), %rsi
movslq (%rsi), %rax
leal 0x1(%rax), %edx
movl %edx, (%rsi)
movq -0x10(%rsp), %rdx
movq %r12, (%rdx,%rax,8)
movslq (%r10,%r8,4), %r9
movslq (%r10,%rcx,4), %rsi
movslq 0x4(%r13), %rax
movl (%r10,%rax,4), %eax
shlq $0xa, %r9
cltq
addq %rsi, %rax
addq %r9, %rax
cmpq %r11, %rax
jg 0x1c438
jne 0x1c354
movq 0x18(%r12), %rax
movq -0x20(%rsp), %rsi
movslq (%rsi), %rcx
leal 0x1(%rcx), %edx
movl %edx, (%rsi)
movq -0x30(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
jmp 0x1c354
incq %r14
jmp 0x1c313
movq 0x38(%rsp), %rax
andl $0x0, (%rax)
movq -0x18(%rsp), %rax
andl $0x0, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq