// File: /workspace/github_c_makefile_star2_O1/ComplexNetworks-DCC-FCUP[P]gtrieScanner/nauty/nautil.c
// Function: doref
void
doref(graph *g, int *lab, int *ptn, int level, int *numcells,
     int *qinvar, permutation *invar, set *active, int *code,
     void (*refproc)(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int),
     void (*invarproc)(graph*,int*,int*,int,int,int,permutation*,
                                                     int,boolean,int,int),
     int mininvarlev, int maxinvarlev, int invararg,
     boolean digraph, int m, int n)
{
	int j,h;
	permutation pw;
	int iw;
	int i,cell1,cell2,nc,tvpos,minlev,maxlev;
	long longcode;
	boolean same;

#if !MAXN 
	DYNALLOC1(permutation,workperm,workperm_sz,n,"doref"); 
#endif

	if ((tvpos = nextelement(active,M,-1)) < 0) tvpos = 0;

	(*refproc)(g,lab,ptn,level,numcells,invar,active,code,M,n);

	minlev = (mininvarlev < 0 ? -mininvarlev : mininvarlev);
	maxlev = (maxinvarlev < 0 ? -maxinvarlev : maxinvarlev);
	if (invarproc != NULL && *numcells < n
	                    && level >= minlev && level <= maxlev)
	{
	    (*invarproc)(g,lab,ptn,level,*numcells,tvpos,invar,invararg,
	                                                         digraph,M,n);
	    EMPTYSET(active,m);
	    for (i = n; --i >= 0;) workperm[i] = invar[lab[i]];
	    nc = *numcells;
	    for (cell1 = 0; cell1 < n; cell1 = cell2 + 1)
	    {
	        pw = workperm[cell1];
	        same = TRUE;
	        for (cell2 = cell1; ptn[cell2] > level; ++cell2)
	            if (workperm[cell2+1] != pw) same = FALSE;

	        if (same) continue;

	        j = (cell2 - cell1 + 1) / 3;
	        h = 1;
	        do
	            h = 3 * h + 1;
	        while (h < j);

	        do                      /* shell sort */
	        {
	            for (i = cell1 + h; i <= cell2; ++i)
	            {
	                iw = lab[i];
	                pw = workperm[i];
	                for (j = i; workperm[j-h] > pw; )
	                {
	                    workperm[j] = workperm[j-h];
	                    lab[j] = lab[j-h];
	                    if ((j -= h) < cell1 + h) break;
	                }
	                workperm[j] = pw;
	                lab[j] = iw;
	            }
	            h /= 3;
	        }
	        while (h > 0);

	        for (i = cell1 + 1; i <= cell2; ++i)
	            if (workperm[i] != workperm[i-1])
	            {
	                ptn[i-1] = level;
	                ++*numcells;
	                ADDELEMENT(active,i);
	            }
	    }

	    if (*numcells > nc)
	    {
	        *qinvar = 2;
	        longcode = *code;
	        (*refproc)(g,lab,ptn,level,numcells,invar,active,code,M,n);
	        longcode = MASH(longcode,*code);
	        *code = CLEANUP(longcode);
	    }
	    else
	        *qinvar = 1;
	}
	else
	    *qinvar = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %r14
movl %ecx, %ebp
movq %rdx, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
movl 0xd0(%rsp), %ebx
movslq %ebx, %r15
movq 0x1b5e7(%rip), %rax     # 0x29aa0
cmpq %r15, %rax
jae 0xe4f2
testq %rax, %rax
je 0xe4cf
movq 0x1b5de(%rip), %rdi     # 0x29aa8
callq 0x2260
movq %r15, 0x1b5ca(%rip)     # 0x29aa0
shlq $0x2, %r15
movq %r15, %rdi
callq 0x22a0
movq %rax, 0x1b5bf(%rip)     # 0x29aa8
testq %rax, %rax
je 0xe8a7
movl 0xc8(%rsp), %esi
movq 0x88(%rsp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xdcbc
xorl %r13d, %r13d
testl %eax, %eax
cmovgl %eax, %r13d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq 0x20(%rsp), %r15
movq %r15, %rdx
movl %ebp, %ecx
movq %r14, %r8
movq 0x80(%rsp), %r9
pushq %rbx
movl 0xd0(%rsp), %eax
pushq %rax
pushq 0xa0(%rsp)
pushq 0xa0(%rsp)
callq *0xb8(%rsp)
addq $0x20, %rsp
movq 0xa0(%rsp), %rax
testq %rax, %rax
je 0xe5f7
movq %rax, %r10
movl 0xb0(%rsp), %ecx
movl 0xa8(%rsp), %edx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
movl (%r14), %r8d
cmpl %ebx, %r8d
jge 0xe5f7
cmpl %ebp, %ecx
jg 0xe5f7
cmpl %ebp, %eax
jl 0xe5f7
movl 0xc0(%rsp), %eax
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
movl %r13d, %r9d
pushq %rbx
movl 0xd8(%rsp), %r11d
movq %r11, %r13
pushq %r11
pushq %rax
movl 0xd8(%rsp), %eax
pushq %rax
pushq 0xa8(%rsp)
callq *%r10
addq $0x30, %rsp
movslq %r13d, %rax
movq 0x88(%rsp), %r11
leaq (%r11,%rax,4), %rax
addq $-0x4, %rax
cmpq %r11, %rax
jb 0xe611
movl $0x0, (%rax)
addq $-0x4, %rax
jmp 0xe5e6
movq 0x8(%rsp), %rax
movl $0x0, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebx, %ebx
movq 0x80(%rsp), %rsi
jle 0xe63e
movq 0x1b484(%rip), %rax     # 0x29aa8
movl %ebx, %ecx
incq %rcx
movslq -0x8(%r12,%rcx,4), %rdx
movl (%rsi,%rdx,4), %edx
movl %edx, -0x8(%rax,%rcx,4)
decq %rcx
cmpq $0x1, %rcx
jg 0xe629
movl (%r14), %eax
movl %eax, 0x18(%rsp)
testl %ebx, %ebx
jle 0xe818
movq 0x1b454(%rip), %rcx     # 0x29aa8
leaq 0x4(%r15), %rax
movq %rax, 0x40(%rsp)
leaq 0x4(%rcx), %rax
movq %rax, 0x38(%rsp)
xorl %r13d, %r13d
xorl %esi, %esi
movq %r14, 0x28(%rsp)
movl %ebp, 0x1c(%rsp)
movslq %esi, %r9
cmpl %ebp, (%r15,%r9,4)
jle 0xe6c9
movq %rbx, %r14
movq %rsi, %rbx
movl (%rcx,%r9,4), %edx
movq 0x40(%rsp), %rax
leaq (%rax,%r9,4), %rsi
movq 0x38(%rsp), %rax
leaq (%rax,%r9,4), %r8
movl $0x1, %eax
xorl %r10d, %r10d
movq %r10, %rdi
cmpl %edx, (%r8,%r10,4)
cmovnel %r13d, %eax
incq %r10
cmpl %ebp, (%rsi,%rdi,4)
jg 0xe6a1
movq %rbx, %rsi
addl %esi, %r10d
testl %eax, %eax
sete %al
movq %r14, %rbx
movq 0x28(%rsp), %r14
jmp 0xe6ce
xorl %eax, %eax
movl %esi, %r10d
testb %al, %al
je 0xe809
movl %r10d, %eax
subl %esi, %eax
incl %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rax
addl %edx, %eax
movl $0x1, %r13d
leal 0x1(%r13,%r13,2), %r13d
cmpl %eax, %r13d
jl 0xe6f9
leal 0x1(%r10), %eax
movq %rsi, 0x30(%rsp)
leal (%rsi,%r13), %edx
movslq %r13d, %rsi
cmpl %r10d, %edx
jg 0xe772
leaq (%r9,%rsi), %r15
movq 0x30(%rsp), %rdi
movl %edi, %r8d
movl (%r12,%r15,4), %ebx
movl (%rcx,%r15,4), %r14d
movl %r8d, %edi
leal (%rdi,%r13), %r11d
movslq %edi, %rbp
movl (%rcx,%rbp,4), %edi
cmpl %r14d, %edi
jle 0xe75c
movslq %r11d, %r11
movl %edi, (%rcx,%r11,4)
movl (%r12,%rbp,4), %edi
movl %edi, (%r12,%r11,4)
movl %ebp, %edi
subl %r13d, %edi
cmpl %edx, %ebp
jge 0xe72f
addl %r13d, %edi
movl %edi, %r11d
movslq %r11d, %rdi
movl %r14d, (%rcx,%rdi,4)
movl %ebx, (%r12,%rdi,4)
incq %r15
incl %r8d
cmpl %r15d, %eax
jne 0xe724
imulq $0x55555556, %rsi, %rdx # imm = 0x55555556
movq %rdx, %rsi
shrq $0x3f, %rsi
shrq $0x20, %rdx
addl %esi, %edx
cmpl $0x2, %r13d
movl %edx, %r13d
movq 0x30(%rsp), %rsi
jg 0xe70c
cmpl %esi, %r10d
movq 0x28(%rsp), %r14
movl 0x1c(%rsp), %ebp
movl 0xd0(%rsp), %ebx
movq 0x20(%rsp), %r15
movq 0x88(%rsp), %r11
movl $0x0, %r13d
leaq 0x381b(%rip), %rdi      # 0x11fe0
jle 0xe809
movslq %r10d, %rax
incq %r9
negq %rax
movl (%rcx,%r9,4), %edx
cmpl -0x4(%rcx,%r9,4), %edx
je 0xe7f9
movl %ebp, -0x4(%r15,%r9,4)
incl (%r14)
movl %r9d, %edx
andl $0x1f, %edx
movl (%rdi,%rdx,4), %edx
movl %r9d, %esi
sarl $0x5, %esi
movslq %esi, %rsi
orl %edx, (%r11,%rsi,4)
leaq (%rax,%r9), %rdx
incq %rdx
incq %r9
cmpq $0x1, %rdx
jne 0xe7d0
incl %r10d
movl %r10d, %esi
cmpl %ebx, %r10d
jl 0xe674
movl 0x18(%rsp), %eax
cmpl %eax, (%r14)
jle 0xe897
movq 0x8(%rsp), %rax
movl $0x2, (%rax)
movq %rbx, %rax
movl $0x6b1d, %ebx           # imm = 0x6B1D
movq 0x90(%rsp), %r13
xorl (%r13), %ebx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movl %ebp, %ecx
movq %r14, %r8
movq 0x80(%rsp), %r9
pushq %rax
movl 0xd0(%rsp), %eax
pushq %rax
pushq %r13
pushq %r11
callq *0xb8(%rsp)
addq $0x20, %rsp
addl (%r13), %ebx
andl $0x7fff, %ebx           # imm = 0x7FFF
imulq $0x20005, %rbx, %rax    # imm = 0x20005
shrq $0x20, %rax
movl %eax, %ecx
shll $0xf, %ecx
subl %ecx, %eax
addl %ebx, %eax
movl %eax, (%r13)
jmp 0xe602
movq 0x8(%rsp), %rax
movl $0x1, (%rax)
jmp 0xe602
callq 0x260d