// File: /workspace/github_c_makefile_star2_O1/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 0xbdf6(%rip), %eax      # 0x26094
leal 0x2(%rax), %r11d
movl %r11d, 0xbdeb(%rip)     # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0x1a2da
movl $0x2, 0xbdda(%rip)      # 0x26094
movl $0x30, %eax
leaq 0x22a35a(%rip), %r11    # 0x244620
movl $0x0, (%rax,%r11)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0x1a2c6
movq %rdi, (%rsi)
movq 0x20(%rdi), %rax
movq %rax, (%r8)
movl 0xbdaa(%rip), %eax      # 0x26094
movl %eax, 0x30(%rdi)
movq 0x20(%rdi), %rdi
movq 0x10(%rdi), %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 0x20(%rdi), %rdi
movq 0x10(%rdi), %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, %ebp
movl %ebp, (%rcx)
movl %ebp, (%r10)
movslq 0x22a2d4(%rip), %rcx    # 0x244610
movl $0x3, %ebx
testq %rcx, %rcx
jle 0x1a45a
xorl %edi, %edi
leaq 0xd89d(%rip), %r10      # 0x27bf0
leaq 0xd696(%rip), %r9       # 0x279f0
movl (%r10,%rdi,4), %r14d
cmpl $0x6, %r14d
jl 0x1a44e
leaq (%r9,%rdi,8), %r15
incl %r14d
movq (%r15), %r15
cmpl %eax, 0x30(%r15)
je 0x1a43d
movslq 0x4(%r15), %r12
cmpl $0x6, (%r10,%r12,4)
jl 0x1a43d
movq 0x18(%r15), %r12
movslq 0x4(%r12), %r13
cmpl $0x4, (%r10,%r13,4)
jne 0x1a43d
movq 0x18(%r12), %r13
movslq 0x4(%r13), %r11
cmpl $0x4, (%r10,%r11,4)
jne 0x1a43d
movq 0x18(%r13), %r11
movslq 0x4(%r11), %r11
cmpl $0x6, (%r10,%r11,4)
jl 0x1a43d
movq 0x20(%r12), %r11
movq 0x18(%r11), %r11
movq 0x18(%r11), %r11
movslq 0x4(%r11), %r11
cmpl $0x4, (%r10,%r11,4)
jne 0x1a43d
movslq %ebp, %r11
movq %r15, (%rsi,%r11,8)
movq 0x20(%r15), %r12
movslq %ebx, %r13
movq %r12, (%r8,%r13,8)
movl %eax, 0x30(%r15)
movq 0x20(%r15), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq %rbx, 0x8(%rsi,%r11,8)
movq 0x20(%rbx), %r12
movq %r12, 0x8(%r8,%r13,8)
movl %eax, 0x30(%rbx)
movq 0x20(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %rbx
movq 0x10(%rbx), %r12
leal 0x3(%r11), %ebp
movq %r12, 0x10(%rsi,%r11,8)
movq 0x20(%r12), %r11
leal 0x3(%r13), %ebx
movq %r11, 0x10(%r8,%r13,8)
movl %eax, 0x30(%r12)
addq $0x18, %r15
decl %r14d
cmpl $0x1, %r14d
jg 0x1a36f
incq %rdi
cmpq %rcx, %rdi
jne 0x1a35a
movl %ebp, (%rdx)
movq -0x8(%rsp), %rax
movl %ebx, (%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq