// File: /workspace/github_cpp_makefile_star2_O1/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 $0x208, %rsp            # imm = 0x208
movl %ecx, 0xd4(%rsp)
movq %rdx, 0x60(%rsp)
movss %xmm0, 0x80(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
movq 0x12061(%rip), %rbx     # 0x1cfc8
leaq 0xc8b2(%rip), %rsi      # 0x17820
movl $0x17, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x18(%r14), %rax
movq %rax, 0x38(%rsp)
movq 0x20(%r14), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%r14), %rax
movq %rax, 0x70(%rsp)
leaq 0xc874(%rip), %rsi      # 0x17838
movl $0xd, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
movq %r14, 0x78(%rsp)
movq %r14, %rdi
callq 0xf028
movq 0x11fa6(%rip), %rdi     # 0x1cfc8
leaq 0xc81d(%rip), %rsi      # 0x17846
movl $0xc, %edx
callq 0x3300
movq 0x11f8e(%rip), %rdi     # 0x1cfc8
callq 0x31e0
movl 0x38(%rsp), %eax
movq %rax, 0x58(%rsp)
movl 0x30(%rsp), %eax
movq %rax, 0x50(%rsp)
movq 0x70(%rsp), %rcx
movl %ecx, %eax
movq %rax, 0x48(%rsp)
testl %ecx, %ecx
jle 0xb0f8
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x48(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x88(%rsp)
movq 0x50(%rsp), %r12
andq %rbp, %r12
andq 0x58(%rsp), %rbp
xorl %ebx, %ebx
leaq 0x100(%rsp), %r14
cmpl $0x0, 0x30(%rsp)
jle 0xb0eb
xorl %r15d, %r15d
cmpl $0x0, 0x38(%rsp)
jle 0xb0e3
xorl %r13d, %r13d
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xf418
ucomiss 0xc09b(%rip), %xmm0     # 0x17158
jb 0xb0c5
sqrtss %xmm0, %xmm0
jmp 0xb0ca
callq 0x3470
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0xf774
incq %r13
cmpq %r13, %rbp
jne 0xb0a5
incq %r15
cmpq %r12, %r15
jne 0xb09b
incq %rbx
cmpq 0x88(%rsp), %rbx
jne 0xb091
movq 0x11ec9(%rip), %rbx     # 0x1cfc8
leaq 0xc7c7(%rip), %rsi      # 0x178cd
movl $0x5, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq 0x11e97(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
leaq 0x158(%rsp), %rdi
movq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x12142
movq 0x28(%rsp), %r12
leaq 0x18(%rbx), %rcx
movq 0x10(%rcx), %rax
leaq 0x158(%rsp), %rdi
movq %rax, 0x28(%rdi)
movq %rcx, 0x130(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rdi)
leaq 0x100(%rsp), %rsi
movss 0x80(%rsp), %xmm0
callq 0xfad0
movq 0x60(%rsp), %rbx
leaq 0x1f8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x1e8(%rsp), %rdi
callq 0x1312e
leaq 0x1d8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xc687(%rip), %rsi      # 0x17853
leaq 0xc689(%rip), %rdx      # 0x1785c
leaq 0x1c8(%rsp), %rdi
callq 0x131be
movslq 0x48(%rsp), %rcx
leaq 0x158(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
leaq 0x1c8(%rsp), %rdx
movq %rcx, 0xf0(%rsp)
xorl %r8d, %r8d
callq 0x97f4
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0xb21f
callq 0x3290
movq 0x1e8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb231
callq 0x3290
leaq 0x100(%rsp), %rdi
movss 0xbf13(%rip), %xmm0     # 0x17154
movl $0x5, %esi
callq 0xfc1e
leaq 0x1b8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x1a8(%rsp), %rdi
callq 0x1312e
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xc5dc(%rip), %rsi      # 0x1785d
leaq 0xc5da(%rip), %rdx      # 0x17862
leaq 0x188(%rsp), %rdi
callq 0x131be
leaq 0x100(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x188(%rsp), %rdx
movq 0xf0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x1042c
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xb2cf
callq 0x3290
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0xb2e1
callq 0x3290
leaq 0x158(%rsp), %rdi
movq %r12, %rsi
callq 0x10f58
leaq 0x170(%rsp), %rcx
movq -0x18(%rcx), %rax
cmpq %rax, -0x10(%rcx)
je 0xb30b
movq %rax, 0x160(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x20(%rsp)
cmpq %rax, 0x18(%rsp)
je 0xb331
movq $0x0, 0x18(%rsp)
movl $0x0, 0x98(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xb359
movl $0x0, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xb36b
leaq 0x10(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0xef54
movq (%r12), %rdx
movq 0x8(%r12), %rax
cmpq %rax, %rdx
sete %sil
movq %rdx, %rcx
addq $0x4, %rcx
cmpq %rax, %rcx
sete %dil
orb %sil, %dil
je 0xb393
movq %rdx, %rsi
jmp 0xb3ab
movl (%rdx), %edi
movq %rcx, %rsi
cmpl (%rcx), %edi
jl 0xb39f
movq %rdx, %rsi
addq $0x4, %rcx
movq %rsi, %rdx
cmpq %rax, %rcx
jne 0xb393
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
movq 0x11c10(%rip), %rdi     # 0x1cfc8
leaq 0xc4a4(%rip), %rsi      # 0x17863
movl $0x13, %edx
callq 0x3300
movq 0x11bf8(%rip), %rdi     # 0x1cfc8
movl 0xc(%rsp), %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movl $0x1, 0x98(%rsp)
cmpl $0x0, 0xc(%rsp)
jle 0xb462
movl $0x1, %eax
leaq 0x10(%rsp), %rbx
leaq 0x98(%rsp), %r14
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xb440
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xb44b
movq %rbx, %rdi
movq %r14, %rdx
callq 0xedfa
movl 0x98(%rsp), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x98(%rsp)
cmpl 0xc(%rsp), %ecx
jl 0xb427
movl 0xc(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x70(%rsp)
je 0xb918
xorl %ebx, %ebx
leaq 0x10(%rsp), %r14
leaq 0x44(%rsp), %r15
cmpl $0x0, 0x30(%rsp)
je 0xb523
xorl %r12d, %r12d
cmpl $0x0, 0x38(%rsp)
je 0xb515
xorl %r13d, %r13d
movq 0x78(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xeaa4
cmpb $0x1, %al
jne 0xb50b
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xd03a
testl %eax, %eax
jne 0xb50b
movl 0x44(%rsp), %r8d
movq 0x28(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0xe52c
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xb4fc
movl 0x44(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0xb507
movq %r14, %rdi
movq %r15, %rdx
callq 0xedfa
incl 0x44(%rsp)
incq %r13
cmpq %r13, 0x58(%rsp)
jne 0xb499
incq %r12
cmpq 0x50(%rsp), %r12
jne 0xb48f
incq %rbx
cmpq 0x48(%rsp), %rbx
jne 0xb481
movq 0x38(%rsp), %rax
decl %eax
movl %eax, 0xc4(%rsp)
movq 0x30(%rsp), %rax
decl %eax
movl %eax, 0xc0(%rsp)
movq 0x70(%rsp), %rax
decl %eax
movl %eax, 0xbc(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0xf8(%rsp)
xorl %ebp, %ebp
movq 0x28(%rsp), %r12
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
movq %rax, 0x140(%rsp)
cmpl $0x0, 0x30(%rsp)
je 0xb902
cmpl $0x2, %ebp
movl $0x1, %eax
cmovgel %ebp, %eax
decl %eax
movl %eax, 0xe0(%rsp)
leal 0x1(%rbp), %ecx
movl 0xbc(%rsp), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0xdc(%rsp)
movslq %ecx, %rax
movq %rax, 0x150(%rsp)
xorl %r15d, %r15d
movq %rbp, 0xb0(%rsp)
cmpl $0x2, %r15d
movl $0x1, %eax
cmovgel %r15d, %eax
movq %rax, 0xe8(%rsp)
cmpl $0x0, 0x38(%rsp)
je 0xb8f4
decq 0xe8(%rsp)
cmpl $0x2, %r15d
movl $0x1, %eax
cmovgel %r15d, %eax
decl %eax
movl %eax, 0xd0(%rsp)
leal 0x1(%r15), %ecx
movl 0xc0(%rsp), %eax
cmpl %ecx, %eax
cmovll %eax, %ecx
movl %ecx, 0xcc(%rsp)
movslq %ecx, %rax
movq %rax, 0x148(%rsp)
xorl %r13d, %r13d
movq %r15, 0x80(%rsp)
cmpl $0x2, %r13d
movl $0x1, %eax
cmovgel %r13d, %eax
movq %rax, 0x60(%rsp)
movq 0x78(%rsp), %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xeaa4
cmpb $0x1, %al
jne 0xb8e6
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xd03a
cmpl 0xc(%rsp), %eax
jle 0xb8e6
leal 0x1(%r13), %ebx
movl 0xc4(%rsp), %eax
cmpl %ebx, %eax
cmovll %eax, %ebx
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xd03a
movl %eax, %r14d
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xd03a
movl %eax, 0x90(%rsp)
movl %r14d, 0xc8(%rsp)
cmpl $0x2, %r13d
movl $0x1, %eax
cmovgel %r13d, %eax
decl %eax
cmpl %ebx, %eax
jg 0xb886
decq 0x60(%rsp)
movslq %ebx, %rax
movq %rax, 0x138(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x94(%rsp)
movq %r13, %r14
movl 0xcc(%rsp), %eax
cmpl %eax, 0xd0(%rsp)
jg 0xb867
movq 0x60(%rsp), %rax
subl %r13d, %eax
imull %eax, %eax
movl %eax, 0xd8(%rsp)
movq 0xe8(%rsp), %rbx
movl 0xdc(%rsp), %eax
cmpl %eax, 0xe0(%rsp)
jg 0xb852
movl %ebx, %r12d
subl 0x80(%rsp), %r12d
imull %r12d, %r12d
addl 0xd8(%rsp), %r12d
movq 0x140(%rsp), %r15
leaq -0x1(%r15), %r13
leaq 0x100(%rsp), %rbp
movq %rbp, %rdi
movq 0x60(%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xf418
movss %xmm0, 0x88(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq 0x80(%rsp), %rdx
movq 0xb0(%rsp), %rcx
callq 0xf418
movaps %xmm0, %xmm2
movq 0xf8(%rsp), %rax
addl %r15d, %eax
imull %eax, %eax
addl %r12d, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
ucomisd 0xb89f(%rip), %xmm0     # 0x17060
jb 0xb7c9
sqrtsd %xmm0, %xmm0
jmp 0xb7e0
movss %xmm2, 0xe4(%rsp)
callq 0x3240
movss 0xe4(%rsp), %xmm2
cvtsd2ss %xmm0, %xmm0
ucomiss 0xb96d(%rip), %xmm0     # 0x17158
jne 0xb7ef
jnp 0xb841
movss 0x88(%rsp), %xmm1
subss %xmm2, %xmm1
divss %xmm0, %xmm1
movss %xmm1, 0x88(%rsp)
ucomiss 0x94(%rsp), %xmm1
jbe 0xb841
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0xd03a
movl %eax, 0x90(%rsp)
movss 0x88(%rsp), %xmm0
movss %xmm0, 0x94(%rsp)
incq %r15
cmpq 0x150(%rsp), %r13
jl 0xb75b
leaq 0x1(%rbx), %rax
cmpq 0x148(%rsp), %rbx
movq %rax, %rbx
jl 0xb728
movq 0x60(%rsp), %rcx
leaq 0x1(%rcx), %rax
cmpq 0x138(%rsp), %rcx
movq %rax, 0x60(%rsp)
movq %r14, %r13
jl 0xb6fa
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movl 0xc8(%rsp), %ecx
movslq %ecx, %rsi
movl 0x90(%rsp), %edi
cmpl %ecx, %edi
movq 0x80(%rsp), %r15
jne 0xb8cb
cmpq %rsi, %rdx
movq 0x28(%rsp), %r12
movq 0xb0(%rsp), %rbp
ja 0xb8e3
jmp 0xbf53
cmpq %rsi, %rdx
movq 0x28(%rsp), %r12
movq 0xb0(%rsp), %rbp
jbe 0xbf53
negl %edi
movl %edi, (%rax,%rsi,4)
incq %r13
cmpq 0x58(%rsp), %r13
jne 0xb638
incq %r15
cmpq 0x50(%rsp), %r15
jne 0xb5cd
incq %rbp
decq 0xf8(%rsp)
cmpq 0x48(%rsp), %rbp
jne 0xb56f
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
je 0xb950
sarq $0x2, %rdx
movl $0x1, %ebp
xorl %esi, %esi
cmpq %rsi, %rdx
je 0xbf61
cmpl $0x0, (%rax,%rsi,4)
jle 0xb946
movl %ebp, (%rax,%rsi,4)
incl %ebp
incq %rsi
cmpq %rsi, %rdx
jne 0xb932
jmp 0xb955
movl $0x1, %ebp
movq 0x1166c(%rip), %rbx     # 0x1cfc8
leaq 0xbf14(%rip), %rsi      # 0x17877
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq 0x1163a(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
xorl %ebx, %ebx
cmpq $0x4, %rdx
je 0xb9d9
sarq $0x2, %rdx
xorl %ebx, %ebx
movl $0x1, %esi
movl $0x2, %ecx
cmpq %rsi, %rdx
jbe 0xbf80
cmpl $0x1, (%rax,%rsi,4)
adcl $0x0, %ebx
movl %ecx, %esi
incl %ecx
cmpq %rsi, %rdx
jne 0xb9c0
movq 0x115e8(%rip), %rdi     # 0x1cfc8
leaq 0xbead(%rip), %rsi      # 0x17894
movl $0xc, %edx
callq 0x3300
movq 0x115d0(%rip), %rdi     # 0x1cfc8
movl %ebx, %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x11598(%rip), %rdi     # 0x1cfc8
leaq 0xbe2c(%rip), %rsi      # 0x17863
movl $0x13, %edx
callq 0x3300
movq 0x11580(%rip), %rdi     # 0x1cfc8
movl 0xc(%rsp), %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x11546(%rip), %rdi     # 0x1cfc8
leaq 0xbe18(%rip), %rsi      # 0x178a1
movl $0xf, %edx
callq 0x3300
movq 0x1152e(%rip), %rdi     # 0x1cfc8
movl %ebp, %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x2, %rax
testl %eax, %eax
je 0xbb48
xorl %ebx, %ebx
leaq 0x10(%rsp), %r14
movl %ebx, %edi
movq %r14, %rsi
callq 0x11494
cmpl 0xc(%rsp), %eax
jle 0xbb09
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
xorl %eax, %eax
jmp 0xbb24
movl %ebx, %edi
movq %r14, %rsi
callq 0x11494
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0xbf6f
movl %eax, (%rcx,%rbx,4)
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
incq %rbx
shrq $0x2, %rax
movl %eax, %eax
cmpq %rax, %rbx
jne 0xbae4
cmpl $0x0, 0x70(%rsp)
je 0xbbc6
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
je 0xbbbc
xorl %r14d, %r14d
cmpl $0x0, 0x38(%rsp)
je 0xbbb2
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xd03a
movslq %eax, %rsi
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbf29
movl (%rax,%rsi,4), %r8d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xe52c
incq %r15
cmpq %r15, 0x58(%rsp)
jne 0xbb65
incq %r14
cmpq 0x50(%rsp), %r14
jne 0xbb5b
incq %rbx
cmpq 0x48(%rsp), %rbx
jne 0xbb51
movq 0x113fb(%rip), %rbx     # 0x1cfc8
leaq 0xbcdd(%rip), %rsi      # 0x178b1
movl $0x21, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq 0x113c9(%rip), %rdi     # 0x1cfc8
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movslq 0xc(%rsp), %rsi
incq %rsi
leaq 0x98(%rsp), %rdi
leaq 0x6f(%rsp), %rdx
callq 0xe886
cmpl $0x0, 0x70(%rsp)
je 0xbd28
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
je 0xbc92
xorl %r14d, %r14d
cmpl $0x0, 0x38(%rsp)
je 0xbc88
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xd03a
movslq %eax, %rsi
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbf37
incl (%rax,%rsi,4)
incq %r15
cmpq %r15, 0x58(%rsp)
jne 0xbc47
incq %r14
cmpq 0x50(%rsp), %r14
jne 0xbc3d
incq %rbx
cmpq 0x48(%rsp), %rbx
jne 0xbc33
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
je 0xbd1a
xorl %r14d, %r14d
cmpl $0x0, 0x38(%rsp)
je 0xbd10
xorl %r15d, %r15d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0xd03a
movslq %eax, %rsi
movq 0x98(%rsp), %rax
movq 0xa0(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0xbf45
movl 0xd4(%rsp), %ecx
cmpl %ecx, (%rax,%rsi,4)
jge 0xbd06
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0xe52c
incq %r15
cmpq %r15, 0x58(%rsp)
jne 0xbcb2
incq %r14
cmpq 0x50(%rsp), %r14
jne 0xbca8
incq %rbx
cmpq 0x48(%rsp), %rbx
jne 0xbc9e
leaq 0x158(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x12f3c
movq 0x130(%rsp), %rcx
movq 0x10(%rcx), %rax
leaq 0x170(%rsp), %rdx
movq %rax, 0x10(%rdx)
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
leaq 0x158(%rsp), %rdi
movl $0x3, %esi
callq 0x114ee
leaq 0x158(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0xf028
cmpl $0x0, 0x70(%rsp)
je 0xbe4f
movslq 0x58(%rsp), %r15
movslq 0x50(%rsp), %r12
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpl $0x0, 0x30(%rsp)
je 0xbe3f
xorl %ebp, %ebp
cmpl $0x0, 0x38(%rsp)
je 0xbe31
xorl %r14d, %r14d
movq 0x78(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xeaa4
cmpb $0x1, %al
jne 0xbe27
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xd03a
testl %eax, %eax
jne 0xbe27
movq %r15, %rdi
movq %r12, %rsi
movq 0xf0(%rsp), %rdx
movq %r14, %rcx
movq %rbp, %r8
movq %r13, %r9
leaq 0x100(%rsp), %rax
pushq %rax
pushq 0x30(%rsp)
callq 0x119be
addq $0x10, %rsp
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movl %eax, %r8d
callq 0xe52c
incl %ebx
incq %r14
cmpq %r14, 0x58(%rsp)
jne 0xbdb4
incq %rbp
cmpq 0x50(%rsp), %rbp
jne 0xbda6
incq %r13
cmpq 0x48(%rsp), %r13
jne 0xbd99
jmp 0xbe51
xorl %ebx, %ebx
movq 0x11170(%rip), %rdi     # 0x1cfc8
leaq 0xba74(%rip), %rsi      # 0x178d3
movl $0xe, %edx
callq 0x3300
movq 0x11158(%rip), %rdi     # 0x1cfc8
movl %ebx, %esi
callq 0x3430
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31e0
movq 0x100(%rsp), %rax
cmpq %rax, 0x108(%rsp)
je 0xbebb
movq %rax, 0x108(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x118(%rsp)
movq $0x0, 0x128(%rsp)
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xbee4
callq 0x3290
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xbef3
callq 0x3290
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0xbf05
callq 0x3290
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0xbf17
callq 0x3290
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb839(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xb82b(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xb81d(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xb80f(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xb801(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
leaq 0xb7f3(%rip), %rdi      # 0x17769
movq %rbx, %rsi
xorl %eax, %eax
callq 0x33a0
leaq 0xb7e2(%rip), %rdi      # 0x17769
xorl %eax, %eax
callq 0x33a0
jmp 0xc042
jmp 0xc042
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r15, %rdi
je 0xbfb2
callq 0x3290
jmp 0xbfb2
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r14, %rdi
je 0xc054
jmp 0xc04f
movq %rax, %rbx
movq 0x1c8(%rsp), %rdi
cmpq %r15, %rdi
je 0xbfe2
callq 0x3290
jmp 0xbfe2
movq %rax, %rbx
movq 0x1e8(%rsp), %rdi
cmpq %r14, %rdi
je 0xc054
jmp 0xc04f
jmp 0xc03b
jmp 0xc020
jmp 0xc042
jmp 0xc020
jmp 0xc042
movq %rax, %rbx
jmp 0xc054
jmp 0xc042
jmp 0xc03b
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc042
jmp 0xc020
jmp 0xc020
jmp 0xc020
jmp 0xc042
jmp 0xc020
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xc045
callq 0x3290
jmp 0xc045
jmp 0xc042
jmp 0xc042
movq %rax, %rbx
jmp 0xc066
jmp 0xc042
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc054
callq 0x3290
movq 0x158(%rsp), %rdi
testq %rdi, %rdi
je 0xc066
callq 0x3290
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0xc078
callq 0x3290
movq %rbx, %rdi
callq 0x3440