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

/* The P0-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
*/

{
    EDGE *e;
    int col,col2,maxcol,maxcol2;
    int i,nor,nmir;
    int d1,d2,d3,d4;

#define VCOLPD(di,dj) (di<dj ? (dj<<10)+di : (di<<10)+dj)

    nor = nmir = 0;

    d1 = degree[ref->end];
    d2 = degree[ref->next->end];
    d3 = degree[ref->invers->next->end];
    d4 = degree[ref->invers->prev->end];

    maxcol = VCOLPD(d1,d2);
    maxcol2 = VCOLPD(d3,d4);

    if (d1 >= d2)
    {
        if (d3 >= d4) good_or[nor++] = ref;
        if (d4 >= d3) good_mir[nmir++] = ref;
    }
    if (d2 >= d1)
    {
        if (d4 >= d3) good_or[nor++] = ref->next;
        if (d3 >= d4) good_mir[nmir++] = ref->next;
    }
    
    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

    for (i = nv-1; --i >= 0; )
        if (degree[i] == 2)
        {
	    e = firstedge[i];
    	    d1 = degree[e->end];
    	    d2 = degree[e->next->end];
	    col = VCOLPD(d1,d2);
	    if (col > maxcol)
	    {
		*ngood_ref = *ngood_mir_ref = 0;
		return;
	    }
	    else if (col == maxcol)
	    {
    		d3 = degree[e->invers->next->end];
    		d4 = degree[e->invers->prev->end];
		col2 = VCOLPD(d3,d4);
    
		if (col2 > maxcol2)
		{
                    *ngood_ref = *ngood_mir_ref = 0;
                    return;
                }
                else if (col2 == maxcol2)
                {
    		    if (d1 >= d2)
    		    {
        	        if (d3 >= d4) good_or[nor++] = e;
        	        if (d4 >= d3) good_mir[nmir++] = e;
    		    }
    		    if (d2 >= d1)
    		    {
        	        if (d4 >= d3) good_or[nor++] = e->next;
        	        if (d3 >= d4) good_mir[nmir++] = e->next;
    		    }
		}
	    }
        }

    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 $0x80, %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 $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x8(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x2eb0c(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2eaf3(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2ead6(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2eab9(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xf163
movl -0x5c(%rbp), %eax
shll $0xa, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0xf16f
movl -0x58(%rbp), %eax
shll $0xa, %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xf18b
movl -0x64(%rbp), %eax
shll $0xa, %eax
addl -0x60(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0xf197
movl -0x60(%rbp), %eax
shll $0xa, %eax
addl -0x64(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0xf1eb
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0xf1c7
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x50(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
cmpl -0x60(%rbp), %eax
jl 0xf1e9
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x54(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xf1eb
movl -0x5c(%rbp), %eax
cmpl -0x58(%rbp), %eax
jl 0xf241
movl -0x64(%rbp), %eax
cmpl -0x60(%rbp), %eax
jl 0xf219
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x50(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0xf23f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x54(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xf241
movl -0x50(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl 0x24b3c7(%rip), %eax    # 0x25a620
subl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
cmpl $0x0, %eax
jl 0xf45e
movslq -0x4c(%rbp), %rcx
leaq 0x2e984(%rip), %rax     # 0x3dc00
cmpl $0x2, (%rax,%rcx,4)
jne 0xf459
movslq -0x4c(%rbp), %rcx
leaq 0x2e76f(%rip), %rax     # 0x3da00
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movslq 0x4(%rax), %rcx
leaq 0x2e958(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x58(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2e93f(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xf2dd
movl -0x5c(%rbp), %eax
shll $0xa, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x70(%rbp)
jmp 0xf2e9
movl -0x58(%rbp), %eax
shll $0xa, %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jle 0xf310
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xf4a3
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0xf455
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2e8cd(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movslq 0x4(%rax), %rcx
leaq 0x2e8b0(%rip), %rax     # 0x3dc00
movl (%rax,%rcx,4), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0xf36c
movl -0x64(%rbp), %eax
shll $0xa, %eax
addl -0x60(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0xf378
movl -0x60(%rbp), %eax
shll $0xa, %eax
addl -0x64(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jle 0xf39f
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xf4a3
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
jne 0xf451
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0xf3f9
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0xf3d5
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x50(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
cmpl -0x60(%rbp), %eax
jl 0xf3f7
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x54(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xf3f9
movl -0x5c(%rbp), %eax
cmpl -0x58(%rbp), %eax
jl 0xf44f
movl -0x64(%rbp), %eax
cmpl -0x60(%rbp), %eax
jl 0xf427
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x10(%rbp), %rax
movl -0x50(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x50(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
cmpl -0x64(%rbp), %eax
jl 0xf44d
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x54(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xf44f
jmp 0xf451
jmp 0xf453
jmp 0xf455
jmp 0xf457
jmp 0xf459
jmp 0xf25f
movl -0x50(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jg 0xf474
movl -0x54(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpl (%rcx), %eax
jle 0xf491
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r9
leaq -0x50(%rbp), %rsi
leaq -0x54(%rbp), %r8
callq 0x12be0
movl -0x50(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)