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

/* The P1-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 P1-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-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).
   P1-reductions have a priority (colour) based on the degrees of the
   end vertex and two side vertices.  It cannot be changed without
   changing find_extensions_quad too.

   version for general quadrangulations
   assumes no vertices of degree 2
*/

{
    EDGE *e,*ee,*elast;
    int maxdeg;
    int col,maxcol;
    int i,nor,nmir;

#define QORCOL(e) (((long)degree[e->prev->end]<<10)+(long)degree[e->next->end])
#define QMIRCOL(e) (((long)degree[e->next->end]<<10)+(long)degree[e->prev->end])

    RESETMARKS;
    nor = nmir = 0;

    maxdeg = degree[ref->end];
    maxcol = QORCOL(ref);
    col = QMIRCOL(ref);
    if (col < maxcol)
        good_or[nor++] = ref;
    else if (col == maxcol)
    {
	good_or[nor++] = ref;
	good_mir[nmir++] = ref;
    }
    else
    {
	maxcol = col;
	good_mir[nmir++] = ref;
    }
 
    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

    MARKLO(ref->invers);

    if (nor > *ngood_ref || nmir > *ngood_mir_ref)
        prune_oriented_lists(good_or,&nor,ngood_ref,
                             good_mir,&nmir,ngood_mir_ref);

    if (*ngood_ref == 0 && *ngood_mir_ref == 0) return;

    for (i = 0; i < nv; ++i)
        if (degree[i] > maxdeg)
        {
	    e = elast = firstedge[i];
            do
            {
		if (!ISMARKEDLO(e) && degree[e->end] == 3)
                {
		    ee = e->invers;
		    if (legal_P1_reduction_all(ee))
		    {
                        *ngood_ref = *ngood_mir_ref = 0;
                        return;
		    }
                }
	        e = e->next;
	    } while (e != elast);
        } 
        else if (degree[i] == maxdeg)
        {
            e = elast = firstedge[i];
            do
            {
		ee = e->invers;
                if (degree[e->end] == 3 && !ISMARKEDLO(e) 
                        && legal_P1_reduction_all(ee))
                {
                    col = QORCOL(e->invers);
                    if (col > maxcol)
                    {
                        *ngood_ref = *ngood_mir_ref = 0;
                        return;
                    }
                    else if (col == maxcol)
                        good_or[nor++] = e->invers;
    
                    col = QMIRCOL(e->invers);
                    if (col > maxcol)
                    {
                        *ngood_ref = *ngood_mir_ref = 0;
                        return;
                    }
                    else if (col == maxcol)
                        good_mir[nmir++] = e->invers;
                }
                e = e->next;
            } while (e != elast);
        }

    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 $0x70, %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)
movl 0x2c3ca(%rip), %eax     # 0x3c084
addl $0x2, %eax
movl %eax, 0x2c3c1(%rip)     # 0x3c084
cmpl $0x7530, %eax           # imm = 0x7530
jle 0xfd0a
movl $0x2, 0x2c3b0(%rip)     # 0x3c084
movl $0x0, -0x64(%rbp)
cmpl $0x1198, -0x64(%rbp)    # imm = 0x1198
jge 0xfd08
movslq -0x64(%rbp), %rcx
leaq 0x24a941(%rip), %rax    # 0x25a630
shlq $0x6, %rcx
addq %rcx, %rax
movl $0x0, 0x30(%rax)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xfcdb
jmp 0xfd0a
movl $0x0, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x2ded9(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2dec0(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x2dea5(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2de88(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x2de6d(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0xfdc1
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x5c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xfe21
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0xfdff
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x5c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x60(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x60(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xfe1f
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x60(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x60(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xfe21
movl -0x5c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl 0x2c24b(%rip), %ecx     # 0x3c084
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl %ecx, 0x30(%rax)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0xfe5a
movl -0x60(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0xfe77
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r9
leaq -0x5c(%rbp), %rsi
leaq -0x60(%rbp), %r8
callq 0x12be0
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xfe8e
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xfe8e
jmp 0x10145
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl 0x24a782(%rip), %eax    # 0x25a620
jge 0x10100
movslq -0x58(%rbp), %rcx
leaq 0x2dd51(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jle 0xff46
movslq -0x58(%rbp), %rcx
leaq 0x2db3a(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x2c1a5(%rip), %eax     # 0x3c084
je 0xff2b
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x2dd10(%rip), %rax     # 0x3dc00
cmpl $0x3, (%rax,%rcx,4)
jne 0xff2b
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x130f0
cmpl $0x0, %eax
je 0xff29
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x10145
jmp 0xff2b
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0xfed2
jmp 0x100f0
movslq -0x58(%rbp), %rcx
leaq 0x2dcaf(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
cmpl -0x4c(%rbp), %eax
jne 0x100ee
movslq -0x58(%rbp), %rcx
leaq 0x2da98(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x2dc71(%rip), %rax     # 0x3dc00
cmpl $0x3, (%rax,%rcx,4)
jne 0x100d2
movq -0x38(%rbp), %rax
movl 0x30(%rax), %eax
cmpl 0x2c0de(%rip), %eax     # 0x3c084
je 0x100d2
movq -0x40(%rbp), %rdi
callq 0x130f0
cmpl $0x0, %eax
je 0x100d2
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2dc2b(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x18(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x2dc0c(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x1001f
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x10145
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x10045
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x10(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x5c(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x10047
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2dba2(%rip), %rax     # 0x3dc00
movslq (%rax,%rcx,4), %rax
shlq $0xa, %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq 0x10(%rcx), %rcx
movslq 0x4(%rcx), %rdx
leaq 0x2db83(%rip), %rcx     # 0x3dc00
movslq (%rcx,%rdx,4), %rcx
addq %rcx, %rax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jle 0x100a8
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x10145
movl -0x50(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x100ce
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x28(%rbp), %rax
movl -0x60(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x60(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x100d0
jmp 0x100d2
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0xff74
jmp 0x100ee
jmp 0x100f0
jmp 0x100f2
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0xfe95
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0x10116
movl -0x60(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0x10133
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r9
leaq -0x5c(%rbp), %rsi
leaq -0x60(%rbp), %r8
callq 0x12be0
movl -0x5c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)