void GradientModulus3D_tensor3D(
    float *gradient_modulus, float *derivative_along_X1,
    float *derivative_along_Y1, float *derivative_along_Z1,
    float *derivative_along_X2, float *derivative_along_Y2,
    float *derivative_along_Z2, float *derivative_along_X3,
    float *derivative_along_Y3, float *derivative_along_Z3, int length,
    int type, int is_trace) {
  register int i;
  register float *norme = gradient_modulus;
  register float *gx1 = derivative_along_X1;
  register float *gy1 = derivative_along_Y1;
  register float *gz1 = derivative_along_Z1;
  register float *gx2 = derivative_along_X2;
  register float *gy2 = derivative_along_Y2;
  register float *gz2 = derivative_along_Z2;
  register float *gx3 = derivative_along_X3;
  register float *gy3 = derivative_along_Y3;
  register float *gz3 = derivative_along_Z3;
  register int index_max_vp, index_min_vp;
  register float min;
  register float trace;
  float **wt_tensor;
  float **v;
  float *w;
  double *rv1;
  {
    int z;
    wt_tensor = (float **)malloc(3 * sizeof(float *));
    for (z = 0; z < 3; z++)
      wt_tensor[z] = (float *)malloc(3 * sizeof(float));
    v = (float **)malloc(3 * sizeof(float *));
    for (z = 0; z < 3; z++)
      v[z] = (float *)malloc(3 * sizeof(float));
    w = (float *)malloc(3 * sizeof(float));
    rv1 = (double *)malloc(3 * sizeof(double));
  }
  for (i = 0; i < length; i++, norme++, gx1++, gy1++, gz1++, gx2++, gy2++,
      gz2++, gx3++, gy3++, gz3++) {
    wt_tensor[0][0] = *gx1;
    wt_tensor[0][1] = *gx2;
    wt_tensor[0][2] = *gx3;
    wt_tensor[1][0] = *gy1;
    wt_tensor[1][1] = *gy2;
    wt_tensor[1][2] = *gy3;
    wt_tensor[2][0] = *gz1;
    wt_tensor[2][1] = *gz2;
    wt_tensor[2][2] = *gz3;
    dsvd(wt_tensor, 3, 3, w, v, rv1);
    if (type == 1) {
      if (w[0] > w[1]) {
        *norme = w[0];
        index_max_vp = 0;
        min = w[1];
        index_min_vp = 1;
      } else {
        *norme = w[1];
        index_max_vp = 1;
        min = w[0];
        index_min_vp = 0;
      }
      if (w[2] > (*norme)) {
        *norme = w[2];
        index_max_vp = 2;
      }
      if (w[2] < min) {
        min = w[2];
        index_min_vp = 2;
      }
    } else {
      if (w[0] < w[1]) {
        *norme = w[0];
        index_max_vp = 0;
      } else {
        *norme = w[1];
        index_max_vp = 1;
      }
      if (w[2] < (*norme)) {
        *norme = w[2];
        index_max_vp = 2;
      }
    }
    if (is_trace == 1) {
      trace = w[0] + w[1] + w[2];
      *norme = trace;
    }
    *gx1 = (*norme) * wt_tensor[0][index_max_vp];
    *gy1 = (*norme) * wt_tensor[1][index_max_vp];
    *gz1 = (*norme) * wt_tensor[2][index_max_vp];
  }
  {
    int z;
    for (z = 0; z < 3; z++) {
      free((void *)wt_tensor[z]);
      free((void *)v[z]);
    }
    free(w);
    free(rv1);
  }
}


