// File: spatialfruitsalad[P]volume2position/./edm.hpp
// Function: void edm::create_edm<unsigned char>(tomogram3d<unsigned char>&, tomogram3d<float>&)
static void create_edm(tomogram3d<VALUE>& matrix_in, tomogram3d<float>& edm)
    {

        std::cout << "calculating edm ... " << std::flush;

        int sx = matrix_in.get_sx();
        int sy = matrix_in.get_sy();
        int sz = matrix_in.get_sz();

        edm.initialise(sx,sy,sz,-1);

        for (int z = 0; z < sz; z++)
            for (int y = 0; y < sy; y++)
                for (int x = 0; x < sx; x++)
                    edm.set(x,y,z,float(matrix_in.get(x,y,z))*INF);


        float *f = new float[std::max(sx,sz)]; //fixme sy, not quadratic case

        for (int z = 0; z < sz; z++)
        {
            for (int y = 0; y < sy; y++)
            {
                for (int x = 0; x < sx; x++)
                {
                    f[x] = edm.get(x, y, z);
                }
                float *d = dt(f, sx);
                for (int x = 0; x < sx; x++)
                {
                    edm.set (x, y, z, d[x]);
                }
                delete [] d;
            }
        }

        for (int y = 0; y < sy; y++)
        {
            for (int x = 0; x < sx; x++)
            {
                for (int z = 0; z < sz; z++)
                {
                    f[z] = edm.get( x, y, z);
                }
                float *d = dt(f, sz);
                for (int z = 0; z < sz; z++)
                {
                    edm.set (x, y, z, d[z]);
                }
                delete [] d;
            }

        }

        for (int x = 0; x < sx; x++)
        {
            for (int z = 0; z < sz; z++)
            {
                for (int y = 0; y < sy; y++)
                {
                    f[y] = edm.get( x, y, z);
                }
                float *d = dt(f, sy);
                for (int y = 0; y < sy; y++)
                {
                    edm.set (x, y, z, d[y]);
                }
                delete [] d;
            }

        }
        delete []f;
        std::cout << " done" << std::endl;
    }

