// File: 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:
subq $0x438, %rsp            # imm = 0x438
movq %rdx, 0x1b8(%rsp)
movq %rdi, 0x430(%rsp)
movq %rsi, 0x428(%rsp)
movss %xmm0, 0x424(%rsp)
movq %rdx, 0x418(%rsp)
movl %ecx, 0x414(%rsp)
movq 0x27622(%rip), %rdi     # 0x33fc0
movq %rdi, 0x1c0(%rsp)
leaq 0x1bdf0(%rip), %rsi     # 0x2879d
callq 0x3290
movq %rax, %rdi
movq 0x275e4(%rip), %rsi     # 0x33fa0
movq %rsi, 0x1c8(%rsp)
callq 0x32c0
movq 0x430(%rsp), %rdi
callq 0x125e0
movl %eax, 0x410(%rsp)
movq 0x430(%rsp), %rdi
callq 0x125f0
movl %eax, 0x40c(%rsp)
movq 0x430(%rsp), %rdi
callq 0x12600
movq 0x1c0(%rsp), %rdi
movl %eax, 0x408(%rsp)
leaq 0x1bda1(%rip), %rsi     # 0x287b5
callq 0x3290
movq 0x1c8(%rsp), %rsi
movq %rax, %rdi
callq 0x32c0
leaq 0x3d8(%rsp), %rdi
movq %rdi, 0x1d0(%rsp)
callq 0x155d0
movq 0x1d0(%rsp), %rsi
movq 0x430(%rsp), %rdi
callq 0x155e0
jmp 0xca55
movq 0x27564(%rip), %rdi     # 0x33fc0
leaq 0x1bd60(%rip), %rsi     # 0x287c3
callq 0x3290
movq %rax, 0x1b0(%rsp)
jmp 0xca72
movq 0x1b0(%rsp), %rdi
movq 0x27547(%rip), %rsi     # 0x33fc8
callq 0x32c0
jmp 0xca88
movl $0x0, 0x3c8(%rsp)
movl 0x3c8(%rsp), %eax
cmpl 0x408(%rsp), %eax
jge 0xcbc5
movl $0x0, 0x3c4(%rsp)
movl 0x3c4(%rsp), %eax
cmpl 0x40c(%rsp), %eax
jge 0xcbad
movl $0x0, 0x3c0(%rsp)
movl 0x3c0(%rsp), %eax
cmpl 0x410(%rsp), %eax
jge 0xcb95
movslq 0x3c0(%rsp), %rsi
movslq 0x3c4(%rsp), %rdx
movslq 0x3c8(%rsp), %rcx
leaq 0x3d8(%rsp), %rdi
callq 0x15be0
movss %xmm0, 0x1ac(%rsp)
jmp 0xcb15
movss 0x1ac(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x3250
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x3bc(%rsp)
movslq 0x3c0(%rsp), %rsi
movslq 0x3c4(%rsp), %rdx
movslq 0x3c8(%rsp), %rcx
movss 0x3bc(%rsp), %xmm0
leaq 0x3d8(%rsp), %rdi
callq 0x15f80
jmp 0xcb64
jmp 0xcb66
movl 0x3c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c0(%rsp)
jmp 0xcad1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
jmp 0xe13a
jmp 0xcb97
movl 0x3c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c4(%rsp)
jmp 0xcab2
jmp 0xcbaf
movl 0x3c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c8(%rsp)
jmp 0xca93
movq 0x273f4(%rip), %rdi     # 0x33fc0
leaq 0x1bc77(%rip), %rsi     # 0x2884a
callq 0x3290
movq %rax, 0x1a0(%rsp)
jmp 0xcbe2
movq 0x1a0(%rsp), %rdi
movq 0x273af(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xcbf8
movq 0x430(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x16340
jmp 0xcc0f
movss 0x424(%rsp), %xmm0
leaq 0x388(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0x16390
jmp 0xcc2f
movq 0x1b8(%rsp), %rsi
leaq 0x368(%rsp), %rdi
callq 0x3120
jmp 0xcc46
leaq 0x347(%rsp), %rdi
movq %rdi, 0x198(%rsp)
callq 0x34b0
movq 0x198(%rsp), %rdx
leaq 0x1bb66(%rip), %rsi     # 0x287d0
leaq 0x348(%rsp), %rdi
callq 0x3360
jmp 0xcc79
movslq 0x408(%rsp), %rcx
leaq 0x388(%rsp), %rdi
leaq 0x368(%rsp), %rsi
leaq 0x348(%rsp), %rdx
xorl %r8d, %r8d
callq 0xaab0
jmp 0xcca3
leaq 0x348(%rsp), %rdi
callq 0x3538
leaq 0x347(%rsp), %rdi
callq 0x32d0
leaq 0x368(%rsp), %rdi
callq 0x3538
leaq 0x3d8(%rsp), %rdi
movl $0x5, %esi
movss 0x1b425(%rip), %xmm0    # 0x28104
callq 0x16500
jmp 0xcce6
movq 0x1b8(%rsp), %rsi
leaq 0x320(%rsp), %rdi
callq 0x3120
jmp 0xccfd
leaq 0x2ff(%rsp), %rdi
movq %rdi, 0x190(%rsp)
callq 0x34b0
movq 0x190(%rsp), %rdx
leaq 0x1bab9(%rip), %rsi     # 0x287da
leaq 0x300(%rsp), %rdi
callq 0x3360
jmp 0xcd30
movslq 0x408(%rsp), %rcx
leaq 0x3d8(%rsp), %rdi
leaq 0x320(%rsp), %rsi
leaq 0x300(%rsp), %rdx
xorl %r8d, %r8d
callq 0x17270
jmp 0xcd5a
leaq 0x300(%rsp), %rdi
callq 0x3538
leaq 0x2ff(%rsp), %rdi
callq 0x32d0
leaq 0x320(%rsp), %rdi
callq 0x3538
movq 0x428(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x17ac0
jmp 0xcd98
leaq 0x388(%rsp), %rdi
callq 0x182d0
jmp 0xcda7
leaq 0x2e0(%rsp), %rdi
movq %rdi, 0x188(%rsp)
callq 0x125d0
movq 0x188(%rsp), %rdi
callq 0x12610
movq 0x188(%rsp), %rdi
movl $0x0, 0x2dc(%rsp)
leaq 0x2dc(%rsp), %rsi
callq 0x18310
jmp 0xcdeb
movq 0x428(%rsp), %rdi
callq 0x18340
movl %eax, 0x184(%rsp)
jmp 0xce01
movl 0x184(%rsp), %eax
movl %eax, 0x2d8(%rsp)
movq 0x271aa(%rip), %rdi     # 0x33fc0
leaq 0x1b9c3(%rip), %rsi     # 0x287e0
callq 0x3290
movq %rax, 0x178(%rsp)
jmp 0xce2c
movq 0x178(%rsp), %rdi
movl 0x2d8(%rsp), %esi
callq 0x3470
movq %rax, 0x170(%rsp)
jmp 0xce4a
movq 0x170(%rsp), %rdi
movq 0x27147(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xce60
movl $0x1, 0x2d4(%rsp)
movl 0x2d4(%rsp), %eax
cmpl 0x2d8(%rsp), %eax
jg 0xcf89
leaq 0x2e0(%rsp), %rdi
leaq 0x2d4(%rsp), %rsi
callq 0x12910
jmp 0xce96
jmp 0xce98
movl 0x2d4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2d4(%rsp)
jmp 0xce6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
jmp 0xe12d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
jmp 0xcefb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
leaq 0x348(%rsp), %rdi
callq 0x3538
leaq 0x347(%rsp), %rdi
callq 0x32d0
leaq 0x368(%rsp), %rdi
callq 0x3538
jmp 0xe12d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
jmp 0xcf51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
leaq 0x300(%rsp), %rdi
callq 0x3538
leaq 0x2ff(%rsp), %rdi
callq 0x32d0
leaq 0x320(%rsp), %rdi
callq 0x3538
jmp 0xe12d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
jmp 0xe120
movl 0x2d8(%rsp), %eax
movl %eax, 0x2d0(%rsp)
movl $0x0, 0x2cc(%rsp)
movl 0x2cc(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xd10e
movl $0x0, 0x2c8(%rsp)
movl 0x2c8(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xd0f6
movl $0x0, 0x2c4(%rsp)
movl 0x2c4(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xd0de
movq 0x430(%rsp), %rdi
movslq 0x2c4(%rsp), %rsi
movslq 0x2c8(%rsp), %rdx
movslq 0x2cc(%rsp), %rcx
callq 0x13b70
movb %al, 0x16f(%rsp)
jmp 0xd022
movb 0x16f(%rsp), %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xd0c6
movq 0x428(%rsp), %rdi
movslq 0x2c4(%rsp), %rsi
movslq 0x2c8(%rsp), %rdx
movslq 0x2cc(%rsp), %rcx
callq 0xefc0
movl %eax, 0x168(%rsp)
jmp 0xd063
movl 0x168(%rsp), %eax
cmpl $0x0, %eax
jne 0xd0c6
movq 0x428(%rsp), %rdi
movslq 0x2c4(%rsp), %rsi
movslq 0x2c8(%rsp), %rdx
movslq 0x2cc(%rsp), %rcx
movl 0x2d0(%rsp), %r8d
callq 0x12980
jmp 0xd09e
leaq 0x2e0(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
callq 0x12910
jmp 0xd0b5
movl 0x2d0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2d0(%rsp)
jmp 0xd0c8
movl 0x2c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c4(%rsp)
jmp 0xcfe0
jmp 0xd0e0
movl 0x2c8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c8(%rsp)
jmp 0xcfc1
jmp 0xd0f8
movl 0x2cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2cc(%rsp)
jmp 0xcfa2
movl $0x0, 0x2c0(%rsp)
movl 0x2c0(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xd6e5
movl $0x0, 0x2bc(%rsp)
movl 0x2bc(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xd6cd
movl $0x0, 0x2b8(%rsp)
movl 0x2b8(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xd6b5
movq 0x430(%rsp), %rdi
movslq 0x2b8(%rsp), %rsi
movslq 0x2bc(%rsp), %rdx
movslq 0x2c0(%rsp), %rcx
callq 0x13b70
movb %al, 0x167(%rsp)
jmp 0xd199
movb 0x167(%rsp), %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xd69d
movq 0x428(%rsp), %rdi
movslq 0x2b8(%rsp), %rsi
movslq 0x2bc(%rsp), %rdx
movslq 0x2c0(%rsp), %rcx
callq 0xefc0
movl %eax, 0x160(%rsp)
jmp 0xd1da
movl 0x160(%rsp), %eax
cmpl 0x2d8(%rsp), %eax
jle 0xd69d
movl 0x2b8(%rsp), %eax
decl %eax
movl %eax, 0x2b0(%rsp)
movl $0x0, 0x2ac(%rsp)
leaq 0x2b0(%rsp), %rdi
leaq 0x2ac(%rsp), %rsi
callq 0x127b0
movl (%rax), %eax
movl %eax, 0x2b4(%rsp)
movl 0x2b8(%rsp), %eax
incl %eax
movl %eax, 0x2a4(%rsp)
movl 0x410(%rsp), %eax
decl %eax
movl %eax, 0x2a0(%rsp)
leaq 0x2a4(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x127f0
movl (%rax), %eax
movl %eax, 0x2a8(%rsp)
movl 0x2bc(%rsp), %eax
decl %eax
movl %eax, 0x298(%rsp)
movl $0x0, 0x294(%rsp)
leaq 0x298(%rsp), %rdi
leaq 0x294(%rsp), %rsi
callq 0x127b0
movl (%rax), %eax
movl %eax, 0x29c(%rsp)
movl 0x2bc(%rsp), %eax
incl %eax
movl %eax, 0x28c(%rsp)
movl 0x40c(%rsp), %eax
decl %eax
movl %eax, 0x288(%rsp)
leaq 0x28c(%rsp), %rdi
leaq 0x288(%rsp), %rsi
callq 0x127f0
movl (%rax), %eax
movl %eax, 0x290(%rsp)
movl 0x2c0(%rsp), %eax
decl %eax
movl %eax, 0x280(%rsp)
movl $0x0, 0x27c(%rsp)
leaq 0x280(%rsp), %rdi
leaq 0x27c(%rsp), %rsi
callq 0x127b0
movl (%rax), %eax
movl %eax, 0x284(%rsp)
movl 0x2c0(%rsp), %eax
incl %eax
movl %eax, 0x274(%rsp)
movl 0x408(%rsp), %eax
decl %eax
movl %eax, 0x270(%rsp)
leaq 0x274(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x127f0
movl (%rax), %eax
movl %eax, 0x278(%rsp)
movl $0x0, 0x26c(%rsp)
movq 0x428(%rsp), %rdi
movslq 0x2b8(%rsp), %rsi
movslq 0x2bc(%rsp), %rdx
movslq 0x2c0(%rsp), %rcx
callq 0xefc0
movl %eax, 0x15c(%rsp)
jmp 0xd38c
movl 0x15c(%rsp), %eax
movl %eax, 0x268(%rsp)
movq 0x428(%rsp), %rdi
movslq 0x2b8(%rsp), %rsi
movslq 0x2bc(%rsp), %rdx
movslq 0x2c0(%rsp), %rcx
callq 0xefc0
movl %eax, 0x158(%rsp)
jmp 0xd3c8
movl 0x158(%rsp), %eax
movl %eax, 0x264(%rsp)
movl 0x2b4(%rsp), %eax
movl %eax, 0x260(%rsp)
movl 0x260(%rsp), %eax
cmpl 0x2a8(%rsp), %eax
jg 0xd60b
movl 0x29c(%rsp), %eax
movl %eax, 0x25c(%rsp)
movl 0x25c(%rsp), %eax
cmpl 0x290(%rsp), %eax
jg 0xd5f3
movl 0x284(%rsp), %eax
movl %eax, 0x258(%rsp)
movl 0x258(%rsp), %eax
cmpl 0x278(%rsp), %eax
jg 0xd5db
movslq 0x260(%rsp), %rsi
movslq 0x25c(%rsp), %rdx
movslq 0x258(%rsp), %rcx
leaq 0x3d8(%rsp), %rdi
callq 0x15be0
movss %xmm0, 0x154(%rsp)
jmp 0xd46c
movslq 0x2b8(%rsp), %rsi
movslq 0x2bc(%rsp), %rdx
movslq 0x2c0(%rsp), %rcx
leaq 0x3d8(%rsp), %rdi
callq 0x15be0
movss %xmm0, 0x150(%rsp)
jmp 0xd49c
movss 0x150(%rsp), %xmm1
movss 0x154(%rsp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x254(%rsp)
movl 0x260(%rsp), %eax
subl 0x2b8(%rsp), %eax
movl 0x260(%rsp), %ecx
subl 0x2b8(%rsp), %ecx
imull %ecx, %eax
movl 0x25c(%rsp), %ecx
subl 0x2bc(%rsp), %ecx
movl 0x25c(%rsp), %edx
subl 0x2bc(%rsp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl 0x258(%rsp), %ecx
subl 0x2c0(%rsp), %ecx
movl 0x258(%rsp), %edx
subl 0x2c0(%rsp), %edx
imull %edx, %ecx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
callq 0x3250
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x250(%rsp)
movss 0x250(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xd547
jp 0xd547
jmp 0xd5c5
movss 0x254(%rsp), %xmm0
divss 0x250(%rsp), %xmm0
movss %xmm0, 0x24c(%rsp)
movss 0x24c(%rsp), %xmm0
ucomiss 0x26c(%rsp), %xmm0
jbe 0xd5c3
movss 0x24c(%rsp), %xmm0
movss %xmm0, 0x26c(%rsp)
movq 0x428(%rsp), %rdi
movslq 0x260(%rsp), %rsi
movslq 0x25c(%rsp), %rdx
movslq 0x258(%rsp), %rcx
callq 0xefc0
movl %eax, 0x14c(%rsp)
jmp 0xd5b5
movl 0x14c(%rsp), %eax
movl %eax, 0x264(%rsp)
jmp 0xd5c5
movl 0x258(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x258(%rsp)
jmp 0xd428
jmp 0xd5dd
movl 0x25c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x25c(%rsp)
jmp 0xd406
jmp 0xd5f5
movl 0x260(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x260(%rsp)
jmp 0xd3e4
movl 0x264(%rsp), %eax
cmpl 0x268(%rsp), %eax
je 0xd65d
movl 0x264(%rsp), %eax
negl %eax
movl %eax, 0x13c(%rsp)
movslq 0x268(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x140(%rsp)
jmp 0xd64a
movq 0x140(%rsp), %rax
movl 0x13c(%rsp), %ecx
movl %ecx, (%rax)
jmp 0xd69b
movl 0x264(%rsp), %eax
movl %eax, 0x12c(%rsp)
movslq 0x268(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x130(%rsp)
jmp 0xd68a
movq 0x130(%rsp), %rax
movl 0x12c(%rsp), %ecx
movl %ecx, (%rax)
jmp 0xd69d
jmp 0xd69f
movl 0x2b8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2b8(%rsp)
jmp 0xd157
jmp 0xd6b7
movl 0x2bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2bc(%rsp)
jmp 0xd138
jmp 0xd6cf
movl 0x2c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c0(%rsp)
jmp 0xd119
movl $0x1, 0x248(%rsp)
movq $0x0, 0x240(%rsp)
movq 0x240(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x12830
movq %rax, %rcx
movq 0x120(%rsp), %rax
cmpq %rcx, %rax
je 0xd7c3
movq 0x240(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x118(%rsp)
jmp 0xd74c
movq 0x118(%rsp), %rax
cmpl $0x0, (%rax)
jle 0xd7a8
movl 0x248(%rsp), %eax
movl %eax, 0x10c(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x110(%rsp)
jmp 0xd786
movq 0x110(%rsp), %rax
movl 0x10c(%rsp), %ecx
movl %ecx, (%rax)
movl 0x248(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x248(%rsp)
jmp 0xd7aa
movq 0x240(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x240(%rsp)
jmp 0xd6fc
movq 0x267f6(%rip), %rdi     # 0x33fc0
leaq 0x1b023(%rip), %rsi     # 0x287f4
callq 0x3290
movq %rax, 0x100(%rsp)
jmp 0xd7e0
movq 0x100(%rsp), %rdi
movq 0x267b1(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xd7f6
movl $0x0, 0x23c(%rsp)
movl $0x1, 0x238(%rsp)
movl 0x238(%rsp), %eax
movq %rax, 0xf8(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x12830
movq %rax, %rcx
movq 0xf8(%rsp), %rax
cmpq %rcx, %rax
je 0xd88b
movl 0x238(%rsp), %eax
movl %eax, %esi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0xf0(%rsp)
jmp 0xd858
movq 0xf0(%rsp), %rax
cmpl $0x0, (%rax)
jne 0xd876
movl 0x23c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x23c(%rsp)
jmp 0xd878
movl 0x238(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x238(%rsp)
jmp 0xd80c
movq 0x2672e(%rip), %rdi     # 0x33fc0
leaq 0x1af78(%rip), %rsi     # 0x28811
callq 0x3290
movq %rax, 0xe8(%rsp)
jmp 0xd8a8
movq 0xe8(%rsp), %rdi
movl 0x23c(%rsp), %esi
callq 0x3470
movq %rax, 0xe0(%rsp)
jmp 0xd8c6
movq 0xe0(%rsp), %rdi
movq 0x266cb(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xd8dc
movq 0x266dd(%rip), %rdi     # 0x33fc0
leaq 0x1aef6(%rip), %rsi     # 0x287e0
callq 0x3290
movq %rax, 0xd8(%rsp)
jmp 0xd8f9
movq 0xd8(%rsp), %rdi
movl 0x2d8(%rsp), %esi
callq 0x3470
movq %rax, 0xd0(%rsp)
jmp 0xd917
movq 0xd0(%rsp), %rdi
movq 0x2667a(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xd92d
movq 0x2668c(%rip), %rdi     # 0x33fc0
leaq 0x1aee3(%rip), %rsi     # 0x2881e
callq 0x3290
movq %rax, 0xc8(%rsp)
jmp 0xd94a
movq 0xc8(%rsp), %rdi
movl 0x248(%rsp), %esi
callq 0x3470
movq %rax, 0xc0(%rsp)
jmp 0xd968
movq 0xc0(%rsp), %rdi
movq 0x26629(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xd97e
movl $0x0, 0x234(%rsp)
movl 0x234(%rsp), %eax
movl %eax, 0xbc(%rsp)
leaq 0x2e0(%rsp), %rdi
callq 0x12830
movq %rax, %rcx
movl 0xbc(%rsp), %eax
cmpl %ecx, %eax
je 0xda77
movl 0x234(%rsp), %edi
leaq 0x2e0(%rsp), %rsi
callq 0x183a0
movl %eax, 0xb8(%rsp)
jmp 0xd9d3
movl 0xb8(%rsp), %eax
cmpl 0x2d8(%rsp), %eax
jle 0xda12
movslq 0x234(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0xb0(%rsp)
jmp 0xda02
movq 0xb0(%rsp), %rax
movl $0x0, (%rax)
jmp 0xda5f
movl 0x234(%rsp), %edi
leaq 0x2e0(%rsp), %rsi
callq 0x183a0
movl %eax, 0xac(%rsp)
jmp 0xda2f
movslq 0x234(%rsp), %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0xa0(%rsp)
jmp 0xda4e
movq 0xa0(%rsp), %rax
movl 0xac(%rsp), %ecx
movl %ecx, (%rax)
jmp 0xda61
movl 0x234(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x234(%rsp)
jmp 0xd989
movl $0x0, 0x230(%rsp)
movl 0x230(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xdbab
movl $0x0, 0x22c(%rsp)
movl 0x22c(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xdb93
movl $0x0, 0x228(%rsp)
movl 0x228(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xdb7b
movq 0x428(%rsp), %rdi
movslq 0x228(%rsp), %rsi
movslq 0x22c(%rsp), %rdx
movslq 0x230(%rsp), %rcx
callq 0xefc0
movl %eax, 0x9c(%rsp)
jmp 0xdb02
movl 0x9c(%rsp), %eax
movslq %eax, %rsi
leaq 0x2e0(%rsp), %rdi
callq 0x12f20
movq %rax, 0x90(%rsp)
jmp 0xdb23
movq 0x90(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x224(%rsp)
movq 0x428(%rsp), %rdi
movslq 0x228(%rsp), %rsi
movslq 0x22c(%rsp), %rdx
movslq 0x230(%rsp), %rcx
movl 0x224(%rsp), %r8d
callq 0x12980
jmp 0xdb63
jmp 0xdb65
movl 0x228(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x228(%rsp)
jmp 0xdac0
jmp 0xdb7d
movl 0x22c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x22c(%rsp)
jmp 0xdaa1
jmp 0xdb95
movl 0x230(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x230(%rsp)
jmp 0xda82
movq 0x2640e(%rip), %rdi     # 0x33fc0
leaq 0x1ac75(%rip), %rsi     # 0x2882e
callq 0x3290
movq %rax, 0x88(%rsp)
jmp 0xdbc8
movq 0x88(%rsp), %rdi
movq 0x263c9(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xdbde
movl 0x2d8(%rsp), %eax
incl %eax
cltq
movq %rax, 0x78(%rsp)
leaq 0x207(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x12e80
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
leaq 0x208(%rsp), %rdi
callq 0x12e90
jmp 0xdc1f
leaq 0x207(%rsp), %rdi
callq 0x12f10
movl $0x0, 0x200(%rsp)
movl 0x200(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xdd6a
movl $0x0, 0x1fc(%rsp)
movl 0x1fc(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xdd52
movl $0x0, 0x1f8(%rsp)
movl 0x1f8(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xdd3a
movq 0x428(%rsp), %rdi
movslq 0x1f8(%rsp), %rsi
movslq 0x1fc(%rsp), %rdx
movslq 0x200(%rsp), %rcx
callq 0xefc0
movl %eax, 0x74(%rsp)
jmp 0xdcb4
movl 0x74(%rsp), %eax
movslq %eax, %rsi
leaq 0x208(%rsp), %rdi
callq 0x12f20
movq %rax, 0x68(%rsp)
jmp 0xdccf
movq 0x68(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl 0x1f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f8(%rsp)
jmp 0xdc75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
leaq 0x207(%rsp), %rdi
callq 0x12f10
jmp 0xe120
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3d0(%rsp)
movl %eax, 0x3cc(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x12fb0
jmp 0xe120
jmp 0xdd3c
movl 0x1fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1fc(%rsp)
jmp 0xdc56
jmp 0xdd54
movl 0x200(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x200(%rsp)
jmp 0xdc37
movl $0x0, 0x1f4(%rsp)
movl 0x1f4(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xde91
movl $0x0, 0x1f0(%rsp)
movl 0x1f0(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xde79
movl $0x0, 0x1ec(%rsp)
movl 0x1ec(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xde61
movq 0x428(%rsp), %rdi
movslq 0x1ec(%rsp), %rsi
movslq 0x1f0(%rsp), %rdx
movslq 0x1f4(%rsp), %rcx
callq 0xefc0
movl %eax, 0x64(%rsp)
jmp 0xddf2
movl 0x64(%rsp), %eax
movslq %eax, %rsi
leaq 0x208(%rsp), %rdi
callq 0x12f20
movq %rax, 0x58(%rsp)
jmp 0xde0d
movq 0x58(%rsp), %rax
movl (%rax), %eax
cmpl 0x414(%rsp), %eax
jge 0xde49
movq 0x428(%rsp), %rdi
movslq 0x1ec(%rsp), %rsi
movslq 0x1f0(%rsp), %rdx
movslq 0x1f4(%rsp), %rcx
xorl %r8d, %r8d
callq 0x12980
jmp 0xde47
jmp 0xde49
jmp 0xde4b
movl 0x1ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ec(%rsp)
jmp 0xddb3
jmp 0xde63
movl 0x1f0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f0(%rsp)
jmp 0xdd94
jmp 0xde7b
movl 0x1f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1f4(%rsp)
jmp 0xdd75
movq 0x430(%rsp), %rsi
leaq 0x388(%rsp), %rdi
callq 0x18420
jmp 0xdea8
leaq 0x388(%rsp), %rdi
movl $0x3, %esi
callq 0x18470
jmp 0xdebc
leaq 0x388(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0x155e0
jmp 0xded3
movl $0x0, 0x1e8(%rsp)
movl $0x0, 0x1e4(%rsp)
movl 0x1e4(%rsp), %eax
cmpl 0x408(%rsp), %eax
je 0xe090
movl $0x0, 0x1e0(%rsp)
movl 0x1e0(%rsp), %eax
cmpl 0x40c(%rsp), %eax
je 0xe078
movl $0x0, 0x1dc(%rsp)
movl 0x1dc(%rsp), %eax
cmpl 0x410(%rsp), %eax
je 0xe060
movq 0x430(%rsp), %rdi
movslq 0x1dc(%rsp), %rsi
movslq 0x1e0(%rsp), %rdx
movslq 0x1e4(%rsp), %rcx
callq 0x13b70
movb %al, 0x57(%rsp)
jmp 0xdf66
movb 0x57(%rsp), %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xe048
movq 0x428(%rsp), %rdi
movslq 0x1dc(%rsp), %rsi
movslq 0x1e0(%rsp), %rdx
movslq 0x1e4(%rsp), %rcx
callq 0xefc0
movl %eax, 0x50(%rsp)
jmp 0xdfa1
movl 0x50(%rsp), %eax
cmpl $0x0, %eax
jne 0xe048
movq 0x428(%rsp), %r10
movq %r10, 0x28(%rsp)
movslq 0x1dc(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movslq 0x1e0(%rsp), %r8
movq %r8, 0x38(%rsp)
movslq 0x1e4(%rsp), %r9
movq %r9, 0x40(%rsp)
movslq 0x410(%rsp), %rdi
movslq 0x40c(%rsp), %rsi
movslq 0x408(%rsp), %rdx
movq %rsp, %rax
leaq 0x3d8(%rsp), %r11
movq %r11, 0x8(%rax)
movq %r10, (%rax)
callq 0x18990
movl %eax, 0x4c(%rsp)
jmp 0xe017
movl 0x4c(%rsp), %r8d
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x12980
jmp 0xe037
movl 0x1e8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e8(%rsp)
jmp 0xe04a
movl 0x1dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1dc(%rsp)
jmp 0xdf27
jmp 0xe062
movl 0x1e0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e0(%rsp)
jmp 0xdf08
jmp 0xe07a
movl 0x1e4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1e4(%rsp)
jmp 0xdee9
movq 0x25f29(%rip), %rdi     # 0x33fc0
leaq 0x1a7b2(%rip), %rsi     # 0x28850
callq 0x3290
movq %rax, 0x20(%rsp)
jmp 0xe0aa
movq 0x20(%rsp), %rdi
movl 0x1e8(%rsp), %esi
callq 0x3470
movq %rax, 0x18(%rsp)
jmp 0xe0c2
movq 0x18(%rsp), %rdi
movq 0x25ed2(%rip), %rsi     # 0x33fa0
callq 0x32c0
jmp 0xe0d5
leaq 0x3d8(%rsp), %rdi
callq 0x18e40
jmp 0xe0e4
leaq 0x208(%rsp), %rdi
callq 0x12fb0
leaq 0x2e0(%rsp), %rdi
callq 0x12fb0
leaq 0x388(%rsp), %rdi
callq 0xfda0
leaq 0x3d8(%rsp), %rdi
callq 0x18e80
addq $0x438, %rsp            # imm = 0x438
retq
leaq 0x2e0(%rsp), %rdi
callq 0x12fb0
leaq 0x388(%rsp), %rdi
callq 0xfda0
leaq 0x3d8(%rsp), %rdi
callq 0x18e80
movq 0x3d0(%rsp), %rdi
callq 0x34a0
nopw %cs:(%rax,%rax)
nop