x86 assembly (clang, -O0):
<GradientModulus3D_tensor3D>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0xbc(%rbp)
cmpl   $0x3,-0xbc(%rbp)
jge    121a <GradientModulus3D_tensor3D+0xea>
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0xa0(%rbp),%rax
movslq -0xbc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    11da <GradientModulus3D_tensor3D+0xaa>
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0xa8(%rbp)
movl   $0x0,-0xbc(%rbp)
cmpl   $0x3,-0xbc(%rbp)
jge    1275 <GradientModulus3D_tensor3D+0x145>
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0xa8(%rbp),%rax
movslq -0xbc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    1235 <GradientModulus3D_tensor3D+0x105>
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,-0xb0(%rbp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,-0xb8(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x30(%rbp),%eax
jge    16a6 <GradientModulus3D_tensor3D+0x576>
mov    -0x48(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,(%rax)
mov    -0x60(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x4(%rax)
mov    -0x78(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    (%rax),%rax
movss  %xmm0,0x8(%rax)
mov    -0x50(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%rax
movss  %xmm0,(%rax)
mov    -0x68(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%rax
movss  %xmm0,0x4(%rax)
mov    -0x80(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%rax
movss  %xmm0,0x8(%rax)
mov    -0x58(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x10(%rax),%rax
movss  %xmm0,(%rax)
mov    -0x70(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x10(%rax),%rax
movss  %xmm0,0x4(%rax)
mov    -0x88(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x10(%rax),%rax
movss  %xmm0,0x8(%rax)
mov    -0xa0(%rbp),%rdi
mov    -0xb0(%rbp),%rcx
mov    -0xa8(%rbp),%r8
mov    -0xb8(%rbp),%r9
mov    $0x3,%edx
mov    %edx,%esi
mov    $0x0,%al
call   1050 <dsvd@plt>
cmpl   $0x1,0x38(%rbp)
jne    14c1 <GradientModulus3D_tensor3D+0x391>
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xb0(%rbp),%rax
ucomiss 0x4(%rax),%xmm0
jbe    140f <GradientModulus3D_tensor3D+0x2df>
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x8c(%rbp)
mov    -0xb0(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x94(%rbp)
ff
movl   $0x1,-0x90(%rbp)
jmp    144a <GradientModulus3D_tensor3D+0x31a>
mov    -0xb0(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x8c(%rbp)
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x94(%rbp)
ff
movl   $0x0,-0x90(%rbp)
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x40(%rbp),%rax
ucomiss (%rax),%xmm0
jbe    1481 <GradientModulus3D_tensor3D+0x351>
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x2,-0x8c(%rbp)
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm1
movss  -0x94(%rbp),%xmm0
ff
ucomiss %xmm1,%xmm0
jbe    14bc <GradientModulus3D_tensor3D+0x38c>
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x94(%rbp)
ff
movl   $0x2,-0x90(%rbp)
jmp    1561 <GradientModulus3D_tensor3D+0x431>
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm1
mov    -0xb0(%rbp),%rax
movss  0x4(%rax),%xmm0
ucomiss %xmm1,%xmm0
jbe    1503 <GradientModulus3D_tensor3D+0x3d3>
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x8c(%rbp)
jmp    1521 <GradientModulus3D_tensor3D+0x3f1>
mov    -0xb0(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x8c(%rbp)
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x40(%rbp),%rax
movss  (%rax),%xmm0
ucomiss %xmm1,%xmm0
jbe    155c <GradientModulus3D_tensor3D+0x42c>
mov    -0xb0(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x2,-0x8c(%rbp)
jmp    1561 <GradientModulus3D_tensor3D+0x431>
cmpl   $0x1,0x40(%rbp)
jne    15a6 <GradientModulus3D_tensor3D+0x476>
mov    -0xb0(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xb0(%rbp),%rax
addss  0x4(%rax),%xmm0
mov    -0xb0(%rbp),%rax
addss  0x8(%rax),%xmm0
movss  %xmm0,-0x98(%rbp)
ff
movss  -0x98(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    (%rax),%rax
movslq -0x8c(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
mov    -0x48(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x8c(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
mov    -0x50(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movss  (%rax),%xmm0
mov    -0xa0(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x8c(%rbp),%rcx
mulss  (%rax,%rcx,4),%xmm0
mov    -0x58(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x58(%rbp)
mov    -0x60(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x68(%rbp)
mov    -0x70(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x78(%rbp)
mov    -0x80(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x88(%rbp)
jmp    129e <GradientModulus3D_tensor3D+0x16e>
movl   $0x0,-0xc0(%rbp)
cmpl   $0x3,-0xc0(%rbp)
jge    16ff <GradientModulus3D_tensor3D+0x5cf>
mov    -0xa0(%rbp),%rax
movslq -0xc0(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0xa8(%rbp),%rax
movslq -0xc0(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc0(%rbp)
jmp    16b0 <GradientModulus3D_tensor3D+0x580>
mov    -0xb0(%rbp),%rdi
call   1030 <free@plt>
mov    -0xb8(%rbp),%rdi
call   1030 <free@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GradientModulus3D_tensor3D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,0x70(%rsp)
mov    %r8,0x68(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x28(%rsp)
mov    0xe0(%rsp),%eax
mov    %eax,0x24(%rsp)
mov    0xd8(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    0xd0(%rsp),%r14d
mov    0xc8(%rsp),%rax
mov    %rax,0x60(%rsp)
mov    0xc0(%rsp),%rax
mov    %rax,0x58(%rsp)
mov    0xb8(%rsp),%rax
mov    %rax,0x50(%rsp)
mov    0xb0(%rsp),%rax
mov    %rax,0x48(%rsp)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rax,(%rbx)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %rax,0x8(%rbx)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
mov    %rax,0x10(%rbx)
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%r15)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %r15,0x38(%rsp)
mov    %rax,0x10(%r15)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0x18,%edi
call   1040 <malloc@plt>
mov    %rax,0x30(%rsp)
test   %r14d,%r14d
jle    1418 <GradientModulus3D_tensor3D+0x2e8>
mov    %r14d,%eax
mov    %rax,0x40(%rsp)
xor    %r14d,%r14d
mov    0x8(%rsp),%rcx
mov    0x18(%rsp),%rdx
mov    0x10(%rsp),%rsi
jmp    12bb <GradientModulus3D_tensor3D+0x18b>
nopl   0x0(%rax)
mov    (%rbx),%r12
mulss  (%r12,%rax,4),%xmm3
movss  %xmm3,(%rsi,%r14,4)
movss  (%rdi,%r14,4),%xmm0
mov    0x8(%rbx),%r13
mulss  0x0(%r13,%rax,4),%xmm0
movss  %xmm0,(%rdx,%r14,4)
movss  (%rdi,%r14,4),%xmm0
mov    0x10(%rbx),%rbp
mulss  0x0(%rbp,%rax,4),%xmm0
movss  %xmm0,(%rcx,%r14,4)
add    $0x1,%r14
cmp    %r14d,0x40(%rsp)
je     1418 <GradientModulus3D_tensor3D+0x2e8>
movss  (%rsi,%r14,4),%xmm0
movss  %xmm0,(%r12)
mov    0x68(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x4(%r12)
mov    0x50(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x8(%r12)
movss  (%rdx,%r14,4),%xmm0
movss  %xmm0,0x0(%r13)
mov    0x70(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x4(%r13)
mov    0x58(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x8(%r13)
movss  (%rcx,%r14,4),%xmm0
movss  %xmm0,0x0(%rbp)
mov    0x48(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x4(%rbp)
mov    0x60(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
movss  %xmm0,0x8(%rbp)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %r15,%rcx
mov    0x38(%rsp),%r8
mov    0x30(%rsp),%r9
xor    %eax,%eax
call   1050 <dsvd@plt>
movss  (%r15),%xmm0
movss  0x4(%r15),%xmm1
cmpl   $0x1,0x20(%rsp)
jne    13a0 <GradientModulus3D_tensor3D+0x270>
xor    %eax,%eax
ucomiss %xmm1,%xmm0
setbe  %cl
movaps %xmm0,%xmm3
maxss  %xmm1,%xmm3
mov    0x28(%rsp),%rdi
movss  %xmm3,(%rdi,%r14,4)
movss  0x8(%r15),%xmm2
ucomiss %xmm3,%xmm2
jmp    13c3 <GradientModulus3D_tensor3D+0x293>
nopl   0x0(%rax)
xor    %eax,%eax
ucomiss %xmm0,%xmm1
setbe  %cl
movaps %xmm0,%xmm3
minss  %xmm1,%xmm3
mov    0x28(%rsp),%rdi
movss  %xmm3,(%rdi,%r14,4)
movss  0x8(%r15),%xmm2
ucomiss %xmm2,%xmm3
mov    0x18(%rsp),%rdx
mov    0x10(%rsp),%rsi
jbe    13f0 <GradientModulus3D_tensor3D+0x2c0>
mov    0x8(%rsp),%rcx
movss  %xmm2,(%rdi,%r14,4)
mov    $0x2,%eax
movaps %xmm2,%xmm3
cmpl   $0x1,0x24(%rsp)
jne    1270 <GradientModulus3D_tensor3D+0x140>
jmp    1402 <GradientModulus3D_tensor3D+0x2d2>
nop
mov    %cl,%al
mov    0x8(%rsp),%rcx
cmpl   $0x1,0x24(%rsp)
jne    1270 <GradientModulus3D_tensor3D+0x140>
addss  %xmm1,%xmm0
addss  %xmm2,%xmm0
movss  %xmm0,(%rdi,%r14,4)
movaps %xmm0,%xmm3
jmp    1270 <GradientModulus3D_tensor3D+0x140>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rbp
mov    0x0(%rbp),%rdi
call   1030 <free@plt>
mov    0x8(%rbx),%rdi
call   1030 <free@plt>
mov    0x8(%rbp),%rdi
call   1030 <free@plt>
mov    0x10(%rbx),%rdi
call   1030 <free@plt>
mov    0x10(%rbp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @GradientModulus3D_tensor3D(float* %0, float* %1, float* %2, float* %3, float* %4, float* %5, float* %6, float* %7, float* %8, float* %9, i32 %10, i32 %11, i32 %12) {
%14 = alloca float*
%15 = alloca float*
%16 = alloca float*
%17 = alloca float*
%18 = alloca float*
%19 = alloca float*
%20 = alloca float*
%21 = alloca float*
%22 = alloca float*
%23 = alloca float*
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca float*
%29 = alloca float*
%30 = alloca float*
%31 = alloca float*
%32 = alloca float*
%33 = alloca float*
%34 = alloca float*
%35 = alloca float*
%36 = alloca float*
%37 = alloca float*
%38 = alloca i32
%39 = alloca i32
%40 = alloca float
%41 = alloca float
%42 = alloca float**
%43 = alloca float**
%44 = alloca float*
%45 = alloca double*
%46 = alloca i32
%47 = alloca i32
store float* %0, float** %14
store float* %1, float** %15
store float* %2, float** %16
store float* %3, float** %17
store float* %4, float** %18
store float* %5, float** %19
store float* %6, float** %20
store float* %7, float** %21
store float* %8, float** %22
store float* %9, float** %23
store i32 %10, i32* %24
store i32 %11, i32* %25
store i32 %12, i32* %26
%48 = load float*, float** %14
store float* %48, float** %28
%49 = load float*, float** %15
store float* %49, float** %29
%50 = load float*, float** %16
store float* %50, float** %30
%51 = load float*, float** %17
store float* %51, float** %31
%52 = load float*, float** %18
store float* %52, float** %32
%53 = load float*, float** %19
store float* %53, float** %33
%54 = load float*, float** %20
store float* %54, float** %34
%55 = load float*, float** %21
store float* %55, float** %35
%56 = load float*, float** %22
store float* %56, float** %36
%57 = load float*, float** %23
store float* %57, float** %37
%58 = call i8* @malloc(i64 24)
%59 = bitcast i8* %58 to float**
store float** %59, float*** %42
store i32 0, i32* %46
br label %60
60: ; preds = %70, %13
%61 = load i32, i32* %46
%62 = icmp slt i32 %61, 3
br i1 %62, label %63, label %73
63: ; preds = %60
%64 = call i8* @malloc(i64 12)
%65 = bitcast i8* %64 to float*
%66 = load float**, float*** %42
%67 = load i32, i32* %46
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds float*, float** %66, i64 %68
store float* %65, float** %69
br label %70
70: ; preds = %63
%71 = load i32, i32* %46
%72 = add nsw i32 %71, 1
store i32 %72, i32* %46
br label %60
73: ; preds = %60
%74 = call i8* @malloc(i64 24)
%75 = bitcast i8* %74 to float**
store float** %75, float*** %43
store i32 0, i32* %46
br label %76
76: ; preds = %86, %73
%77 = load i32, i32* %46
%78 = icmp slt i32 %77, 3
br i1 %78, label %79, label %89
79: ; preds = %76
%80 = call i8* @malloc(i64 12)
%81 = bitcast i8* %80 to float*
%82 = load float**, float*** %43
%83 = load i32, i32* %46
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float*, float** %82, i64 %84
store float* %81, float** %85
br label %86
86: ; preds = %79
%87 = load i32, i32* %46
%88 = add nsw i32 %87, 1
store i32 %88, i32* %46
br label %76
89: ; preds = %76
%90 = call i8* @malloc(i64 12)
%91 = bitcast i8* %90 to float*
store float* %91, float** %44
%92 = call i8* @malloc(i64 24)
%93 = bitcast i8* %92 to double*
store double* %93, double** %45
store i32 0, i32* %27
br label %94
94: ; preds = %289, %89
%95 = load i32, i32* %27
%96 = load i32, i32* %24
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %312
98: ; preds = %94
%99 = load float*, float** %29
%100 = load float, float* %99
%101 = load float**, float*** %42
%102 = getelementptr inbounds float*, float** %101, i64 0
%103 = load float*, float** %102
%104 = getelementptr inbounds float, float* %103, i64 0
store float %100, float* %104
%105 = load float*, float** %32
%106 = load float, float* %105
%107 = load float**, float*** %42
%108 = getelementptr inbounds float*, float** %107, i64 0
%109 = load float*, float** %108
%110 = getelementptr inbounds float, float* %109, i64 1
store float %106, float* %110
%111 = load float*, float** %35
%112 = load float, float* %111
%113 = load float**, float*** %42
%114 = getelementptr inbounds float*, float** %113, i64 0
%115 = load float*, float** %114
%116 = getelementptr inbounds float, float* %115, i64 2
store float %112, float* %116
%117 = load float*, float** %30
%118 = load float, float* %117
%119 = load float**, float*** %42
%120 = getelementptr inbounds float*, float** %119, i64 1
%121 = load float*, float** %120
%122 = getelementptr inbounds float, float* %121, i64 0
store float %118, float* %122
%123 = load float*, float** %33
%124 = load float, float* %123
%125 = load float**, float*** %42
%126 = getelementptr inbounds float*, float** %125, i64 1
%127 = load float*, float** %126
%128 = getelementptr inbounds float, float* %127, i64 1
store float %124, float* %128
%129 = load float*, float** %36
%130 = load float, float* %129
%131 = load float**, float*** %42
%132 = getelementptr inbounds float*, float** %131, i64 1
%133 = load float*, float** %132
%134 = getelementptr inbounds float, float* %133, i64 2
store float %130, float* %134
%135 = load float*, float** %31
%136 = load float, float* %135
%137 = load float**, float*** %42
%138 = getelementptr inbounds float*, float** %137, i64 2
%139 = load float*, float** %138
%140 = getelementptr inbounds float, float* %139, i64 0
store float %136, float* %140
%141 = load float*, float** %34
%142 = load float, float* %141
%143 = load float**, float*** %42
%144 = getelementptr inbounds float*, float** %143, i64 2
%145 = load float*, float** %144
%146 = getelementptr inbounds float, float* %145, i64 1
store float %142, float* %146
%147 = load float*, float** %37
%148 = load float, float* %147
%149 = load float**, float*** %42
%150 = getelementptr inbounds float*, float** %149, i64 2
%151 = load float*, float** %150
%152 = getelementptr inbounds float, float* %151, i64 2
store float %148, float* %152
%153 = load float**, float*** %42
%154 = load float*, float** %44
%155 = load float**, float*** %43
%156 = load double*, double** %45
%157 = call i32 (float**, i32, i32, float*, float**, double*, ...) bitcast (i32 (...)* @dsvd to i32 (float**, i32, i32, float*, float**, double*, ...)*)(float** %153, i32 3, i32 3, float* %154, float** %155, double* %156)
%158 = load i32, i32* %25
%159 = icmp eq i32 %158, 1
br i1 %159, label %160, label %207
160: ; preds = %98
%161 = load float*, float** %44
%162 = getelementptr inbounds float, float* %161, i64 0
%163 = load float, float* %162
%164 = load float*, float** %44
%165 = getelementptr inbounds float, float* %164, i64 1
%166 = load float, float* %165
%167 = fcmp ogt float %163, %166
br i1 %167, label %168, label %176
168: ; preds = %160
%169 = load float*, float** %44
%170 = getelementptr inbounds float, float* %169, i64 0
%171 = load float, float* %170
%172 = load float*, float** %28
store float %171, float* %172
store i32 0, i32* %38
%173 = load float*, float** %44
%174 = getelementptr inbounds float, float* %173, i64 1
%175 = load float, float* %174
store float %175, float* %40
store i32 1, i32* %39
br label %184
176: ; preds = %160
%177 = load float*, float** %44
%178 = getelementptr inbounds float, float* %177, i64 1
%179 = load float, float* %178
%180 = load float*, float** %28
store float %179, float* %180
store i32 1, i32* %38
%181 = load float*, float** %44
%182 = getelementptr inbounds float, float* %181, i64 0
%183 = load float, float* %182
store float %183, float* %40
store i32 0, i32* %39
br label %184
184: ; preds = %176, %168
%185 = load float*, float** %44
%186 = getelementptr inbounds float, float* %185, i64 2
%187 = load float, float* %186
%188 = load float*, float** %28
%189 = load float, float* %188
%190 = fcmp ogt float %187, %189
br i1 %190, label %191, label %196
191: ; preds = %184
%192 = load float*, float** %44
%193 = getelementptr inbounds float, float* %192, i64 2
%194 = load float, float* %193
%195 = load float*, float** %28
store float %194, float* %195
store i32 2, i32* %38
br label %196
196: ; preds = %191, %184
%197 = load float*, float** %44
%198 = getelementptr inbounds float, float* %197, i64 2
%199 = load float, float* %198
%200 = load float, float* %40
%201 = fcmp olt float %199, %200
br i1 %201, label %202, label %206
202: ; preds = %196
%203 = load float*, float** %44
%204 = getelementptr inbounds float, float* %203, i64 2
%205 = load float, float* %204
store float %205, float* %40
store i32 2, i32* %39
br label %206
206: ; preds = %202, %196
br label %238
207: ; preds = %98
%208 = load float*, float** %44
%209 = getelementptr inbounds float, float* %208, i64 0
%210 = load float, float* %209
%211 = load float*, float** %44
%212 = getelementptr inbounds float, float* %211, i64 1
%213 = load float, float* %212
%214 = fcmp olt float %210, %213
br i1 %214, label %215, label %220
215: ; preds = %207
%216 = load float*, float** %44
%217 = getelementptr inbounds float, float* %216, i64 0
%218 = load float, float* %217
%219 = load float*, float** %28
store float %218, float* %219
store i32 0, i32* %38
br label %225
220: ; preds = %207
%221 = load float*, float** %44
%222 = getelementptr inbounds float, float* %221, i64 1
%223 = load float, float* %222
%224 = load float*, float** %28
store float %223, float* %224
store i32 1, i32* %38
br label %225
225: ; preds = %220, %215
%226 = load float*, float** %44
%227 = getelementptr inbounds float, float* %226, i64 2
%228 = load float, float* %227
%229 = load float*, float** %28
%230 = load float, float* %229
%231 = fcmp olt float %228, %230
br i1 %231, label %232, label %237
232: ; preds = %225
%233 = load float*, float** %44
%234 = getelementptr inbounds float, float* %233, i64 2
%235 = load float, float* %234
%236 = load float*, float** %28
store float %235, float* %236
store i32 2, i32* %38
br label %237
237: ; preds = %232, %225
br label %238
238: ; preds = %237, %206
%239 = load i32, i32* %26
%240 = icmp eq i32 %239, 1
br i1 %240, label %241, label %255
241: ; preds = %238
%242 = load float*, float** %44
%243 = getelementptr inbounds float, float* %242, i64 0
%244 = load float, float* %243
%245 = load float*, float** %44
%246 = getelementptr inbounds float, float* %245, i64 1
%247 = load float, float* %246
%248 = fadd float %244, %247
%249 = load float*, float** %44
%250 = getelementptr inbounds float, float* %249, i64 2
%251 = load float, float* %250
%252 = fadd float %248, %251
store float %252, float* %41
%253 = load float, float* %41
%254 = load float*, float** %28
store float %253, float* %254
br label %255
255: ; preds = %241, %238
%256 = load float*, float** %28
%257 = load float, float* %256
%258 = load float**, float*** %42
%259 = getelementptr inbounds float*, float** %258, i64 0
%260 = load float*, float** %259
%261 = load i32, i32* %38
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds float, float* %260, i64 %262
%264 = load float, float* %263
%265 = fmul float %257, %264
%266 = load float*, float** %29
store float %265, float* %266
%267 = load float*, float** %28
%268 = load float, float* %267
%269 = load float**, float*** %42
%270 = getelementptr inbounds float*, float** %269, i64 1
%271 = load float*, float** %270
%272 = load i32, i32* %38
%273 = sext i32 %272 to i64
%274 = getelementptr inbounds float, float* %271, i64 %273
%275 = load float, float* %274
%276 = fmul float %268, %275
%277 = load float*, float** %30
store float %276, float* %277
%278 = load float*, float** %28
%279 = load float, float* %278
%280 = load float**, float*** %42
%281 = getelementptr inbounds float*, float** %280, i64 2
%282 = load float*, float** %281
%283 = load i32, i32* %38
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds float, float* %282, i64 %284
%286 = load float, float* %285
%287 = fmul float %279, %286
%288 = load float*, float** %31
store float %287, float* %288
br label %289
289: ; preds = %255
%290 = load i32, i32* %27
%291 = add nsw i32 %290, 1
store i32 %291, i32* %27
%292 = load float*, float** %28
%293 = getelementptr inbounds float, float* %292, i32 1
store float* %293, float** %28
%294 = load float*, float** %29
%295 = getelementptr inbounds float, float* %294, i32 1
store float* %295, float** %29
%296 = load float*, float** %30
%297 = getelementptr inbounds float, float* %296, i32 1
store float* %297, float** %30
%298 = load float*, float** %31
%299 = getelementptr inbounds float, float* %298, i32 1
store float* %299, float** %31
%300 = load float*, float** %32
%301 = getelementptr inbounds float, float* %300, i32 1
store float* %301, float** %32
%302 = load float*, float** %33
%303 = getelementptr inbounds float, float* %302, i32 1
store float* %303, float** %33
%304 = load float*, float** %34
%305 = getelementptr inbounds float, float* %304, i32 1
store float* %305, float** %34
%306 = load float*, float** %35
%307 = getelementptr inbounds float, float* %306, i32 1
store float* %307, float** %35
%308 = load float*, float** %36
%309 = getelementptr inbounds float, float* %308, i32 1
store float* %309, float** %36
%310 = load float*, float** %37
%311 = getelementptr inbounds float, float* %310, i32 1
store float* %311, float** %37
br label %94
312: ; preds = %94
store i32 0, i32* %47
br label %313
313: ; preds = %329, %312
%314 = load i32, i32* %47
%315 = icmp slt i32 %314, 3
br i1 %315, label %316, label %332
316: ; preds = %313
%317 = load float**, float*** %42
%318 = load i32, i32* %47
%319 = sext i32 %318 to i64
%320 = getelementptr inbounds float*, float** %317, i64 %319
%321 = load float*, float** %320
%322 = bitcast float* %321 to i8*
%323 = load float**, float*** %43
%324 = load i32, i32* %47
%325 = sext i32 %324 to i64
%326 = getelementptr inbounds float*, float** %323, i64 %325
%327 = load float*, float** %326
%328 = bitcast float* %327 to i8*
br label %329
329: ; preds = %316
%330 = load i32, i32* %47
%331 = add nsw i32 %330, 1
store i32 %331, i32* %47
br label %313
332: ; preds = %313
%333 = load float*, float** %44
%334 = bitcast float* %333 to i8*
%335 = load double*, double** %45
%336 = bitcast double* %335 to i8*
ret void
}

LLVM IR (-O2):
define void @GradientModulus3D_tensor3D(float* nocapture %0, float* nocapture %1, float* nocapture %2, float* nocapture %3, float* nocapture %4, float* nocapture %5, float* nocapture %6, float* nocapture %7, float* nocapture %8, float* nocapture %9, i32 %10, i32 %11, i32 %12) {
%14 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%15 = bitcast i8* %14 to float**
%16 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%17 = bitcast i8* %14 to i8**
store i8* %16, i8** %17
%18 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%19 = getelementptr inbounds float*, float** %15, i64 1
%20 = bitcast float** %19 to i8**
store i8* %18, i8** %20
%21 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%22 = getelementptr inbounds float*, float** %15, i64 2
%23 = bitcast float** %22 to i8**
store i8* %21, i8** %23
%24 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%25 = bitcast i8* %24 to float**
%26 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%27 = bitcast i8* %24 to i8**
store i8* %26, i8** %27
%28 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%29 = getelementptr inbounds float*, float** %25, i64 1
%30 = bitcast float** %29 to i8**
store i8* %28, i8** %30
%31 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%32 = getelementptr inbounds float*, float** %25, i64 2
%33 = bitcast float** %32 to i8**
store i8* %31, i8** %33
%34 = tail call dereferenceable_or_null(12) i8* @malloc(i64 12)
%35 = bitcast i8* %34 to float*
%36 = tail call dereferenceable_or_null(24) i8* @malloc(i64 24)
%37 = bitcast i8* %36 to double*
%38 = icmp sgt i32 %10, 0
br i1 %38, label %39, label %49
39: ; preds = %13
%40 = bitcast i8* %21 to float*
%41 = bitcast i8* %18 to float*
%42 = bitcast i8* %16 to float*
%43 = icmp eq i32 %11, 1
%44 = getelementptr inbounds float, float* %35, i64 1
%45 = getelementptr inbounds float, float* %35, i64 2
%46 = icmp eq i32 %12, 1
br label %56
47: ; preds = %112
%48 = bitcast float* %114 to i8*
br label %49
49: ; preds = %47, %13
%50 = phi i8* [ %48, %47 ], [ %16, %13 ]
tail call void @free(i8* %50)
%51 = load i8*, i8** %27
tail call void @free(i8* %51)
%52 = load i8*, i8** %20
tail call void @free(i8* %52)
%53 = load i8*, i8** %30
tail call void @free(i8* %53)
%54 = load i8*, i8** %23
tail call void @free(i8* %54)
%55 = load i8*, i8** %33
tail call void @free(i8* %55)
tail call void @free(i8* %34)
tail call void @free(i8* %36)
ret void
56: ; preds = %39, %112
%57 = phi float* [ %40, %39 ], [ %124, %112 ]
%58 = phi float* [ %41, %39 ], [ %119, %112 ]
%59 = phi float* [ %42, %39 ], [ %114, %112 ]
%60 = phi i32 [ 0, %39 ], [ %128, %112 ]
%61 = phi float* [ %0, %39 ], [ %129, %112 ]
%62 = phi float* [ %1, %39 ], [ %130, %112 ]
%63 = phi float* [ %2, %39 ], [ %131, %112 ]
%64 = phi float* [ %3, %39 ], [ %132, %112 ]
%65 = phi float* [ %9, %39 ], [ %138, %112 ]
%66 = phi float* [ %8, %39 ], [ %137, %112 ]
%67 = phi float* [ %7, %39 ], [ %136, %112 ]
%68 = phi float* [ %6, %39 ], [ %135, %112 ]
%69 = phi float* [ %5, %39 ], [ %134, %112 ]
%70 = phi float* [ %4, %39 ], [ %133, %112 ]
%71 = load float, float* %62
store float %71, float* %59
%72 = load float, float* %70
%73 = getelementptr inbounds float, float* %59, i64 1
store float %72, float* %73
%74 = load float, float* %67
%75 = getelementptr inbounds float, float* %59, i64 2
store float %74, float* %75
%76 = load float, float* %63
store float %76, float* %58
%77 = load float, float* %69
%78 = getelementptr inbounds float, float* %58, i64 1
store float %77, float* %78
%79 = load float, float* %66
%80 = getelementptr inbounds float, float* %58, i64 2
store float %79, float* %80
%81 = load float, float* %64
store float %81, float* %57
%82 = load float, float* %68
%83 = getelementptr inbounds float, float* %57, i64 1
store float %82, float* %83
%84 = load float, float* %65
%85 = getelementptr inbounds float, float* %57, i64 2
store float %84, float* %85
%86 = tail call i32 (float**, i32, i32, float*, float**, double*, ...) bitcast (i32 (...)* @dsvd to i32 (float**, i32, i32, float*, float**, double*, ...)*)(float** %15, i32 3, i32 3, float* %35, float** %25, double* %37)
%87 = load float, float* %35
%88 = load float, float* %44
br i1 %43, label %89, label %96
89: ; preds = %56
%90 = fcmp ogt float %87, %88
%91 = select i1 %90, float %87, float %88
%92 = xor i1 %90, true
%93 = zext i1 %92 to i64
store float %91, float* %61
%94 = load float, float* %45
%95 = fcmp ogt float %94, %91
br i1 %95, label %103, label %105
96: ; preds = %56
%97 = fcmp olt float %87, %88
%98 = select i1 %97, float %87, float %88
%99 = xor i1 %97, true
%100 = zext i1 %99 to i64
store float %98, float* %61
%101 = load float, float* %45
%102 = fcmp olt float %101, %98
br i1 %102, label %103, label %105
103: ; preds = %96, %89
%104 = phi float [ %94, %89 ], [ %101, %96 ]
store float %104, float* %61
br label %105
105: ; preds = %103, %89, %96
%106 = phi float [ %98, %96 ], [ %91, %89 ], [ %104, %103 ]
%107 = phi float [ %101, %96 ], [ %94, %89 ], [ %104, %103 ]
%108 = phi i64 [ %100, %96 ], [ %93, %89 ], [ 2, %103 ]
br i1 %46, label %109, label %112
109: ; preds = %105
%110 = fadd float %87, %88
%111 = fadd float %110, %107
store float %111, float* %61
br label %112
112: ; preds = %109, %105
%113 = phi float [ %111, %109 ], [ %106, %105 ]
%114 = load float*, float** %15
%115 = getelementptr inbounds float, float* %114, i64 %108
%116 = load float, float* %115
%117 = fmul float %113, %116
store float %117, float* %62
%118 = load float, float* %61
%119 = load float*, float** %19
%120 = getelementptr inbounds float, float* %119, i64 %108
%121 = load float, float* %120
%122 = fmul float %118, %121
store float %122, float* %63
%123 = load float, float* %61
%124 = load float*, float** %22
%125 = getelementptr inbounds float, float* %124, i64 %108
%126 = load float, float* %125
%127 = fmul float %123, %126
store float %127, float* %64
%128 = add nuw nsw i32 %60, 1
%129 = getelementptr inbounds float, float* %61, i64 1
%130 = getelementptr inbounds float, float* %62, i64 1
%131 = getelementptr inbounds float, float* %63, i64 1
%132 = getelementptr inbounds float, float* %64, i64 1
%133 = getelementptr inbounds float, float* %70, i64 1
%134 = getelementptr inbounds float, float* %69, i64 1
%135 = getelementptr inbounds float, float* %68, i64 1
%136 = getelementptr inbounds float, float* %67, i64 1
%137 = getelementptr inbounds float, float* %66, i64 1
%138 = getelementptr inbounds float, float* %65, i64 1
%139 = icmp eq i32 %128, %10
br i1 %139, label %47, label %56
}