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

/* The S-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 S-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 S-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).

   Hopefully this routine is used rarely, so we are going for simple
   rather than fast.  If the S operation ever becomes a critical part
   of some generation, optimising this routine would be necesary.
*/
{
    EDGE *e,*ee;
    int nor,nmir,i,j;

    RESETMARKS;
    e = ref;

    nor = nmir = 0;
    good_or[nor++] = e;
    good_mir[nmir++] = e->invers;
    MARKLO(e); 

    ee = e->invers->prev->prev->prev;
    good_or[nor++] = ee;
    good_mir[nmir++] = ee->invers;
    MARKLO(ee);

    ee = ee->invers->prev->prev->prev;
    good_or[nor++] = ee;
    good_mir[nmir++] = ee->invers;
    MARKLO(ee);

    *ngood_ref = nor;
    *ngood_mir_ref = nmir;

    for (i = 0; i < nv; ++i)
    if (degree[i] >= 6)
    {
	for (e = firstedge[i], j = degree[i]; --j >= 0; e = e->next)
        {
	    if (ISMARKEDLO(e)) continue;
            if (degree[e->end] < 6 || degree[e->next->end] != 4 ||
		degree[e->next->next->end] != 4 || 
		degree[e->next->next->next->end] < 6) continue;
	    if (degree[e->next->invers->next->next->end] != 4) continue;

	    good_or[nor++] = e;
            good_mir[nmir++] = e->invers;
            MARKLO(e);
        
            ee = e->invers->prev->prev->prev;
            good_or[nor++] = ee;
            good_mir[nmir++] = ee->invers;
            MARKLO(ee);

            ee = ee->invers->prev->prev->prev;
            good_or[nor++] = ee;
            good_mir[nmir++] = ee->invers;
            MARKLO(ee);
        }
    }

    *ngood_or = nor;
    *ngood_mir = nmir;    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r9, -0x8(%rsp)
movq 0x38(%rsp), %r10
movl 0xb494(%rip), %r11d     # 0x2407c
leal 0x2(%r11), %eax
movl %eax, 0xb48a(%rip)      # 0x2407c
cmpl $0x752f, %r11d          # imm = 0x752F
jl 0x18c2f
movl $0x2, 0xb477(%rip)      # 0x2407c
movabsq $0x30, %r11
movl $0x2, %eax
leaq 0x2299f5(%rip), %rbx    # 0x242610
cmpq $0x46630, %r11          # imm = 0x46630
je 0x18c2f
andl $0x0, (%r11,%rbx)
addq $0x40, %r11
jmp 0x18c1b
movq %rdi, (%rsi)
movq 0x20(%rdi), %r11
movq %r11, (%r8)
movl %eax, 0x30(%rdi)
movq 0x10(%r11), %rdi
movq 0x10(%rdi), %rdi
movq 0x10(%rdi), %rdi
movq %rdi, 0x8(%rsi)
movq 0x20(%rdi), %r11
movq %r11, 0x8(%r8)
movl %eax, 0x30(%rdi)
movq 0x10(%r11), %rdi
movq 0x10(%rdi), %rdi
movq 0x10(%rdi), %rdi
movq %rdi, 0x10(%rsi)
movq 0x20(%rdi), %r11
movq %r11, 0x10(%r8)
movl %eax, 0x30(%rdi)
movl $0x3, %ebx
movl %ebx, (%rcx)
movl %ebx, (%r10)
movl 0x22997e(%rip), %ecx    # 0x242600
xorl %edi, %edi
testl %ecx, %ecx
cmovlel %edi, %ecx
leaq 0xcf50(%rip), %r10      # 0x25be0
leaq 0xcd49(%rip), %r9       # 0x259e0
movl %ebx, %ebp
cmpq %rcx, %rdi
je 0x18d96
movl (%r10,%rdi,4), %r14d
cmpl $0x6, %r14d
jl 0x18d8e
leaq (%r9,%rdi,8), %r15
testl %r14d, %r14d
jle 0x18d8e
movq (%r15), %r15
cmpl %eax, 0x30(%r15)
je 0x18d82
movslq 0x4(%r15), %r12
cmpl $0x6, (%r10,%r12,4)
jl 0x18d82
movq 0x18(%r15), %r12
movslq 0x4(%r12), %r13
cmpl $0x4, (%r10,%r13,4)
jne 0x18d82
movq 0x18(%r12), %r13
movslq 0x4(%r13), %r11
cmpl $0x4, (%r10,%r11,4)
jne 0x18d82
movq 0x18(%r13), %r11
movslq 0x4(%r11), %r11
cmpl $0x6, (%r10,%r11,4)
jl 0x18d82
movq 0x20(%r12), %r11
movq 0x18(%r11), %r11
movq 0x18(%r11), %r11
movslq 0x4(%r11), %r11
cmpl $0x4, (%r10,%r11,4)
jne 0x18d82
movslq %ebx, %r11
movq %r15, (%rsi,%r11,8)
movq 0x20(%r15), %rbx
movslq %ebp, %r12
movq %rbx, (%r8,%r12,8)
movl %eax, 0x30(%r15)
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq %rbx, 0x8(%rsi,%r11,8)
movq 0x20(%rbx), %r13
movq %r13, 0x8(%r8,%r12,8)
movl %eax, 0x30(%rbx)
movq 0x10(%r13), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %r13
leal 0x3(%r11), %ebx
movq %r13, 0x10(%rsi,%r11,8)
movq 0x20(%r13), %r11
leal 0x3(%r12), %ebp
movq %r11, 0x10(%r8,%r12,8)
movl %eax, 0x30(%r13)
addq $0x18, %r15
decl %r14d
jmp 0x18cb4
incq %rdi
jmp 0x18c99
movl %ebx, (%rdx)
movq -0x8(%rsp), %rax
movl %ebp, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq