// File: /workspace/github_cpp_makefile_star2_O3/spatialfruitsalad[P]volume2position/./watershed_segmentation.hpp
// Function: watershedSegmentation::Process(tomogram3d<unsigned char>&, tomogram3d<int>&, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
static void Process (tomogram3d<uint8_t>& binary,  tomogram3d<int>& out, float erosion_depth, std::string imagefoldername, int minimumCluster= 50000)
    {
        std::cout << "start segmentation ... " << std::endl;
        int nx = binary.get_sx();
        int ny = binary.get_sy();
        int nz = binary.get_sz();

        std::cout << "calculate edm" << std::endl;

        tomogram3d<float> edm;
        edm::create_edm(binary, edm);

        std::cout << "sqrt edm ..." << std::flush;
        for (int z = 0; z<nz; z++)
        for (int y = 0; y<ny; y++)
        for (int x = 0; x<nx; x++){
            float value = sqrt( edm.get(x,y,z) );
            edm.set(x,y,z,value);
        }
        std::cout << " done" << std::endl;

        // erodate binary image so particles don't overlap anymore. erosiondepth has to be chosen respectively
        tomogram3d<uint8_t> erodated_binary = binary;
        Erodate::erodate_binary_sphere(erodated_binary, edm, erosion_depth);
        WriteImages(erodated_binary, imagefoldername, "5_erosion", nz);
        
        // filter edm for smoother look
        gaussFilter::gauss_filter_mask_5(edm , 5, 0.8);
        
        WriteImages(edm, imagefoldername, "6_edm", nz);

        // identify individual clusters
        HoshenKopelman::Process(erodated_binary, out);
        erodated_binary.clear();
        // rename vector for HoshenKopelman
        std::vector <int> rename;

        rename.clear ();
        rename.push_back(0);

        // find max
        int ellipsoid_number = out.find_max();
        std::cout << "ellipsoid_number = " << ellipsoid_number << std::endl;
        for (int i = 1; i<= ellipsoid_number; i++)
            rename.push_back(i);

        // label previously eroded voxels
        int init = ellipsoid_number;
        for (int k = 0; k != nz; ++k)
            for (int j = 0; j != ny; ++j)
                for (int i = 0; i != nx; ++i)
                    if (binary.get(i,j,k) == 1 && out.get(i,j,k) == 0)
                    {
                        out.set (i, j, k, init);
                        rename.push_back(init);
                        init++;
                    }
    
        // check for slope in filtered edm
        for (int k = 0; k != nz; ++k)
        {
            for (int j = 0; j != ny; ++j)
            for (int i = 0; i != nx; ++i)
            {
                if (binary.get(i,j,k) == 1 && out.get(i,j,k) > ellipsoid_number)
                {
                    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));

                    float grad = 0.;
                    int label = out.get(i,j,k);
                    int grad_label = out.get(i,j,k);

                    for (int ii = imin; ii <= imax; ++ii)
                    for (int jj = jmin; jj <= jmax; ++jj)
                    for (int kk = kmin; kk <= kmax; ++kk)
                    {
                        float diff = edm.get(ii,jj,kk) - edm.get(i,j,k);
                        //sweis @Fabian: Why??? pow is so slow 
                        //float distance = sqrt(pow(float(ii-i),2)+pow(float(jj-j),2)+pow(float(kk-k),2));
                        float distance = sqrt( (ii-i)*(ii-i) + (jj-j)*(jj-j) + (kk-k)*(kk-k));
                        if (distance == 0) continue;
                        float slope = diff/distance;
                        if (slope > grad)
                        {
                            grad = slope;
                            grad_label = out.get(ii,jj,kk);
                        }
                    }
                    if (grad_label != label) 
                    {
                        rename.at(label) = - grad_label;
                    }
                    else
                    {
                        rename.at(label) = grad_label;
                    }
                }
            }
        }


        int clustercount = 1;
        for (size_t i = 0; i != rename.size (); ++i)
        {
            if (rename.at(i) > 0)
            {
                rename.at(i) = clustercount;
                clustercount++;
            }
        }

        std::cout << "start checking rename vektor" << std::endl;
        int not_added = 0;
        for (unsigned int i = 1; i != rename.size (); ++i)
        {
            if (rename.at(i) == 0)
            {
                not_added++;
            }
        }
        std::cout << "not_added = " << not_added << std::endl;


        std::cout << "ellipsoid_number = " << ellipsoid_number << std::endl;
        std::cout << "clustercount = " << clustercount << std::endl;


        // resolve all indirections in the rename map
        for (int i = 0; i != (int)rename.size (); ++i)
        {
            if (watershedSegmentation::lookup_2 (i,rename) > ellipsoid_number)
                rename.at(i) = 0;
            else
                rename.at(i) = watershedSegmentation::lookup_2 (i, rename);
        }

        for (int k = 0; k != nz; ++k)
        for (int j = 0; j != ny; ++j)
        for (int i = 0; i != nx; ++i)
        {
            int newvalue = rename.at(out.get(i,j,k));
            out.set(i,j,k, newvalue);
        }

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

        // count the number of voxels in each cluster
        std::vector<int> clustersize (ellipsoid_number + 1);
        for (int k = 0; k != nz; ++k)
        for (int j = 0; j != ny; ++j)
        for (int i = 0; i != nx; ++i)
            clustersize.at(out.get(i,j,k))++;

        // remove clusters smaller than a certain threshold
        for (int k = 0; k != nz; ++k)
        for (int j = 0; j != ny; ++j)
        for (int i = 0; i != nx; ++i)
        {
            if (clustersize.at(out.get(i,j,k)) < minimumCluster) out.set(i,j,k,0);
        }

        erodated_binary = binary;
        Dilate::Process(erodated_binary, 3);
        edm::create_edm(erodated_binary, edm);

        int added_later = 0;

        for (int k = 0; k != nz; ++k)
        for (int j = 0; j != ny; ++j)
        for (int i = 0; i != nx; ++i)
        {
            if (binary.get(i,j,k) == 1 && out.get(i,j,k) == 0)
            {
                out.set(i,j,k,find_label(nx, ny, nz, i, j, k, out, edm));
                added_later++;
            }
        }
        std::cout << "added_later = " << added_later << std::endl;
        edm.clear();
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movl %ecx, 0xc8(%rsp)
movq %rdx, 0x60(%rsp)
movss %xmm0, 0x78(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movq 0x12156(%rip), %rbx     # 0x1cfc8
leaq 0xc997(%rip), %rsi      # 0x17810
movl $0x17, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x18(%r14), %rax
movq %rax, 0x18(%rsp)
movq 0x20(%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%r14), %rax
movq %rax, 0x20(%rsp)
leaq 0xc959(%rip), %rsi      # 0x17828
movl $0xd, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq %r14, 0x70(%rsp)
movq %r14, %rdi
callq 0xeefa
movq 0x1209b(%rip), %rdi     # 0x1cfc8
leaq 0xc902(%rip), %rsi      # 0x17836
movl $0xc, %edx
callq 0x32f0
movq 0x12083(%rip), %rdi     # 0x1cfc8
callq 0x31e0
movl 0x18(%rsp), %eax
movq %rax, 0x38(%rsp)
movl 0x10(%rsp), %eax
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rcx
movl %ecx, %eax
movq %rax, 0x28(%rsp)
testl %ecx, %ecx
jle 0xb003
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x80(%rsp)
movq 0x30(%rsp), %r12
andq %rbp, %r12
andq 0x38(%rsp), %rbp
xorl %ebx, %ebx
leaq 0xe0(%rsp), %r14
cmpl $0x0, 0x10(%rsp)
jle 0xaff6
xorl %r15d, %r15d
cmpl $0x0, 0x18(%rsp)
jle 0xafee
xorl %r13d, %r13d
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xf342
ucomiss 0xc180(%rip), %xmm0     # 0x17148
jb 0xafd0
sqrtss %xmm0, %xmm0
jmp 0xafd5
callq 0x3460
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xf6ac
incq %r13
cmpq %r13, %rbp
jne 0xafb0
incq %r15
cmpq %r12, %r15
jne 0xafa6
incq %rbx
cmpq 0x80(%rsp), %rbx
jne 0xaf9c
movq 0x11fbe(%rip), %rbx     # 0x1cfc8
leaq 0xc8ac(%rip), %rsi      # 0x178bd
movl $0x5, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq 0x11f8c(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
leaq 0x168(%rsp), %rdi
movq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0x11fce
movq 0x8(%rsp), %r12
leaq 0x18(%rbx), %rcx
movq 0x10(%rcx), %rax
leaq 0x168(%rsp), %rdi
movq %rax, 0x28(%rdi)
movq %rcx, 0x120(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rdi)
leaq 0xe0(%rsp), %rsi
movss 0x78(%rsp), %xmm0
callq 0xfa16
movq 0x60(%rsp), %rbx
leaq 0x208(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x1f8(%rsp), %rdi
callq 0x12fde
leaq 0x1e8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xc76f(%rip), %rsi      # 0x17843
leaq 0xc771(%rip), %rdx      # 0x1784c
leaq 0x1d8(%rsp), %rdi
callq 0x13074
movslq 0x28(%rsp), %rcx
leaq 0x168(%rsp), %rdi
leaq 0x1f8(%rsp), %rsi
leaq 0x1d8(%rsp), %rdx
movq %rcx, 0xd8(%rsp)
xorl %r8d, %r8d
callq 0x96b9
movq 0x1d8(%rsp), %rdi
cmpq %r15, %rdi
je 0xb127
callq 0x3280
movq 0x1f8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb139
callq 0x3280
leaq 0xe0(%rsp), %rdi
movss 0xbffb(%rip), %xmm0     # 0x17144
movl $0x5, %esi
callq 0xfb64
leaq 0x1c8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x1b8(%rsp), %rdi
callq 0x12fde
leaq 0x1a8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xc6c4(%rip), %rsi      # 0x1784d
leaq 0xc6c2(%rip), %rdx      # 0x17852
leaq 0x198(%rsp), %rdi
callq 0x13074
leaq 0xe0(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
leaq 0x198(%rsp), %rdx
movq 0xd8(%rsp), %rcx
xorl %r8d, %r8d
callq 0x10364
movq 0x198(%rsp), %rdi
cmpq %r15, %rdi
je 0xb1d7
callq 0x3280
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb1e9
callq 0x3280
leaq 0x168(%rsp), %rdi
movq %r12, %rsi
callq 0x10e90
leaq 0x180(%rsp), %rcx
movq -0x18(%rcx), %rax
cmpq %rax, -0x10(%rcx)
je 0xb213
movq %rax, 0x170(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0x40(%rsp), %rdi
movq %rax, 0x10(%rdi)
movaps %xmm0, (%rdi)
leaq 0x98(%rsp), %rdx
movl $0x0, (%rdx)
xorl %esi, %esi
callq 0xee26
movq (%r12), %rax
movq 0x8(%r12), %rcx
cmpq %rcx, %rax
sete %sil
movq %rax, %rdx
addq $0x4, %rdx
cmpq %rcx, %rdx
sete %dil
orb %sil, %dil
jne 0xb279
movl (%rax), %esi
movl (%rdx), %edi
cmpl %edi, %esi
cmovlel %edi, %esi
cmovlq %rdx, %rax
addq $0x4, %rdx
cmpq %rcx, %rdx
jne 0xb265
movl (%rax), %eax
movl %eax, (%rsp)
movq 0x11d43(%rip), %rdi     # 0x1cfc8
leaq 0xc5c7(%rip), %rsi      # 0x17853
movl $0x13, %edx
callq 0x32f0
movq 0x11d2b(%rip), %rdi     # 0x1cfc8
movl (%rsp), %esi
callq 0x3420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movl $0x1, 0x98(%rsp)
cmpl $0x0, (%rsp)
jle 0xb32c
movl $0x1, %eax
leaq 0x40(%rsp), %rbx
leaq 0x98(%rsp), %r14
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0xb30b
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0xb316
movq %rbx, %rdi
movq %r14, %rdx
callq 0xeccc
movl 0x98(%rsp), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x98(%rsp)
cmpl (%rsp), %ecx
jl 0xb2f2
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x20(%rsp)
je 0xb7d3
xorl %ebx, %ebx
leaq 0x40(%rsp), %r14
leaq 0x4(%rsp), %r15
cmpl $0x0, 0x10(%rsp)
je 0xb3fa
xorl %r12d, %r12d
cmpl $0x0, 0x18(%rsp)
je 0xb3ec
xorl %r13d, %r13d
movq 0x70(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xe968
cmpb $0x1, %al
jne 0xb3de
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xcef2
testl %eax, %eax
jne 0xb3de
movl 0x4(%rsp), %r8d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xe3de
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0xb3c9
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0xb3d8
movq %r14, %rdi
movq %r15, %rdx
callq 0xeccc
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
incq %r13
cmpq %r13, 0x38(%rsp)
jne 0xb366
incq %r12
cmpq 0x30(%rsp), %r12
jne 0xb358
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0xb34a
cmpl $0x0, 0x20(%rsp)
movq 0x8(%rsp), %r12
je 0xb7d3
movq 0x18(%rsp), %rax
decl %eax
movl %eax, 0xbc(%rsp)
movq 0x10(%rsp), %rax
decl %eax
movl %eax, 0xb8(%rsp)
movq 0x20(%rsp), %rax
decl %eax
movl %eax, 0xb4(%rsp)
xorl %r15d, %r15d
cmpl $0x2, %r15d
movl $0x1, %eax
cmovgel %r15d, %eax
cmpl $0x0, 0x10(%rsp)
je 0xb7c2
movq %rax, 0x148(%rsp)
decl %eax
movl %eax, 0xd4(%rsp)
leaq 0x1(%r15), %rcx
movl 0xb4(%rsp), %eax
cmpl %ecx, %eax
movq %rcx, 0x118(%rsp)
cmovll %eax, %ecx
movl %ecx, 0xd0(%rsp)
movslq %ecx, %rax
movq %rax, 0x158(%rsp)
movl %r15d, %eax
notl %eax
movq %rax, 0x160(%rsp)
xorl %r8d, %r8d
movq %r15, 0x90(%rsp)
cmpl $0x2, %r8d
movl $0x1, %r13d
cmovgel %r8d, %r13d
cmpl $0x0, 0x18(%rsp)
je 0xb7a4
leaq -0x1(%r13), %rax
movq %rax, 0x130(%rsp)
decl %r13d
leaq 0x1(%r8), %rcx
movl 0xb8(%rsp), %eax
cmpl %ecx, %eax
movq %rcx, 0x128(%rsp)
cmovll %eax, %ecx
movl %ecx, 0xc4(%rsp)
movslq %ecx, %rax
movq %rax, 0x150(%rsp)
xorl %ebx, %ebx
movq %r13, 0x138(%rsp)
movq %r8, 0x60(%rsp)
cmpl $0x2, %ebx
movl $0x1, %ebp
cmovgel %ebx, %ebp
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
movq %r8, %r14
movq %r8, %rdx
movq %r15, %rcx
callq 0xe968
cmpb $0x1, %al
movq %r14, %r8
jne 0xb789
movq %r12, %rdi
movq %rbx, %rsi
movq %r8, %rdx
movq %r15, %rcx
callq 0xcef2
cmpl (%rsp), %eax
movq %r14, %r8
jle 0xb789
movq %r15, %r14
movq %rbx, %r15
incl %ebx
movl 0xbc(%rsp), %eax
cmpl %ebx, %eax
cmovll %eax, %ebx
movq %r12, %rdi
movq %r15, %rsi
movq %r8, %rdx
movq %r14, %rcx
callq 0xcef2
movl %eax, 0xc0(%rsp)
movq %r12, %rdi
movq %r15, 0x78(%rsp)
movq %r15, %rsi
movq 0x60(%rsp), %rdx
movq %r14, %rcx
callq 0xcef2
movl %eax, 0x88(%rsp)
leal -0x1(%rbp), %eax
cmpl %ebx, %eax
jg 0xb71e
decq %rbp
movl %ebx, %eax
movq %rax, 0x140(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x8c(%rsp)
movq %rbp, %rax
cmpl 0xc4(%rsp), %r13d
jle 0xb5de
movq %rax, %r14
jmp 0xb704
movq %rax, %r14
subl 0x78(%rsp), %eax
imull %eax, %eax
movl %eax, 0xcc(%rsp)
movq 0x130(%rsp), %r13
movl 0xd0(%rsp), %eax
cmpl %eax, 0xd4(%rsp)
jg 0xb6ef
movl %r13d, %ebx
subl 0x60(%rsp), %ebx
imull %ebx, %ebx
addl 0xcc(%rsp), %ebx
movq 0x148(%rsp), %r15
leaq -0x1(%r15), %r12
leaq 0xe0(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xf342
movss %xmm0, 0x80(%rsp)
movq %rbp, %rdi
movq 0x78(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x90(%rsp), %rcx
callq 0xf342
movq 0x160(%rsp), %rax
addl %r15d, %eax
imull %eax, %eax
addl %ebx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
sqrtsd %xmm1, %xmm1
cvtsd2ss %xmm1, %xmm1
ucomiss 0xbabe(%rip), %xmm1     # 0x17148
jne 0xb68e
jnp 0xb6de
movss 0x80(%rsp), %xmm2
subss %xmm0, %xmm2
divss %xmm1, %xmm2
movss %xmm2, 0x80(%rsp)
ucomiss 0x8c(%rsp), %xmm2
jbe 0xb6de
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0xcef2
movl %eax, 0x88(%rsp)
movss 0x80(%rsp), %xmm0
movss %xmm0, 0x8c(%rsp)
incq %r15
cmpq 0x158(%rsp), %r12
jl 0xb624
leaq 0x1(%r13), %rax
cmpq 0x150(%rsp), %r13
movq %rax, %r13
jl 0xb5f7
leaq 0x1(%r14), %rax
cmpq 0x140(%rsp), %r14
movq 0x138(%rsp), %r13
jl 0xb5cc
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movl 0xc0(%rsp), %ecx
movslq %ecx, %rsi
movl 0x88(%rsp), %edi
cmpl %ecx, %edi
movq 0x78(%rsp), %rbx
jne 0xb769
cmpq %rsi, %rdx
movq 0x8(%rsp), %r12
movq 0x90(%rsp), %r15
movq 0x60(%rsp), %r8
jbe 0xbe12
movl %esi, (%rax,%rsi,4)
jmp 0xb789
cmpq %rsi, %rdx
movq 0x8(%rsp), %r12
movq 0x90(%rsp), %r15
movq 0x60(%rsp), %r8
jbe 0xbe12
negl %edi
movl %edi, (%rax,%rsi,4)
incq %rbx
cmpq 0x38(%rsp), %rbx
jne 0xb511
movq 0x128(%rsp), %rax
movq %rax, %r8
jmp 0xb7aa
incq %r8
movq %r8, %rax
cmpq 0x30(%rsp), %rax
jne 0xb4b0
movq 0x118(%rsp), %rax
movq %rax, %r15
jmp 0xb7c8
incq %r15
movq %r15, %rax
cmpq 0x28(%rsp), %rax
jne 0xb445
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
je 0xb80b
sarq $0x2, %rdx
movl $0x1, %ebp
xorl %ecx, %ecx
cmpq %rcx, %rdx
je 0xbe20
cmpl $0x0, (%rax,%rcx,4)
jle 0xb801
movl %ebp, (%rax,%rcx,4)
incl %ebp
incq %rcx
cmpq %rcx, %rdx
jne 0xb7ed
jmp 0xb810
movl $0x1, %ebp
movq 0x117b1(%rip), %rbx     # 0x1cfc8
leaq 0xc049(%rip), %rsi      # 0x17867
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq 0x1177f(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
xorl %ebx, %ebx
cmpq $0x4, %rdx
je 0xb894
sarq $0x2, %rdx
xorl %ebx, %ebx
movl $0x1, %esi
movl $0x2, %ecx
cmpq %rsi, %rdx
jbe 0xbe42
cmpl $0x1, (%rax,%rsi,4)
adcl $0x0, %ebx
movl %ecx, %esi
incl %ecx
cmpq %rsi, %rdx
jne 0xb87b
movq 0x1172d(%rip), %rdi     # 0x1cfc8
leaq 0xbfe2(%rip), %rsi      # 0x17884
movl $0xc, %edx
callq 0x32f0
movq 0x11715(%rip), %rdi     # 0x1cfc8
movl %ebx, %esi
callq 0x3420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x116dd(%rip), %rdi     # 0x1cfc8
leaq 0xbf61(%rip), %rsi      # 0x17853
movl $0x13, %edx
callq 0x32f0
movq 0x116c5(%rip), %rdi     # 0x1cfc8
movl (%rsp), %esi
callq 0x3420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x1168c(%rip), %rdi     # 0x1cfc8
leaq 0xbf4e(%rip), %rsi      # 0x17891
movl $0xf, %edx
callq 0x32f0
movq 0x11674(%rip), %rdi     # 0x1cfc8
movl %ebp, %esi
callq 0x3420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xb9fd
xorl %ebx, %ebx
leaq 0x40(%rsp), %r14
movl %ebx, %edi
movq %r14, %rsi
callq 0x113b0
cmpl (%rsp), %eax
jle 0xb9c5
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rcx
subq %rsi, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
xorl %eax, %eax
jmp 0xb9e3
movl %ebx, %edi
movq %r14, %rsi
callq 0x113b0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rcx
subq %rsi, %rcx
movq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0xbe31
movl %eax, (%rsi,%rbx,4)
incq %rbx
shrq $0x2, %rcx
movl %ecx, %eax
cmpq %rax, %rbx
jne 0xb99e
cmpl $0x0, 0x20(%rsp)
je 0xba7b
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
je 0xba71
xorl %r14d, %r14d
cmpl $0x0, 0x18(%rsp)
je 0xba67
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xcef2
movslq %eax, %rsi
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbde8
movl (%rax,%rsi,4), %r8d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xe3de
incq %r15
cmpq %r15, 0x38(%rsp)
jne 0xba1a
incq %r14
cmpq 0x30(%rsp), %r14
jne 0xba10
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0xba06
movq 0x11546(%rip), %rbx     # 0x1cfc8
leaq 0xbe18(%rip), %rsi      # 0x178a1
movl $0x21, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq 0x11514(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movslq (%rsp), %rsi
incq %rsi
leaq 0x98(%rsp), %rdi
leaq 0x6f(%rsp), %rdx
callq 0xe746
cmpl $0x0, 0x20(%rsp)
je 0xbbe7
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
je 0xbb46
xorl %r14d, %r14d
cmpl $0x0, 0x18(%rsp)
je 0xbb3c
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xcef2
movslq %eax, %rsi
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbdf6
incl (%rax,%rsi,4)
incq %r15
cmpq %r15, 0x38(%rsp)
jne 0xbafb
incq %r14
cmpq 0x30(%rsp), %r14
jne 0xbaf1
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0xbae7
cmpl $0x0, 0x20(%rsp)
je 0xbbe7
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
je 0xbbd9
xorl %r14d, %r14d
cmpl $0x0, 0x18(%rsp)
je 0xbbcf
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xcef2
movslq %eax, %rsi
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbe04
movl 0xc8(%rsp), %ecx
cmpl %ecx, (%rax,%rsi,4)
jge 0xbbc5
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0xe3de
incq %r15
cmpq %r15, 0x38(%rsp)
jne 0xbb71
incq %r14
cmpq 0x30(%rsp), %r14
jne 0xbb67
incq %rbx
cmpq 0x28(%rsp), %rbx
jne 0xbb5d
leaq 0x168(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x12ddc
movq 0x120(%rsp), %rcx
movq 0x10(%rcx), %rax
leaq 0x180(%rsp), %rdx
movq %rax, 0x10(%rdx)
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
leaq 0x168(%rsp), %rdi
movl $0x3, %esi
callq 0x11408
leaq 0x168(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0xeefa
cmpl $0x0, 0x20(%rsp)
je 0xbd0e
movslq 0x38(%rsp), %r15
movslq 0x30(%rsp), %r12
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
je 0xbcfe
xorl %ebp, %ebp
cmpl $0x0, 0x18(%rsp)
je 0xbcf0
xorl %r14d, %r14d
movq 0x70(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xe968
cmpb $0x1, %al
jne 0xbce6
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xcef2
testl %eax, %eax
jne 0xbce6
movq %r15, %rdi
movq %r12, %rsi
movq 0xd8(%rsp), %rdx
movq %r14, %rcx
movq %rbp, %r8
movq %r13, %r9
leaq 0xe0(%rsp), %rax
pushq %rax
pushq 0x10(%rsp)
callq 0x11880
addq $0x10, %rsp
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movl %eax, %r8d
callq 0xe3de
incl %ebx
incq %r14
cmpq %r14, 0x38(%rsp)
jne 0xbc73
incq %rbp
cmpq 0x30(%rsp), %rbp
jne 0xbc65
incq %r13
cmpq 0x28(%rsp), %r13
jne 0xbc58
jmp 0xbd10
xorl %ebx, %ebx
movq 0x112b1(%rip), %rdi     # 0x1cfc8
leaq 0xbba5(%rip), %rsi      # 0x178c3
movl $0xe, %edx
callq 0x32f0
movq 0x11299(%rip), %rdi     # 0x1cfc8
movl %ebx, %esi
callq 0x3420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0xe0(%rsp), %rax
cmpq %rax, 0xe8(%rsp)
je 0xbd7a
movq %rax, 0xe8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xf8(%rsp)
movq $0x0, 0x108(%rsp)
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xbda3
callq 0x3280
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xbdb2
callq 0x3280
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0xbdc4
callq 0x3280
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0xbdd6
callq 0x3280
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb96a(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xb95c(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xb94e(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xb940(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
leaq 0xb932(%rip), %rdi      # 0x17759
movq %rdx, %rsi
xorl %eax, %eax
callq 0x3390
leaq 0xb921(%rip), %rdi      # 0x17759
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3390
leaq 0xb910(%rip), %rdi      # 0x17759
xorl %eax, %eax
callq 0x3390
jmp 0xbf04
jmp 0xbf04
movq %rax, %rbx
movq 0x198(%rsp), %rdi
cmpq %r15, %rdi
je 0xbe74
callq 0x3280
jmp 0xbe74
movq %rax, %rbx
movq 0x1b8(%rsp), %rdi
cmpq %r14, %rdi
je 0xbf16
jmp 0xbf11
movq %rax, %rbx
movq 0x1d8(%rsp), %rdi
cmpq %r15, %rdi
je 0xbea4
callq 0x3280
jmp 0xbea4
movq %rax, %rbx
movq 0x1f8(%rsp), %rdi
cmpq %r14, %rdi
je 0xbf16
jmp 0xbf11
jmp 0xbefd
jmp 0xbee2
jmp 0xbf04
jmp 0xbee2
jmp 0xbf04
movq %rax, %rbx
jmp 0xbf16
jmp 0xbefd
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbf04
jmp 0xbee2
jmp 0xbee2
jmp 0xbee2
jmp 0xbee2
jmp 0xbf04
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xbf07
callq 0x3280
jmp 0xbf07
jmp 0xbf04
jmp 0xbf04
movq %rax, %rbx
jmp 0xbf28
jmp 0xbf04
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xbf16
callq 0x3280
movq 0x168(%rsp), %rdi
testq %rdi, %rdi
je 0xbf28
callq 0x3280
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0xbf3a
callq 0x3280
movq %rbx, %rdi
callq 0x3430