// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbp
movq 0xdf85(%rip), %rbx      # 0x1cfc8
leaq 0x8898(%rip), %rsi      # 0x178e2
movl $0x14, %edx
movq %rbx, %rdi
callq 0x3300
movq %rbx, %rdi
callq 0x31e0
movq 0x18(%rbp), %rax
movq 0x20(%rbp), %rcx
movq 0x28(%rbp), %rdi
movq %rax, 0x8(%rsp)
movslq %eax, %rsi
movq %rcx, 0x10(%rsp)
movslq %ecx, %rdx
movq %rdi, 0x18(%rsp)
movslq %edi, %rbx
movss 0x80d1(%rip), %xmm0     # 0x1715c
movq %r14, %rdi
movq %rbx, %rcx
callq 0x11c7c
testl %ebx, %ebx
jle 0xf12d
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq 0x18(%rsp), %rax
andq %r15, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
andq %r15, %rax
movq %rax, 0x28(%rsp)
andq 0x8(%rsp), %r15
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
jle 0xf123
xorl %r13d, %r13d
cmpl $0x0, 0x8(%rsp)
jle 0xf119
xorl %r12d, %r12d
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xeaa4
movzbl %al, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x7f74(%rip), %xmm0     # 0x17070
cvtsd2ss %xmm0, %xmm0
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xf774
incq %r12
cmpq %r12, %r15
jne 0xf0d9
incq %r13
cmpq 0x28(%rsp), %r13
jne 0xf0cf
incq %rbx
cmpq 0x20(%rsp), %rbx
jne 0xf0c5
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %rbx
cmpl %ebx, %ecx
movl %ebx, %eax
cmovgl %ecx, %eax
cltq
leaq (,%rax,4), %rcx
testl %eax, %eax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x3030
movq %rax, 0x28(%rsp)
testl %ebx, %ebx
jle 0xf228
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x18(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x20(%rsp)
andq 0x8(%rsp), %rbp
xorl %ebx, %ebx
cmpl $0x0, 0x10(%rsp)
jle 0xf21a
xorl %r13d, %r13d
cmpl $0x0, 0x8(%rsp)
movq 0x28(%rsp), %r15
jle 0xf1c9
xorl %r12d, %r12d
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xf418
movss %xmm0, (%r15,%r12,4)
incq %r12
cmpq %r12, %rbp
jne 0xf1aa
movq %r15, %rdi
movq 0x8(%rsp), %r15
movl %r15d, %esi
callq 0x11de0
movq %rax, %r12
testl %r15d, %r15d
jle 0xf203
xorl %r15d, %r15d
movss (%r12,%r15,4), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xf774
incq %r15
cmpq %r15, %rbp
jne 0xf1e4
testq %r12, %r12
je 0xf210
movq %r12, %rdi
callq 0x3350
incq %r13
cmpq 0x20(%rsp), %r13
jne 0xf19b
incq %rbx
cmpq 0x30(%rsp), %rbx
jne 0xf18d
cmpl $0x0, 0x10(%rsp)
movq 0x28(%rsp), %r12
jle 0xf2f9
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x10(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %rax
andq %rbp, %rax
movq %rax, 0x20(%rsp)
andq 0x18(%rsp), %rbp
xorl %ebx, %ebx
cmpl $0x0, 0x8(%rsp)
jle 0xf2eb
xorl %r13d, %r13d
cmpl $0x0, 0x18(%rsp)
jle 0xf295
xorl %r15d, %r15d
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0xf418
movss %xmm0, (%r12,%r15,4)
incq %r15
cmpq %r15, %rbp
jne 0xf276
movq %r12, %rdi
movq 0x18(%rsp), %r15
movl %r15d, %esi
callq 0x11de0
movq %rax, %r12
testl %r15d, %r15d
jle 0xf2cf
xorl %r15d, %r15d
movss (%r12,%r15,4), %xmm0
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0xf774
incq %r15
cmpq %r15, %rbp
jne 0xf2b0
testq %r12, %r12
je 0xf2dc
movq %r12, %rdi
callq 0x3350
incq %r13
cmpq 0x20(%rsp), %r13
movq 0x28(%rsp), %r12
jne 0xf26c
incq %rbx
cmpq 0x30(%rsp), %rbx
jne 0xf25e
cmpl $0x0, 0x8(%rsp)
jle 0xf3c0
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rcx
andq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rsp), %rbp
andq %rax, %rbp
xorl %ebx, %ebx
cmpl $0x0, 0x18(%rsp)
jle 0xf3b2
xorl %r13d, %r13d
cmpl $0x0, 0x10(%rsp)
jle 0xf35c
xorl %r15d, %r15d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0xf418
movss %xmm0, (%r12,%r15,4)
incq %r15
cmpq %r15, %rbp
jne 0xf33d
movq %r12, %rdi
movq 0x10(%rsp), %r15
movl %r15d, %esi
callq 0x11de0
movq %rax, %r12
testl %r15d, %r15d
jle 0xf396
xorl %r15d, %r15d
movss (%r12,%r15,4), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0xf774
incq %r15
cmpq %r15, %rbp
jne 0xf377
testq %r12, %r12
je 0xf3a3
movq %r12, %rdi
callq 0x3350
incq %r13
cmpq 0x20(%rsp), %r13
movq 0x28(%rsp), %r12
jne 0xf333
incq %rbx
cmpq 0x8(%rsp), %rbx
jne 0xf325
movq %r12, %rdi
callq 0x3350
leaq 0x84fe(%rip), %rsi      # 0x178cd
movl $0x5, %edx
movq 0xdbed(%rip), %rbx      # 0x1cfc8
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
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31e0