// Assembly:
subq $0xc8, %rsp
movq %rdi, 0xc0(%rsp)
movq %rsi, 0xb8(%rsp)
movq 0x1e9c2(%rip), %rdi     # 0x33fc0
leaq 0x1325a(%rip), %rsi     # 0x2885f
callq 0x3290
movq %rax, %rdi
movq 0x1e9b4(%rip), %rsi     # 0x33fc8
callq 0x32c0
movq 0xc0(%rsp), %rdi
callq 0x125e0
movl %eax, 0xb4(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x125f0
movl %eax, 0xb0(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x12600
movl %eax, 0xac(%rsp)
movq 0xb8(%rsp), %rdi
movslq 0xb4(%rsp), %rsi
movslq 0xb0(%rsp), %rdx
movslq 0xac(%rsp), %rcx
movss 0x12a8b(%rip), %xmm0    # 0x28108
callq 0x18f20
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x1579a
movl $0x0, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x15782
movl $0x0, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
cmpl 0xb4(%rsp), %eax
jge 0x1576a
movq 0xb8(%rsp), %rax
movq %rax, 0x28(%rsp)
movslq 0xa0(%rsp), %rsi
movq %rsi, 0x30(%rsp)
movslq 0xa4(%rsp), %rdx
movq %rdx, 0x38(%rsp)
movslq 0xa8(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq 0xc0(%rsp), %rdi
callq 0x13b70
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movzbl %al, %eax
cvtsi2ss %eax, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x12921(%rip), %xmm1    # 0x28068
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x15f80
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x156cb
jmp 0x1576c
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x156ac
jmp 0x15784
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x1568d
leaq 0xb4(%rsp), %rdi
leaq 0xac(%rsp), %rsi
callq 0x127b0
movslq (%rax), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3040
movq %rax, 0x98(%rsp)
movl $0x0, 0x94(%rsp)
movl 0x94(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x15941
movl $0x0, 0x90(%rsp)
movl 0x90(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x15929
movl $0x0, 0x8c(%rsp)
movl 0x8c(%rsp), %eax
cmpl 0xb4(%rsp), %eax
jge 0x15881
movq 0xb8(%rsp), %rdi
movslq 0x8c(%rsp), %rsi
movslq 0x90(%rsp), %rdx
movslq 0x94(%rsp), %rcx
callq 0x15be0
movq 0x98(%rsp), %rax
movslq 0x8c(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x15824
movq 0x98(%rsp), %rdi
movl 0xb4(%rsp), %esi
callq 0x19070
movq %rax, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
cmpl 0xb4(%rsp), %eax
jge 0x158f4
movq 0xb8(%rsp), %rdi
movslq 0x7c(%rsp), %rsi
movslq 0x90(%rsp), %rdx
movslq 0x94(%rsp), %rcx
movq 0x80(%rsp), %rax
movslq 0x7c(%rsp), %r8
movss (%rax,%r8,4), %xmm0
callq 0x15f80
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x158a5
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x15911
movq 0x20(%rsp), %rdi
callq 0x3330
jmp 0x15913
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x15805
jmp 0x1592b
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x157e6
movl $0x0, 0x78(%rsp)
movl 0x78(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x15a68
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0xb4(%rsp), %eax
jge 0x15a56
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x159c3
movq 0xb8(%rsp), %rdi
movslq 0x74(%rsp), %rsi
movslq 0x78(%rsp), %rdx
movslq 0x70(%rsp), %rcx
callq 0x15be0
movq 0x98(%rsp), %rax
movslq 0x70(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x1597b
movq 0x98(%rsp), %rdi
movl 0xac(%rsp), %esi
callq 0x19070
movq %rax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x15a2a
movq 0xb8(%rsp), %rdi
movslq 0x74(%rsp), %rsi
movslq 0x78(%rsp), %rdx
movslq 0x64(%rsp), %rcx
movq 0x68(%rsp), %rax
movslq 0x64(%rsp), %r8
movss (%rax,%r8,4), %xmm0
callq 0x15f80
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x159e4
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x15a44
movq 0x18(%rsp), %rdi
callq 0x3330
jmp 0x15a46
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x15962
jmp 0x15a58
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x15949
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
cmpl 0xb4(%rsp), %eax
jge 0x15b8f
movl $0x0, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x15b7d
movl $0x0, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x15aea
movq 0xb8(%rsp), %rdi
movslq 0x60(%rsp), %rsi
movslq 0x58(%rsp), %rdx
movslq 0x5c(%rsp), %rcx
callq 0x15be0
movq 0x98(%rsp), %rax
movslq 0x58(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x15aa2
movq 0x98(%rsp), %rdi
movl 0xb0(%rsp), %esi
callq 0x19070
movq %rax, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x15b51
movq 0xb8(%rsp), %rdi
movslq 0x60(%rsp), %rsi
movslq 0x4c(%rsp), %rdx
movslq 0x5c(%rsp), %rcx
movq 0x50(%rsp), %rax
movslq 0x4c(%rsp), %r8
movss (%rax,%r8,4), %xmm0
callq 0x15f80
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x15b0b
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, %rax
je 0x15b6b
movq 0x10(%rsp), %rdi
callq 0x3330
jmp 0x15b6d
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x15a89
jmp 0x15b7f
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x15a70
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x15bac
movq 0x8(%rsp), %rdi
callq 0x3330
movq 0x1e40d(%rip), %rdi     # 0x33fc0
leaq 0x12c90(%rip), %rsi     # 0x2884a
callq 0x3290
movq %rax, %rdi
movq 0x1e3d7(%rip), %rsi     # 0x33fa0
callq 0x32c0
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)