// File: /workspace/github_cpp_makefile_star2_O3/spatialfruitsalad[P]volume2position/./remove_inside_holes_2.hpp
// Function: removeInsideHoles::Process(tomogram3d<unsigned char>&)
static void Process (tomogram3d <uint8_t> & matrix_in)
    {
        std::cout << "removing inside holes ... " << std::flush;

        tomogram3d<int> clustermap;

        std::vector <int> rename;

        int nx = matrix_in.get_sx();
        int ny = matrix_in.get_sy();
        int nz = matrix_in.get_sz();

        // initialise
        rename.clear ();

        clustermap.initialise (nx, ny, nz, -1);

        // this is basically hoshen kopelman for the black clusters
        for (int k = 0; k != nz; ++k)
        {
            for (int j = 0; j != ny; ++j)
                for (int i = 0; i != nx; ++i)
                {
                    if (voxset_in_2 (i,j,k,matrix_in))
                    {
                        int imin = std::max (i-1, 0);
                        int imax = std::min (i+1, int (nx-1));
                        int jmin = std::max (j-1, 0);
                        int jmax = std::min (j+1, int (ny-1));
                        int kmin = std::max (k-1, 0);
                        int kmax = std::min (k+1, int (nz-1));
                        int cluster_id = rename.size (); // possibly start a new cluster.


                        int pos[6][3] = {{imin,j,k},{imax,j,k},{i,jmin,k},{i,jmax,k},{i,j,kmin},{i,j,kmax}};
                        for (int a = 0; a < 6; ++a)
                        {
//                        std::cout << "a = " << a << std::endl;
                            int ii = pos[a][0];
                            int jj = pos[a][1];
                            int kk = pos[a][2];
//                        std::cout << "ii = " << ii << "  jj = " << jj << "  kk = " << kk << std::endl;
                            if (voxset_in_2 (ii,jj,kk,matrix_in) && clustermap.get(ii,jj,kk) != -1)
                            {
                                int oclid = lookup_in_2 (clustermap.get(ii,jj,kk),rename);
                                if (cluster_id == (int)rename.size ())
                                    cluster_id = oclid;
                                else if (cluster_id != oclid)
                                    cluster_id = merge_clusters_in_2 (oclid, cluster_id, rename);
                            }
                        }



                        // start a new cluster
                        if (cluster_id == (int)rename.size ())
                            rename.push_back (cluster_id);

                        clustermap.set(i,j,k,cluster_id);
                    }
                }
        }



        // resolve all indirections in the indirection map
        for (int i = 0; i != (int)rename.size (); ++i)
            rename[i] = lookup_in_2 (i, rename);
        int max_clustercount = 0;
        // resolve the indirections on the facing planes
        // in the cluster map (other data is not needed)
        rename.insert (rename.begin (), -1);
        for (int i = 0; i != nx; ++i)
            for (int j = 0; j != ny; ++j)
                for (int k = 0; k != nz; ++k)
                {
                    if(rename[clustermap.get(i,j,k)+1] > max_clustercount) max_clustercount = rename[clustermap.get(i,j,k)+1];
                    clustermap.set(i,j,k, rename[clustermap.get(i,j,k)+1]);
                }
        rename.erase (rename.begin ());

        std::vector<int> clustersizes (max_clustercount + 1);
        for (int k = 0; k != nz; ++k)
            for (int j = 0; j != ny; ++j)
                for (int i = 0; i != nx; ++i)
                {
                    if (clustermap.get(i,j,k) >= 0)
                    {
                        clustersizes.at(clustermap.get(i,j,k))++;
                    }
                }


        tomogram3d <uint8_t> matrix_out;
        matrix_out.initialise(nx,ny,nz,0);
        for (int k = 0; k != nz; ++k)
        for (int j = 0; j != ny; ++j)
        for (int i = 0; i != nx; ++i)
        {
            bool fill = false;
            if (clustermap.get(i,j,k) == -1) 
            {
                fill = true;
            }

            else if (clustermap.get(i,j,k) > 0 && clustersizes.at(clustermap.get(i,j,k)) < 100000) 
            {
                fill = true;
            }

            if(fill == true)
            {
                matrix_out.set(i,j,k,1);
            }
        }


        std::cout << " done" << std::endl;

        std::swap (matrix_in, matrix_out);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %rbx
movq 0x12dc9(%rip), %r14     # 0x1cfc8
leaq 0xd59d(%rip), %rsi      # 0x177a3
movl $0x1a, %edx
movq %r14, %rdi
callq 0x32f0
movq %r14, %rdi
callq 0x31e0
xorl %eax, %eax
leaq 0x130(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x38(%rsp)
movl %eax, %eax
movq %rcx, 0x30(%rsp)
movl %ecx, %ecx
movq %rbx, 0x58(%rsp)
movq 0x28(%rbx), %rbp
movq %rax, %rbx
movl %ebp, %eax
movslq %ebx, %rsi
movq %rcx, 0x40(%rsp)
movslq %ecx, %rdx
movq %rax, 0x48(%rsp)
movslq %eax, %rcx
movq %rsi, 0x110(%rsp)
movq %rdx, 0x108(%rsp)
movq %rcx, 0x100(%rsp)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0xe244
testl %ebp, %ebp
movq %rbp, 0x50(%rsp)
je 0xa5ce
movq 0x38(%rsp), %rax
decl %eax
movl %eax, 0x6c(%rsp)
movq 0x30(%rsp), %rax
decl %eax
movl %eax, 0x68(%rsp)
leal -0x1(%rbp), %eax
movl %eax, 0x64(%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, 0x128(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0xa5b6
movq 0x20(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x74(%rsp)
leaq 0x1(%rax), %rcx
movl 0x64(%rsp), %eax
cmpl %ecx, %eax
movq %rcx, 0x118(%rsp)
cmovll %eax, %ecx
movl %ecx, 0x70(%rsp)
movq $0x0, 0x28(%rsp)
cmpl $0x0, 0x38(%rsp)
je 0xa594
movq 0x28(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0x7c(%rsp)
leaq 0x1(%rax), %rcx
movl 0x68(%rsp), %eax
cmpl %ecx, %eax
movq %rcx, 0x120(%rsp)
cmovll %eax, %ecx
movl %ecx, 0x78(%rsp)
xorl %r15d, %r15d
movq 0x58(%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xe968
testb %al, %al
je 0xa373
incq %r15
movq %r15, %rbp
jmp 0xa57c
cmpl $0x2, %r15d
movl $0x1, %eax
cmovgel %r15d, %eax
decl %eax
leaq 0x1(%r15), %rbp
movl 0x6c(%rsp), %edx
cmpl %ebp, %edx
movl %ebp, %ecx
cmovll %edx, %ecx
movq 0x8(%rsp), %rdx
subq (%rsp), %rdx
shrq $0x2, %rdx
movl %edx, 0xd0(%rsp)
movl %eax, 0x80(%rsp)
movq 0x28(%rsp), %rdx
movl %edx, 0x84(%rsp)
movq 0x20(%rsp), %rax
movl %eax, 0x88(%rsp)
movl %ecx, 0x8c(%rsp)
movl %edx, 0x90(%rsp)
movl %eax, 0x94(%rsp)
movl %r15d, 0x98(%rsp)
movl 0x7c(%rsp), %ecx
movl %ecx, 0x9c(%rsp)
movl %eax, 0xa0(%rsp)
movl %r15d, 0xa4(%rsp)
movl 0x78(%rsp), %ecx
movl %ecx, 0xa8(%rsp)
movl %eax, 0xac(%rsp)
movl %r15d, 0xb0(%rsp)
movl %edx, 0xb4(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0xb8(%rsp)
movl %r15d, 0xbc(%rsp)
movl %edx, 0xc0(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0xc4(%rsp)
xorl %ebx, %ebx
leaq (%rbx,%rbx,2), %rax
movslq 0x80(%rsp,%rax,4), %r14
movslq 0x84(%rsp,%rax,4), %r13
movslq 0x88(%rsp,%rax,4), %r12
movq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xe968
testb %al, %al
je 0xa484
incq %rbx
cmpq $0x6, %rbx
jne 0xa443
jmp 0xa510
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xcef2
cmpl $-0x1, %eax
je 0xa476
leaq 0x130(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xcef2
movl %eax, %edi
movq %rsp, %rsi
callq 0xe3a8
movl 0xd0(%rsp), %ecx
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
subq %rdi, %rdx
sarq $0x2, %rdx
cmpl %edx, %ecx
jne 0xa4e3
movl %eax, 0xd0(%rsp)
jmp 0xa476
cmpl %eax, %ecx
je 0xa476
movl %ecx, %esi
movl %eax, %ecx
movl %esi, %eax
cmpl %esi, %ecx
jg 0xa4e7
movslq %esi, %rsi
cmpq %rsi, %rdx
jbe 0xa9f3
movl %ecx, %eax
negl %eax
movl %eax, (%rdi,%rsi,4)
movl %ecx, 0xd0(%rsp)
jmp 0xa476
movl 0xd0(%rsp), %eax
movq 0x8(%rsp), %rsi
movq %rsi, %rcx
subq (%rsp), %rcx
shrq $0x2, %rcx
cmpl %ecx, %eax
movq 0x128(%rsp), %rbx
jne 0xa557
cmpq 0x10(%rsp), %rsi
je 0xa547
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0xa557
movq %rsp, %rdi
leaq 0xd0(%rsp), %rdx
callq 0xeccc
movl 0xd0(%rsp), %r8d
leaq 0x130(%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xe3de
movq %rbp, %r15
cmpq %rbx, %rbp
movq 0x50(%rsp), %rbp
jne 0xa34d
movq 0x120(%rsp), %rcx
jmp 0xa59c
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq 0x40(%rsp), %rcx
jne 0xa310
movq 0x118(%rsp), %rcx
jmp 0xa5be
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpq 0x48(%rsp), %rcx
jne 0xa2cd
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xa611
xorl %r14d, %r14d
movq %rsp, %r15
movl %r14d, %edi
movq %r15, %rsi
callq 0xe3a8
movq (%rsp), %rsi
movl %eax, (%rsi,%r14,4)
incq %r14
movq 0x8(%rsp), %rax
subq %rsi, %rax
shrq $0x2, %rax
movl %eax, %eax
cmpq %rax, %r14
jne 0xa5e8
leaq 0x80(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movq %rsp, %rdi
callq 0xeda0
cmpl $0x0, 0x38(%rsp)
je 0xa6f2
movq %rbx, %rbp
xorl %r14d, %r14d
leaq 0x130(%rsp), %r15
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
je 0xa6d7
xorl %r12d, %r12d
cmpl $0x0, 0x50(%rsp)
je 0xa6c9
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xcef2
movq (%rsp), %rcx
cltq
cmpl %ebx, 0x4(%rcx,%rax,4)
jle 0xa692
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xcef2
movq (%rsp), %rcx
cltq
movl 0x4(%rcx,%rax,4), %ebx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xcef2
movq (%rsp), %rcx
cltq
movl 0x4(%rcx,%rax,4), %r8d
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xe3de
incq %r13
cmpq %r13, 0x48(%rsp)
jne 0xa65a
incq %r12
cmpq 0x40(%rsp), %r12
jne 0xa650
incq %r14
cmpq %rbp, %r14
jne 0xa642
incl %ebx
movslq %ebx, %r14
movq %rbp, %rbx
movq 0x50(%rsp), %rbp
jmp 0xa6f8
movl $0x1, %r14d
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0xa717
subq %rsi, %rdx
callq 0x33d0
movq 0x8(%rsp), %rdx
addq $-0x4, %rdx
movq %rdx, 0x8(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x80(%rsp), %rdx
movq %r14, %rsi
callq 0xe746
testl %ebp, %ebp
je 0xa7c7
xorl %r14d, %r14d
leaq 0x130(%rsp), %r15
cmpl $0x0, 0x30(%rsp)
je 0xa7bd
xorl %r12d, %r12d
cmpl $0x0, 0x38(%rsp)
je 0xa7b3
xorl %r13d, %r13d
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xcef2
testl %eax, %eax
js 0xa7ab
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xcef2
movslq %eax, %rsi
movq 0xe8(%rsp), %rax
movq 0xf0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xaa01
incl (%rax,%rsi,4)
incq %r13
cmpq %r13, %rbx
jne 0xa75f
incq %r12
cmpq 0x40(%rsp), %r12
jne 0xa755
incq %r14
cmpq 0x48(%rsp), %r14
jne 0xa74b
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x110(%rsp), %rsi
movq 0x108(%rsp), %rdx
movq 0x100(%rsp), %rcx
xorl %r8d, %r8d
callq 0x8e82
testl %ebp, %ebp
je 0xa8da
xorl %r14d, %r14d
leaq 0x130(%rsp), %r15
leaq 0x80(%rsp), %r12
cmpl $0x0, 0x30(%rsp)
je 0xa8cc
xorl %r13d, %r13d
cmpl $0x0, 0x38(%rsp)
je 0xa8be
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xcef2
cmpl $-0x1, %eax
je 0xa89b
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xcef2
testl %eax, %eax
jle 0xa8b2
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xcef2
movslq %eax, %rsi
movq 0xe8(%rsp), %rax
movq 0xf0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xaa0f
cmpl $0x1869f, (%rax,%rsi,4) # imm = 0x1869F
jg 0xa8b2
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x9356
incq %rbp
cmpq %rbp, %rbx
jne 0xa833
incq %r13
cmpq 0x40(%rsp), %r13
jne 0xa826
incq %r14
cmpq 0x48(%rsp), %r14
jne 0xa818
movq 0x126e7(%rip), %r14     # 0x1cfc8
leaq 0xcfd5(%rip), %rsi      # 0x178bd
movl $0x5, %edx
movq %r14, %rdi
callq 0x32f0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq 0x126b5(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x58(%rsp), %rsi
leaq 0x18(%rsi), %rax
movq (%rsi), %rdi
movq 0x10(%rax), %rcx
movq %rcx, 0xe0(%rsp)
movups (%rax), %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps 0x80(%rsp), %xmm0
movq 0x90(%rsp), %rcx
movq 0xa8(%rsp), %rdx
movq %rdx, 0x10(%rax)
movups 0x98(%rsp), %xmm1
movups %xmm1, (%rax)
movq %rdi, 0x80(%rsp)
movups 0x8(%rsi), %xmm1
movups %xmm0, (%rsi)
movq %rcx, 0x10(%rsi)
movups %xmm1, 0x88(%rsp)
movaps 0xd0(%rsp), %xmm0
movups %xmm0, 0x98(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xa8(%rsp)
testq %rdi, %rdi
je 0xa9af
callq 0x3280
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0xa9c1
callq 0x3280
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xa9cf
callq 0x3280
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0xa9e1
callq 0x3280
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcd5f(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xcd51(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xcd43(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
jmp 0xaa63
jmp 0xaa63
jmp 0xaa63
jmp 0xaa36
jmp 0xaa63
jmp 0xaa36
jmp 0xaa63
jmp 0xaa31
jmp 0xaa63
jmp 0xaa63
movq %rax, %rbx
jmp 0xaa4b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xaa4b
callq 0x3280
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0xaa66
callq 0x3280
jmp 0xaa66
jmp 0xaa63
jmp 0xaa63
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xaa74
callq 0x3280
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0xaa86
callq 0x3280
movq %rbx, %rdi
callq 0x3430