// File: /workspace/github_cpp_makefile_star2_O1/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 $0x158, %rsp            # imm = 0x158
movq %rdi, %rbx
movq 0x12c8d(%rip), %r14     # 0x1cfc8
leaq 0xd471(%rip), %rsi      # 0x177b3
movl $0x1a, %edx
movq %r14, %rdi
callq 0x3300
movq %r14, %rdi
callq 0x31e0
xorl %eax, %eax
movq %rax, 0x130(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x40(%rsp)
movl %eax, %ebp
movq %rcx, 0x30(%rsp)
movl %ecx, %eax
movq %rax, 0x48(%rsp)
movq 0x28(%rbx), %rax
movq %rax, 0x38(%rsp)
movl %eax, %eax
movq %rax, 0x50(%rsp)
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0xa3b0
movq %rax, 0x8(%rsp)
movslq %ebp, %rsi
movslq 0x48(%rsp), %rdx
movslq 0x50(%rsp), %rcx
leaq 0x120(%rsp), %rdi
movq %rsi, 0x118(%rsp)
movq %rdx, 0x110(%rsp)
movq %rcx, 0x108(%rsp)
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0xe35c
cmpl $0x0, 0x38(%rsp)
movq %rbp, 0x58(%rsp)
je 0xa6cc
movq 0x40(%rsp), %rax
decl %eax
movl %eax, 0xbc(%rsp)
movq 0x30(%rsp), %rax
decl %eax
movl %eax, 0xb8(%rsp)
movq 0x38(%rsp), %rax
decl %eax
movl %eax, 0xb4(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0xa6b4
movq 0x20(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0xc4(%rsp)
leal 0x1(%rax), %ecx
movl 0xb4(%rsp), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0xc0(%rsp)
movq $0x0, 0x28(%rsp)
cmpl $0x0, 0x40(%rsp)
je 0xa69c
movq 0x28(%rsp), %rax
cmpl $0x2, %eax
movl $0x1, %ecx
cmovgel %eax, %ecx
decl %ecx
movl %ecx, 0xcc(%rsp)
leal 0x1(%rax), %ecx
movl 0xb8(%rsp), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0xc8(%rsp)
xorl %r15d, %r15d
movq %rbx, %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xeaa4
testb %al, %al
jne 0xa690
cmpl $0x2, %r15d
movl $0x1, %eax
cmovgel %r15d, %eax
decl %eax
leal 0x1(%r15), %ecx
movl 0xbc(%rsp), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
movq 0x8(%rsp), %rdx
subq (%rsp), %rdx
shrq $0x2, %rdx
movl %edx, 0xd0(%rsp)
movl %eax, 0x60(%rsp)
movq 0x28(%rsp), %rdx
movl %edx, 0x64(%rsp)
movq 0x20(%rsp), %rax
movl %eax, 0x68(%rsp)
movl %ecx, 0x6c(%rsp)
movl %edx, 0x70(%rsp)
movl %eax, 0x74(%rsp)
movl %r15d, 0x78(%rsp)
movl 0xcc(%rsp), %ecx
movl %ecx, 0x7c(%rsp)
movl %eax, 0x80(%rsp)
movl %r15d, 0x84(%rsp)
movl 0xc8(%rsp), %ecx
movl %ecx, 0x88(%rsp)
movl %eax, 0x8c(%rsp)
movl %r15d, 0x90(%rsp)
movl %edx, 0x94(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, 0x98(%rsp)
movl %r15d, 0x9c(%rsp)
movl %edx, 0xa0(%rsp)
movl 0xc0(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl $0x8, %ebp
movslq 0x58(%rsp,%rbp), %r14
movslq 0x5c(%rsp,%rbp), %r13
movslq 0x60(%rsp,%rbp), %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xeaa4
testb %al, %al
jne 0xa61c
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xd03a
cmpl $-0x1, %eax
je 0xa61c
leaq 0x120(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xd03a
movl %eax, %edi
movq %rsp, %rsi
callq 0xe4bc
movl 0xd0(%rsp), %esi
movq 0x8(%rsp), %rcx
subq (%rsp), %rcx
shrq $0x2, %rcx
cmpl %ecx, %esi
je 0xa615
cmpl %eax, %esi
je 0xa61c
movl %eax, %edi
movq %rsp, %rdx
callq 0xe4f0
movl %eax, 0xd0(%rsp)
addq $0xc, %rbp
cmpq $0x50, %rbp
jne 0xa590
movl 0xd0(%rsp), %eax
movq 0x8(%rsp), %rsi
movq %rsi, %rcx
subq (%rsp), %rcx
shrq $0x2, %rcx
cmpl %ecx, %eax
movq 0x58(%rsp), %rbp
jne 0xa66e
cmpq 0x10(%rsp), %rsi
je 0xa65e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0xa66e
movq %rsp, %rdi
leaq 0xd0(%rsp), %rdx
callq 0xedfa
movl 0xd0(%rsp), %r8d
leaq 0x120(%rsp), %rdi
movq %r15, %rsi
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xe52c
incq %r15
cmpq %rbp, %r15
jne 0xa4ab
movq 0x28(%rsp), %rcx
incq %rcx
movq %rcx, 0x28(%rsp)
cmpq 0x48(%rsp), %rcx
jne 0xa46e
movq 0x20(%rsp), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
cmpq 0x50(%rsp), %rcx
jne 0xa42b
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xa70f
xorl %r14d, %r14d
movq %rsp, %r15
movl %r14d, %edi
movq %r15, %rsi
callq 0xe4bc
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 0xa6e6
leaq 0x60(%rsp), %rdx
movl $0xffffffff, (%rdx)     # imm = 0xFFFFFFFF
movq %rsp, %rdi
callq 0xeece
cmpl $0x0, 0x40(%rsp)
je 0xa7e9
xorl %r14d, %r14d
leaq 0x120(%rsp), %r15
xorl %ebp, %ebp
cmpl $0x0, 0x30(%rsp)
je 0xa7cf
xorl %r12d, %r12d
cmpl $0x0, 0x38(%rsp)
je 0xa7c1
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xd03a
movq (%rsp), %rcx
cltq
cmpl %ebp, 0x4(%rcx,%rax,4)
jle 0xa78a
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xd03a
movq (%rsp), %rcx
cltq
movl 0x4(%rcx,%rax,4), %ebp
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xd03a
movq (%rsp), %rcx
cltq
movl 0x4(%rcx,%rax,4), %r8d
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xe52c
incq %r13
cmpq %r13, 0x50(%rsp)
jne 0xa752
incq %r12
cmpq 0x48(%rsp), %r12
jne 0xa748
incq %r14
cmpq 0x58(%rsp), %r14
jne 0xa73a
incl %ebp
movslq %ebp, %r14
movq 0x58(%rsp), %rbp
jmp 0xa7ef
movl $0x1, %r14d
movq (%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0x4(%rdi), %rsi
cmpq %rdx, %rsi
je 0xa809
subq %rsi, %rdx
callq 0x33e0
addq $-0x4, 0x8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r14, %rsi
callq 0xe886
cmpl $0x0, 0x38(%rsp)
je 0xa8b6
xorl %r14d, %r14d
leaq 0x120(%rsp), %r15
cmpl $0x0, 0x30(%rsp)
je 0xa8ac
xorl %r12d, %r12d
cmpl $0x0, 0x40(%rsp)
je 0xa8a2
xorl %r13d, %r13d
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xd03a
testl %eax, %eax
js 0xa89a
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0xd03a
movslq %eax, %rsi
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xaaf7
incl (%rax,%rsi,4)
incq %r13
cmpq %r13, %rbp
jne 0xa84e
incq %r12
cmpq 0x48(%rsp), %r12
jne 0xa844
incq %r14
cmpq 0x50(%rsp), %r14
jne 0xa83a
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x118(%rsp), %rsi
movq 0x110(%rsp), %rdx
movq 0x108(%rsp), %rcx
xorl %r8d, %r8d
callq 0x8fd8
cmpl $0x0, 0x38(%rsp)
je 0xa9c8
xorl %r14d, %r14d
leaq 0x120(%rsp), %r15
leaq 0x60(%rsp), %r12
cmpl $0x0, 0x30(%rsp)
je 0xa9ba
xorl %r13d, %r13d
cmpl $0x0, 0x40(%rsp)
je 0xa9ac
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xd03a
cmpl $-0x1, %eax
je 0xa987
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xd03a
testl %eax, %eax
jle 0xa99e
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xd03a
movslq %eax, %rsi
movq 0xf0(%rsp), %rax
movq 0xf8(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xab05
cmpl $0x1869f, (%rax,%rsi,4) # imm = 0x1869F
jg 0xa99e
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r14, %rcx
movl $0x1, %r8d
callq 0x949e
incq %rbp
cmpq %rbp, 0x58(%rsp)
jne 0xa91f
incq %r13
cmpq 0x48(%rsp), %r13
jne 0xa912
incq %r14
cmpq 0x50(%rsp), %r14
jne 0xa904
movq 0x125f9(%rip), %r14     # 0x1cfc8
leaq 0xcef7(%rip), %rsi      # 0x178cd
movl $0x5, %edx
movq %r14, %rdi
callq 0x3300
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq 0x125c7(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
leaq 0x18(%rbx), %rax
movq (%rbx), %rdi
movups 0x8(%rbx), %xmm0
xorl %ecx, %ecx
movq %rcx, 0x10(%rbx)
xorps %xmm1, %xmm1
movups %xmm1, (%rbx)
movq 0x10(%rax), %rdx
movq %rdx, 0xe0(%rsp)
movups (%rax), %xmm2
movaps %xmm2, 0xd0(%rsp)
movaps 0x60(%rsp), %xmm2
movq 0x70(%rsp), %rdx
movq %rcx, 0x60(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %r8
movups %xmm2, (%rbx)
movq %rdx, 0x10(%rbx)
movq %rsi, 0x68(%rsp)
movq %r8, 0x70(%rsp)
movq %rcx, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
movq 0x88(%rsp), %rcx
movq %rcx, 0x10(%rax)
movups 0x78(%rsp), %xmm1
movups %xmm1, (%rax)
movq %rdi, 0x60(%rsp)
movups %xmm0, 0x68(%rsp)
movaps 0xd0(%rsp), %xmm0
movups %xmm0, 0x78(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x88(%rsp)
testq %rdi, %rdi
je 0xaab3
callq 0x3290
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xaac5
callq 0x3290
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xaad3
callq 0x3290
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0xaae5
callq 0x3290
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcc6b(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xcc5d(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
jmp 0xab54
jmp 0xab54
jmp 0xab54
jmp 0xab2a
jmp 0xab54
jmp 0xab2a
jmp 0xab54
jmp 0xab25
jmp 0xab54
movq %rax, %rbx
jmp 0xab3c
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0xab3c
callq 0x3290
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0xab57
callq 0x3290
jmp 0xab57
jmp 0xab54
jmp 0xab54
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xab65
callq 0x3290
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0xab77
callq 0x3290
movq %rbx, %rdi
callq 0x3440
nop