// File: /workspace/github_c_makefile_star2_O1/mishun[P]plantri/plantri.c
// Function: find_extensions_bip
static void
find_extensions_bip(int nbtot, int nbop, EDGE *extP[], int *nextP,
    EDGE *extQ[], int *nextQ, EDGE *Pedges[], int nPedges)

/* nbtot and nbop are the usual group parameters.
   Place in extP{0..nextP-1] the reference edges of possible P_ops, and
   place in extQ{0..nextQ-1] the reference edges of possible Q_ops.
   In both cases, only inequivalent edges are listed.
*/
{
    int Ptot,Qtot;
    EDGE *e,*elast,*ev,*evlast,*ee;
    EDGE **nb,**nb0,**nblim,**nboplim;
    register int i,v,w;
    int weight[MAXN],minweight;
    int oldPwt,Pv1,Pv2;
   
    Ptot = Qtot = 0;
    for (i = 0; i < nv; ++i) weight[i] = 0;
    minweight = 0;
    RESETMARKS;
    for (i = 0; i < nPedges; ++i)
    if (i == nPedges-1 || is_bip_P(Pedges[i]))
    {
	e = Pedges[i];
	if (ISMARKEDLO(e)) continue;
	MARKLO(e);
	++weight[e->start];
	e = e->next->next->invers->next->next;
	++weight[e->start]; ++weight[e->end];
	while (degree[e->end] == 4) e = e->invers->next->next;
	MARKLO(e);
	++weight[e->start];
	e = e->prev->prev->invers->prev->prev;
	++weight[e->start]; ++weight[e->end];
	minweight += 2;
    }

    if (nv == maxnv-1)
    {
        if (nbtot == 1)  /* Case of trivial group */
        {
            for (i = 0; i < nv; ++i)
	    if (degree[i] != 4)
	    {
	        e = elast = firstedge[i];
	        do
	        {
		    v = e->prev->end;
                    w = e->next->next->end;
		    if (weight[v]+weight[w] >= minweight)
   		    { 
			ev = evlast = e->prev->invers;
                        for (ev = ev->next; ev != evlast; ev = ev->next)
                            if (ev->end == w) break;
                        if (ev == evlast) extQ[Qtot++] = e;
    		    }
		    e = e->next;
	        } while (e != elast);
	    }
        }
        else             /* Case of nontrivial group */
        {
            nb0 = (EDGE**)numbering[0];
            nblim = (EDGE**)numbering[nbtot];
	    nboplim = (EDGE**)numbering[nbop==0?nbtot:nbop];
            RESETMARKS;
            for (i = 0; i < ne; ++i, ++nb0)
            {
	        e = *nb0;
                if (!ISMARKEDLO(e) && degree[e->start] >= 6)
                {
		    v = e->prev->end;
                    w = e->next->next->end;
    
		    if (weight[v]+weight[w] >= minweight)
                    {
                        ev = evlast = e->prev->invers;
                        for (ev = ev->next; ev != evlast; ev = ev->next)
                            if (ev->end == w) break;
                        if (ev == evlast) extQ[Qtot++] = e;
		    }
    
		    nb = nb0 + MAXE;
                    for (; nb < nboplim; nb += MAXE) MARKLO(*nb);
                    for (; nb < nblim; nb += MAXE) MARKLO((*nb)->prev);
                }
            }
        }
    }
    else  /* nv <= maxnv-2 */
    {
        if (nPedges > 0)
	{
	    e = Pedges[nPedges-1];
	    oldPwt = degree[e->end];
	    Pv1 = e->start;
	    Pv2 = e->next->next->end;
	}
	else
	    oldPwt = 0;


        if (nbtot == 1)  /* Case of trivial group */
        {
            for (i = 0; i < nv; ++i)
	    if (degree[i] != 4)
	    {
	        e = elast = firstedge[i];
	        do
	        {
		    if (degree[i] >= oldPwt ||
		        e->next->end == Pv1 || e->next->end == Pv2 ||
			e->prev->end == Pv1 || e->prev->end == Pv2)
		    {
		        for (ee = e; degree[ee->end] == 4;
				         ee = ee->invers->next->next)
		        {}
		        if (degree[i] >= degree[ee->end])
		            extP[Ptot++] = e->invers;
		    }
    
		    v = e->prev->end;
                    w = e->next->next->end;
    
		    if (weight[v]+weight[w] >= minweight)
		    {
                        ev = evlast = e->prev->invers;
                        for (ev = ev->next; ev != evlast; ev = ev->next)
                            if (ev->end == w) break;
                        if (ev == evlast) extQ[Qtot++] = e;
		    }
    
		    e = e->next;
	        } while (e != elast);
	    }
        }
        else             /* Case of nontrivial group */
        {
            nb0 = (EDGE**)numbering[0];
            nblim = (EDGE**)numbering[nbtot];
            RESETMARKS;
	    for (i = 0; i < ne; ++i, ++nb0)
	    {
	        if (!ISMARKEDLO(*nb0) && degree[(*nb0)->start] >= 6)
	        {
		    e = *nb0;
                    if (degree[e->start] >= oldPwt ||
                                e->next->end == Pv1 || e->next->end == Pv2 ||
                                e->prev->end == Pv1 || e->prev->end == Pv2)
		    {
                        for (ee = e; degree[ee->end] == 4;
				        ee = ee->invers->next->next)
                        {}
                        if (degree[e->start] >= degree[ee->end])
                            extP[Ptot++] = e->invers;
		    }
    
		    for (nb = nb0; nb < nblim; nb += MAXE) MARKLO(*nb);
                }
	    }

	    nb0 = (EDGE**)numbering[0];
	    nboplim = (EDGE**)numbering[nbop==0?nbtot:nbop];
            RESETMARKS;
            for (i = 0; i < ne; ++i, ++nb0)
            {
	        e = *nb0;
                if (!ISMARKEDLO(e) && degree[e->start] >= 6)
                {
		    v = e->prev->end;
                    w = e->next->next->end;
    
		    if (weight[v]+weight[w] >= minweight)
		    {
                        ev = evlast = e->prev->invers;
                        for (ev = ev->next; ev != evlast; ev = ev->next)
                            if (ev->end == w) break;
                        if (ev == evlast) extQ[Qtot++] = e;
		    }
    
		    nb = nb0 + MAXE;
                    for (; nb < nboplim; nb += MAXE) MARKLO(*nb);
                    for (; nb < nblim; nb += MAXE) MARKLO((*nb)->prev);
                }
            }
        }
    }

    *nextP = Ptot;
    *nextQ = Qtot;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %r9, 0x38(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movl %esi, %r14d
movl %edi, %ebp
movslq 0x227b80(%rip), %rbx    # 0x244610
testq %rbx, %rbx
jle 0x1caa9
leaq (,%rbx,4), %rdx
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
callq 0x1030
movl 0x188(%rsp), %edx
movl 0x95de(%rip), %eax      # 0x26094
leal 0x2(%rax), %ecx
movl %ecx, 0x95d5(%rip)      # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0x1caef
movl $0x2, 0x95c4(%rip)      # 0x26094
movl $0x30, %eax
leaq 0x227b44(%rip), %rcx    # 0x244620
movl $0x0, (%rax,%rcx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0x1cadc
movl %r14d, 0x14(%rsp)
movl %ebp, 0x4(%rsp)
movq %rbx, 0x20(%rsp)
movq 0x180(%rsp), %r13
testl %edx, %edx
jle 0x1cbdf
leal -0x1(%rdx), %edi
movl 0x957e(%rip), %ebp      # 0x26094
movl %edx, %edx
xorl %r12d, %r12d
leaq 0xb0ce(%rip), %r15      # 0x27bf0
xorl %ebx, %ebx
movq %rdi, 0x8(%rsp)
cmpq %rdi, %r12
je 0x1cb51
movq (%r13,%r12,8), %rdi
movl %ebx, %r14d
movq %rdx, %rbx
callq 0x1d9ef
movq %rbx, %rdx
movl %r14d, %ebx
movq 0x8(%rsp), %rdi
testl %eax, %eax
je 0x1cbd1
movq (%r13,%r12,8), %rax
cmpl %ebp, 0x30(%rax)
je 0x1cbd1
movl %ebp, 0x30(%rax)
movslq (%rax), %rcx
incl 0x40(%rsp,%rcx,4)
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movslq (%rax), %rcx
incl 0x40(%rsp,%rcx,4)
movslq 0x4(%rax), %rcx
incl 0x40(%rsp,%rcx,4)
movslq 0x4(%rax), %rcx
cmpl $0x4, (%r15,%rcx,4)
jne 0x1cba1
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
jmp 0x1cb88
movl %ebp, 0x30(%rax)
movslq (%rax), %rcx
incl 0x40(%rsp,%rcx,4)
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movslq (%rax), %rcx
incl 0x40(%rsp,%rcx,4)
movslq 0x4(%rax), %rax
incl 0x40(%rsp,%rax,4)
addl $0x2, %ebx
incq %r12
cmpq %rdx, %r12
jne 0x1cb29
jmp 0x1cbe1
xorl %ebx, %ebx
movl 0x9689(%rip), %eax      # 0x26270
decl %eax
movq 0x20(%rsp), %r14
cmpl %eax, %r14d
jne 0x1cc8d
movl 0x4(%rsp), %edx
cmpl $0x1, %edx
jne 0x1ccc8
testl %r14d, %r14d
jle 0x1cf1c
xorl %ecx, %ecx
leaq 0xafda(%rip), %rdx      # 0x27bf0
leaq 0xadd3(%rip), %rsi      # 0x279f0
xorl %eax, %eax
cmpl $0x4, (%rdx,%rcx,4)
je 0x1cc80
movq (%rsi,%rcx,8), %rdi
movq %rdi, %r8
movq 0x10(%r8), %r10
movq 0x18(%r8), %r9
movslq 0x4(%r10), %r11
movq 0x18(%r9), %r9
movslq 0x4(%r9), %r9
movl 0x40(%rsp,%r9,4), %ebp
addl 0x40(%rsp,%r11,4), %ebp
cmpl %ebx, %ebp
jl 0x1cc77
movq 0x20(%r10), %r10
movq %r10, %r11
movq 0x18(%r11), %r11
cmpq %r10, %r11
je 0x1cc69
cmpl %r9d, 0x4(%r11)
jne 0x1cc55
cmpq %r10, %r11
jne 0x1cc77
movslq %eax, %r9
incl %eax
movq 0x18(%rsp), %r10
movq %r8, (%r10,%r9,8)
movq 0x18(%r8), %r8
cmpq %rdi, %r8
jne 0x1cc2c
incq %rcx
cmpq %r14, %rcx
jne 0x1cc1f
jmp 0x1cdfd
movl 0x188(%rsp), %eax
testl %eax, %eax
movl 0x4(%rsp), %r8d
jle 0x1ce04
movl %eax, %eax
movq -0x8(%r13,%rax,8), %rax
movslq 0x4(%rax), %rcx
leaq 0xaf3d(%rip), %rdx      # 0x27bf0
movl (%rdx,%rcx,4), %edx
movl (%rax), %esi
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %edi
jmp 0x1ce06
movl 0x14(%rsp), %esi
testl %esi, %esi
cmovel %edx, %esi
movl 0x93bd(%rip), %eax      # 0x26094
leal 0x2(%rax), %ecx
movl %ecx, 0x93b4(%rip)      # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0x1cd10
movl $0x2, 0x93a3(%rip)      # 0x26094
movl $0x30, %eax
leaq 0x227923(%rip), %rcx    # 0x244620
movl $0x0, (%rax,%rcx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0x1ccfd
movl 0x2278fe(%rip), %ecx    # 0x244614
testl %ecx, %ecx
jle 0x1cf1c
movslq %edx, %rax
movslq %esi, %rdi
imulq $0xba0, %rax, %rdx      # imm = 0xBA0
leaq 0xafbe(%rip), %rsi      # 0x27cf0
imulq $0xba0, %rdi, %rdi      # imm = 0xBA0
addq %rsi, %rdx
addq %rsi, %rdi
xorl %r8d, %r8d
movl 0x934b(%rip), %r9d      # 0x26094
leaq 0xaea0(%rip), %r10      # 0x27bf0
xorl %eax, %eax
movq (%rsi), %r11
cmpl %r9d, 0x30(%r11)
je 0x1cded
movslq (%r11), %r14
cmpl $0x6, (%r10,%r14,4)
jl 0x1cded
movq 0x10(%r11), %r15
movq 0x18(%r11), %r14
movslq 0x4(%r15), %r12
movq 0x18(%r14), %r14
movslq 0x4(%r14), %r14
movl 0x40(%rsp,%r14,4), %ebp
addl 0x40(%rsp,%r12,4), %ebp
cmpl %ebx, %ebp
jl 0x1cdba
movq 0x20(%r15), %r15
movq %r15, %r12
movq 0x18(%r12), %r12
cmpq %r15, %r12
je 0x1cdac
cmpl %r14d, 0x4(%r12)
jne 0x1cd96
cmpq %r15, %r12
jne 0x1cdba
movslq %eax, %r14
incl %eax
movq 0x18(%rsp), %r15
movq %r11, (%r15,%r14,8)
leaq 0xba0(%rsi), %r11
cmpq %rdi, %r11
jae 0x1cde8
movq (%r11), %r14
movl %r9d, 0x30(%r14)
addq $0xba0, %r11            # imm = 0xBA0
jmp 0x1cdc1
movq (%r11), %r14
movq 0x10(%r14), %r14
movl %r9d, 0x30(%r14)
addq $0xba0, %r11            # imm = 0xBA0
cmpq %rdx, %r11
jb 0x1cdd6
incl %r8d
addq $0x8, %rsi
cmpl %ecx, %r8d
jne 0x1cd52
xorl %ecx, %ecx
jmp 0x1d185
xorl %edx, %edx
cmpl $0x1, %r8d
jne 0x1cf23
testl %r14d, %r14d
jle 0x1cf1c
xorl %r8d, %r8d
leaq 0xadcd(%rip), %r9       # 0x27bf0
xorl %eax, %eax
xorl %ecx, %ecx
movl (%r9,%r8,4), %r11d
cmpl $0x4, %r11d
je 0x1cf09
leaq 0xabb4(%rip), %r10      # 0x279f0
movq (%r10,%r8,8), %r13
movq %r13, %rbp
cmpl %edx, %r11d
jge 0x1ce6c
movq 0x18(%rbp), %r14
movl 0x4(%r14), %r14d
cmpl %esi, %r14d
je 0x1ce6c
cmpl %edi, %r14d
je 0x1ce6c
movq 0x10(%rbp), %r14
movl 0x4(%r14), %r14d
cmpl %esi, %r14d
je 0x1ce6c
cmpl %edi, %r14d
jne 0x1ceae
movslq 0x4(%rbp), %r14
movl (%r9,%r14,4), %r14d
cmpl $0x4, %r14d
jne 0x1ce97
movq %rbp, %r15
movq 0x20(%r15), %r14
movq 0x18(%r14), %r14
movq 0x18(%r14), %r15
movslq 0x4(%r15), %r14
movl (%r9,%r14,4), %r14d
cmpl $0x4, %r14d
je 0x1ce7d
cmpl %r14d, %r11d
jl 0x1ceae
movq 0x20(%rbp), %r14
movslq %ecx, %r15
incl %ecx
movq 0x28(%rsp), %r10
movq %r14, (%r10,%r15,8)
movq 0x10(%rbp), %r15
movq 0x18(%rbp), %r14
movslq 0x4(%r15), %r12
movq 0x18(%r14), %r14
movslq 0x4(%r14), %r14
movl 0x40(%rsp,%r14,4), %r10d
addl 0x40(%rsp,%r12,4), %r10d
cmpl %ebx, %r10d
jl 0x1cefc
movq 0x20(%r15), %r15
movq %r15, %r12
movq 0x18(%r12), %r12
cmpq %r15, %r12
je 0x1ceee
cmpl %r14d, 0x4(%r12)
jne 0x1ced8
cmpq %r15, %r12
jne 0x1cefc
movslq %eax, %r10
incl %eax
movq 0x18(%rsp), %r14
movq %rbp, (%r14,%r10,8)
movq 0x18(%rbp), %rbp
cmpq %r13, %rbp
jne 0x1ce43
incq %r8
cmpq 0x20(%rsp), %r8
jne 0x1ce27
jmp 0x1d185
xorl %ecx, %ecx
jmp 0x1d183
movslq %r8d, %rax
imulq $0xba0, %rax, %r8       # imm = 0xBA0
leaq 0xadbc(%rip), %r9       # 0x27cf0
movl 0x915a(%rip), %eax      # 0x26094
leal 0x2(%rax), %ecx
movl %ecx, 0x9151(%rip)      # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0x1cf73
movl $0x2, 0x9140(%rip)      # 0x26094
movl $0x30, %eax
leaq 0x2276c0(%rip), %rcx    # 0x244620
movl $0x0, (%rax,%rcx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0x1cf60
addq %r9, %r8
movl 0x227697(%rip), %r13d   # 0x244614
leaq 0xac6c(%rip), %r11      # 0x27bf0
testl %r13d, %r13d
movl %r13d, 0x8(%rsp)
jle 0x1d05e
leaq 0xad57(%rip), %rax      # 0x27cf0
xorl %ebp, %ebp
movl 0x90f2(%rip), %r14d     # 0x26094
xorl %ecx, %ecx
movq (%rax), %r10
cmpl %r14d, 0x30(%r10)
je 0x1d04d
movslq (%r10), %r15
movl (%r11,%r15,4), %r12d
cmpl $0x6, %r12d
jl 0x1d04d
cmpl %edx, %r12d
jge 0x1cfeb
movq 0x18(%r10), %r15
movl 0x4(%r15), %r15d
cmpl %esi, %r15d
je 0x1cfeb
cmpl %edi, %r15d
je 0x1cfeb
movq 0x10(%r10), %r15
movl 0x4(%r15), %r15d
cmpl %esi, %r15d
je 0x1cfeb
cmpl %edi, %r15d
jne 0x1d032
movslq 0x4(%r10), %r15
movl (%r11,%r15,4), %r13d
cmpl $0x4, %r13d
jne 0x1d016
movq %r10, %r15
movq 0x20(%r15), %r15
movq 0x18(%r15), %r15
movq 0x18(%r15), %r15
movslq 0x4(%r15), %r13
movl (%r11,%r13,4), %r13d
cmpl $0x4, %r13d
je 0x1cffc
cmpl %r13d, %r12d
jl 0x1d02d
movq 0x20(%r10), %r10
movslq %ecx, %r15
incl %ecx
movq 0x28(%rsp), %r12
movq %r10, (%r12,%r15,8)
movl 0x8(%rsp), %r13d
cmpq %r8, %rax
jae 0x1d04d
movq %rax, %r10
movq (%r10), %r15
movl %r14d, 0x30(%r15)
addq $0xba0, %r10            # imm = 0xBA0
cmpq %r8, %r10
jb 0x1d03a
incl %ebp
addq $0x8, %rax
cmpl %r13d, %ebp
jne 0x1cfa4
jmp 0x1d060
xorl %ecx, %ecx
movl 0x14(%rsp), %eax
testl %eax, %eax
movl 0x4(%rsp), %esi
cmovnel %eax, %esi
movl 0x9021(%rip), %eax      # 0x26094
leal 0x2(%rax), %edx
movl %edx, 0x9018(%rip)      # 0x26094
cmpl $0x752f, %eax           # imm = 0x752F
jl 0x1d0ac
movl $0x2, 0x9007(%rip)      # 0x26094
movl $0x30, %eax
leaq 0x227587(%rip), %rdx    # 0x244620
movl $0x0, (%rax,%rdx)
addq $0x40, %rax
cmpq $0x46630, %rax          # imm = 0x46630
jne 0x1d099
testl %r13d, %r13d
jle 0x1d183
movslq %esi, %rax
imulq $0xba0, %rax, %rdx      # imm = 0xBA0
addq %r9, %rdx
xorl %esi, %esi
movl 0x8fca(%rip), %edi      # 0x26094
xorl %eax, %eax
movq (%r9), %r14
cmpl %edi, 0x30(%r14)
je 0x1d172
movslq (%r14), %r10
cmpl $0x6, (%r11,%r10,4)
jl 0x1d172
movq 0x10(%r14), %r12
movq 0x18(%r14), %r10
movslq 0x4(%r12), %r13
movq 0x18(%r10), %r10
movslq 0x4(%r10), %r15
movl 0x40(%rsp,%r15,4), %r10d
addl 0x40(%rsp,%r13,4), %r10d
cmpl %ebx, %r10d
jl 0x1d135
movq 0x20(%r12), %r12
movq %r12, %r13
movq 0x18(%r13), %r13
cmpq %r12, %r13
je 0x1d127
cmpl %r15d, 0x4(%r13)
jne 0x1d113
cmpq %r12, %r13
jne 0x1d135
movslq %eax, %r10
incl %eax
movq 0x18(%rsp), %r15
movq %r14, (%r15,%r10,8)
leaq 0xba0(%r9), %r14
cmpq %rdx, %r14
movl 0x8(%rsp), %r13d
jae 0x1d16d
movq (%r14), %r10
movl %edi, 0x30(%r10)
addq $0xba0, %r14            # imm = 0xBA0
cmpq %rdx, %r14
jb 0x1d146
jmp 0x1d16d
movq (%r14), %r10
movq 0x10(%r10), %r10
movl %edi, 0x30(%r10)
addq $0xba0, %r14            # imm = 0xBA0
cmpq %r8, %r14
jb 0x1d15b
incl %esi
addq $0x8, %r9
cmpl %r13d, %esi
jne 0x1d0cc
jmp 0x1d185
xorl %eax, %eax
movq 0x30(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq