void sppdist_sqeuclidean(const double *X, int m, int n, double threshold,
                         int form, double **out_Dx, int **out_Dij,
                         int *out_nzmax) {
  int i, j;
  int nz, nzmax;
  double d;
  const double *x1, *x2;
  int *Dij;
  double *Dx;
  nzmax = 2 * m;
  Dij = realloc(*out_Dij, 2 * nzmax * sizeof(int));
  Dx = realloc(*out_Dx, nzmax * sizeof(double));
  nz = 0;
  for (j = 0; j < m; j++) {
    if ((((form) == 0) || ((form) == 1) || ((form) == 2))) {
      Dij[2 * nz] = j;
      Dij[2 * nz + 1] = j;
      Dx[nz] = 0.0;
      nz++;
      {
        if (nz == nzmax) {
          nzmax *= 2;
          Dij = realloc(Dij, 2 * nzmax * sizeof(int));
          Dx = realloc(Dx, nzmax * sizeof(double));
        }
      };
    }
    for (i = j + 1; i < m; i++) {
      x1 = X + i * n;
      x2 = X + j * n;
      d = sqeuclidean_distance(x1, x2, n);
      if (d <= threshold) {
        if ((((form) == 1) || ((form) == 3) || ((form) == 0))) {
          Dij[2 * nz] = i;
          Dij[2 * nz + 1] = j;
          Dx[nz] = d;
          nz++;
          {
            if (nz == nzmax) {
              nzmax *= 2;
              Dij = realloc(Dij, 2 * nzmax * sizeof(int));
              Dx = realloc(Dx, nzmax * sizeof(double));
            }
          };
        }
        if ((((form) == 2) || ((form) == 4) || ((form) == 0))) {
          Dij[2 * nz] = j;
          Dij[2 * nz + 1] = i;
          Dx[nz] = d;
          nz++;
          {
            if (nz == nzmax) {
              nzmax *= 2;
              Dij = realloc(Dij, 2 * nzmax * sizeof(int));
              Dx = realloc(Dx, nzmax * sizeof(double));
            }
          };
        }
      }
    }
  }
  nzmax = nz;
  Dij = realloc(Dij, 2 * nzmax * sizeof(int));
  Dx = realloc(Dx, nzmax * sizeof(double));
  *out_Dij = Dij;
  *out_Dx = Dx;
  *out_nzmax = nzmax;
  return;
}


x86 assembly (clang, -O0):
<sppdist_sqeuclidean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
movslq -0x40(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    143e <sppdist_sqeuclidean+0x31e>
cmpl   $0x0,-0x1c(%rbp)
je     11bc <sppdist_sqeuclidean+0x9c>
cmpl   $0x1,-0x1c(%rbp)
je     11bc <sppdist_sqeuclidean+0x9c>
cmpl   $0x2,-0x1c(%rbp)
jne    1247 <sppdist_sqeuclidean+0x127>
mov    -0x38(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x68(%rbp),%rax
movslq -0x3c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    1242 <sppdist_sqeuclidean+0x122>
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
movslq -0x40(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x68(%rbp)
jmp    1247 <sppdist_sqeuclidean+0x127>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    142b <sppdist_sqeuclidean+0x30b>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%ecx
imul   -0x10(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    $0x0,%al
call   1030 <sqeuclidean_distance@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1418 <sppdist_sqeuclidean+0x2f8>
cmpl   $0x1,-0x1c(%rbp)
je     12db <sppdist_sqeuclidean+0x1bb>
cmpl   $0x3,-0x1c(%rbp)
je     12db <sppdist_sqeuclidean+0x1bb>
cmpl   $0x0,-0x1c(%rbp)
jne    1368 <sppdist_sqeuclidean+0x248>
mov    -0x34(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x48(%rbp),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    1363 <sppdist_sqeuclidean+0x243>
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
movslq -0x40(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x68(%rbp)
jmp    1368 <sppdist_sqeuclidean+0x248>
cmpl   $0x2,-0x1c(%rbp)
je     1386 <sppdist_sqeuclidean+0x266>
cmpl   $0x4,-0x1c(%rbp)
je     1386 <sppdist_sqeuclidean+0x266>
cmpl   $0x0,-0x1c(%rbp)
jne    1413 <sppdist_sqeuclidean+0x2f3>
mov    -0x38(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%edx
mov    -0x60(%rbp),%rax
mov    -0x3c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x48(%rbp),%xmm0
mov    -0x68(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jne    140e <sppdist_sqeuclidean+0x2ee>
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
movslq -0x40(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x68(%rbp)
jmp    1413 <sppdist_sqeuclidean+0x2f3>
jmp    1418 <sppdist_sqeuclidean+0x2f8>
jmp    141d <sppdist_sqeuclidean+0x2fd>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1250 <sppdist_sqeuclidean+0x130>
jmp    1430 <sppdist_sqeuclidean+0x310>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1192 <sppdist_sqeuclidean+0x72>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%eax
shl    $0x1,%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
movslq -0x40(%rbp),%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x68(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sppdist_sqeuclidean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8,%rbp
mov    %ecx,0x1c(%rsp)
movsd  %xmm0,0x78(%rsp)
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
lea    (%r15,%r15,1),%r13d
mov    %r9,0x40(%rsp)
mov    (%r9),%rdi
lea    0x0(,%r15,4),%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,(%rsp)
mov    %rbp,0x48(%rsp)
mov    0x0(%rbp),%rdi
movslq %r13d,%rsi
shl    $0x3,%rsi
call   1040 <realloc@plt>
mov    %rax,0x8(%rsp)
test   %r15d,%r15d
jle    1464 <sppdist_sqeuclidean+0x344>
mov    %r14d,0x2c(%rsp)
movslq %r14d,%rax
mov    %r15d,%ebp
lea    (%rbx,%rax,8),%r12
mov    %rax,0x50(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x38(%rsp)
mov    $0x1,%r14d
xor    %eax,%eax
xor    %edx,%edx
mov    %rbx,0x58(%rsp)
mov    %rbp,0x10(%rsp)
jmp    11ff <sppdist_sqeuclidean+0xdf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15d,%ebx
mov    %r13d,%edx
mov    0x68(%rsp),%r14
add    $0x1,%r14
mov    0x70(%rsp),%r12
add    0x38(%rsp),%r12
mov    %ebx,%r13d
mov    0x60(%rsp),%rax
cmp    %rbp,%rax
mov    0x58(%rsp),%rbx
je     1466 <sppdist_sqeuclidean+0x346>
cmpl   $0x2,0x1c(%rsp)
mov    %rax,0x20(%rsp)
ja     1270 <sppdist_sqeuclidean+0x150>
mov    %rax,%rcx
lea    (%rdx,%rdx,1),%eax
cltq
mov    (%rsp),%rdi
mov    %ecx,(%rdi,%rax,4)
lea    0x1(%rdx,%rdx,1),%eax
cltq
mov    %ecx,(%rdi,%rax,4)
movslq %edx,%rax
mov    0x8(%rsp),%rbp
movq   $0x0,0x0(%rbp,%rax,8)
add    $0x1,%eax
cmp    %r13d,%eax
jne    1280 <sppdist_sqeuclidean+0x160>
lea    0x0(%r13,%r13,1),%r15d
lea    0x0(,%r13,4),%eax
movslq %eax,%rsi
shl    $0x2,%rsi
call   1040 <realloc@plt>
mov    %rax,(%rsp)
movslq %r15d,%rsi
shl    $0x3,%rsi
mov    %rbp,%rdi
call   1040 <realloc@plt>
mov    %rax,0x8(%rsp)
jmp    1286 <sppdist_sqeuclidean+0x166>
nop
mov    %r13d,%r15d
mov    %edx,%r13d
jmp    1290 <sppdist_sqeuclidean+0x170>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%r15d
mov    %eax,%r13d
mov    0x10(%rsp),%rbp
mov    0x20(%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,0x60(%rsp)
cmp    %rbp,%rcx
mov    %r12,0x70(%rsp)
mov    %r14,0x68(%rsp)
jae    11d0 <sppdist_sqeuclidean+0xb0>
imul   0x50(%rsp),%rax
lea    (%rbx,%rax,8),%rax
mov    %rax,0x80(%rsp)
jmp    12de <sppdist_sqeuclidean+0x1be>
mov    %r15d,%ebx
mov    %r13d,%edx
add    $0x1,%r14
add    0x38(%rsp),%r12
mov    %edx,%r13d
mov    %ebx,%r15d
cmp    %r14,%rbp
je     11d6 <sppdist_sqeuclidean+0xb6>
mov    %r12,%rdi
mov    0x80(%rsp),%rsi
mov    0x2c(%rsp),%edx
xor    %eax,%eax
call   1030 <sqeuclidean_distance@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x78(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     12c0 <sppdist_sqeuclidean+0x1a0>
mov    0x1c(%rsp),%ebx
cmp    $0x3,%ebx
ja     13b4 <sppdist_sqeuclidean+0x294>
cmp    $0x2,%ebx
je     13b4 <sppdist_sqeuclidean+0x294>
lea    0x0(%r13,%r13,1),%eax
cltq
mov    (%rsp),%rbp
mov    %r14d,0x0(%rbp,%rax,4)
lea    0x1(%r13,%r13,1),%eax
cltq
mov    0x20(%rsp),%rcx
mov    %ecx,0x0(%rbp,%rax,4)
movslq %r13d,%rax
mov    0x8(%rsp),%r13
movsd  %xmm1,0x0(%r13,%rax,8)
add    $0x1,%eax
cmp    %r15d,%eax
jne    13a4 <sppdist_sqeuclidean+0x284>
lea    (%r15,%r15,1),%eax
mov    %rax,0x30(%rsp)
lea    0x0(,%r15,4),%eax
movslq %eax,%rsi
shl    $0x2,%rsi
mov    %rbp,%rdi
movsd  %xmm1,(%rsp)
call   1040 <realloc@plt>
mov    %rax,%rbp
movslq 0x30(%rsp),%rsi
shl    $0x3,%rsi
mov    %r13,%rdi
call   1040 <realloc@plt>
movsd  (%rsp),%xmm1
mov    0x30(%rsp),%rdx
mov    %rax,%r13
cmp    $0x4,%ebx
jbe    13cc <sppdist_sqeuclidean+0x2ac>
jmp    144c <sppdist_sqeuclidean+0x32c>
mov    %r15d,%edx
mov    %eax,%r15d
cmp    $0x4,%ebx
jbe    13cc <sppdist_sqeuclidean+0x2ac>
jmp    144c <sppdist_sqeuclidean+0x32c>
mov    %r15d,%edx
mov    %r13d,%r15d
mov    (%rsp),%rbp
mov    0x8(%rsp),%r13
cmp    $0x4,%ebx
ja     144c <sppdist_sqeuclidean+0x32c>
mov    $0x15,%eax
bt     %ebx,%eax
jae    144c <sppdist_sqeuclidean+0x32c>
lea    (%r15,%r15,1),%eax
cltq
mov    0x20(%rsp),%rcx
mov    %ecx,0x0(%rbp,%rax,4)
lea    (%r15,%r15,1),%eax
add    $0x1,%eax
cltq
mov    %r14d,0x0(%rbp,%rax,4)
movslq %r15d,%rax
movsd  %xmm1,0x0(%r13,%rax,8)
add    $0x1,%eax
cmp    %edx,%eax
jne    143d <sppdist_sqeuclidean+0x31d>
lea    (%rdx,%rdx,1),%ebx
lea    0x0(,%rdx,4),%eax
movslq %eax,%rsi
shl    $0x2,%rsi
mov    %rbp,%rdi
mov    %rdx,%rbp
call   1040 <realloc@plt>
mov    %rax,(%rsp)
movslq %ebx,%rsi
shl    $0x3,%rsi
mov    %r13,%rdi
call   1040 <realloc@plt>
mov    %rbp,%rdx
mov    %rax,0x8(%rsp)
jmp    145a <sppdist_sqeuclidean+0x33a>
mov    %r13,0x8(%rsp)
mov    %rbp,(%rsp)
mov    %edx,%ebx
mov    %eax,%edx
jmp    145a <sppdist_sqeuclidean+0x33a>
mov    %r13,0x8(%rsp)
mov    %rbp,(%rsp)
mov    %edx,%ebx
mov    %r15d,%edx
mov    0x10(%rsp),%rbp
jmp    12c6 <sppdist_sqeuclidean+0x1a6>
xor    %edx,%edx
lea    (%rdx,%rdx,1),%eax
movslq %eax,%rsi
shl    $0x2,%rsi
mov    (%rsp),%rdi
mov    %rdx,%rbp
call   1040 <realloc@plt>
mov    %rax,%rbx
movslq %ebp,%rbp
lea    0x0(,%rbp,8),%rsi
mov    0x8(%rsp),%rdi
call   1040 <realloc@plt>
mov    0x40(%rsp),%rcx
mov    %rbx,(%rcx)
mov    0x48(%rsp),%rcx
mov    %rax,(%rcx)
mov    0xc0(%rsp),%rax
mov    %ebp,(%rax)
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sppdist_sqeuclidean(double* %0, i32 %1, i32 %2, double %3, i32 %4, double** %5, i32** %6, i32* %7) {
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca i32
%14 = alloca double**
%15 = alloca i32**
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca double*
%23 = alloca double*
%24 = alloca i32*
%25 = alloca double*
store double* %0, double** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double %3, double* %12
store i32 %4, i32* %13
store double** %5, double*** %14
store i32** %6, i32*** %15
store i32* %7, i32** %16
%26 = load i32, i32* %10
%27 = mul nsw i32 2, %26
store i32 %27, i32* %20
%28 = load i32**, i32*** %15
%29 = load i32*, i32** %28
%30 = bitcast i32* %29 to i8*
%31 = load i32, i32* %20
%32 = mul nsw i32 2, %31
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 4
%35 = call i8* @realloc(i8* %30, i64 %34)
%36 = bitcast i8* %35 to i32*
store i32* %36, i32** %24
%37 = load double**, double*** %14
%38 = load double*, double** %37
%39 = bitcast double* %38 to i8*
%40 = load i32, i32* %20
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 8
%43 = call i8* @realloc(i8* %39, i64 %42)
%44 = bitcast i8* %43 to double*
store double* %44, double** %25
store i32 0, i32* %19
store i32 0, i32* %18
br label %45
45: ; preds = %238, %8
%46 = load i32, i32* %18
%47 = load i32, i32* %10
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %241
49: ; preds = %45
%50 = load i32, i32* %13
%51 = icmp eq i32 %50, 0
br i1 %51, label %58, label %52
52: ; preds = %49
%53 = load i32, i32* %13
%54 = icmp eq i32 %53, 1
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i32, i32* %13
%57 = icmp eq i32 %56, 2
br i1 %57, label %58, label %100
58: ; preds = %55, %52, %49
%59 = load i32, i32* %18
%60 = load i32*, i32** %24
%61 = load i32, i32* %19
%62 = mul nsw i32 2, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %60, i64 %63
store i32 %59, i32* %64
%65 = load i32, i32* %18
%66 = load i32*, i32** %24
%67 = load i32, i32* %19
%68 = mul nsw i32 2, %67
%69 = add nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %66, i64 %70
store i32 %65, i32* %71
%72 = load double*, double** %25
%73 = load i32, i32* %19
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
store double 0.000000e+00, double* %75
%76 = load i32, i32* %19
%77 = add nsw i32 %76, 1
store i32 %77, i32* %19
%78 = load i32, i32* %19
%79 = load i32, i32* %20
%80 = icmp eq i32 %78, %79
br i1 %80, label %81, label %99
81: ; preds = %58
%82 = load i32, i32* %20
%83 = mul nsw i32 %82, 2
store i32 %83, i32* %20
%84 = load i32*, i32** %24
%85 = bitcast i32* %84 to i8*
%86 = load i32, i32* %20
%87 = mul nsw i32 2, %86
%88 = sext i32 %87 to i64
%89 = mul i64 %88, 4
%90 = call i8* @realloc(i8* %85, i64 %89)
%91 = bitcast i8* %90 to i32*
store i32* %91, i32** %24
%92 = load double*, double** %25
%93 = bitcast double* %92 to i8*
%94 = load i32, i32* %20
%95 = sext i32 %94 to i64
%96 = mul i64 %95, 8
%97 = call i8* @realloc(i8* %93, i64 %96)
%98 = bitcast i8* %97 to double*
store double* %98, double** %25
br label %99
99: ; preds = %81, %58
br label %100
100: ; preds = %99, %55
%101 = load i32, i32* %18
%102 = add nsw i32 %101, 1
store i32 %102, i32* %17
br label %103
103: ; preds = %234, %100
%104 = load i32, i32* %17
%105 = load i32, i32* %10
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %237
107: ; preds = %103
%108 = load double*, double** %9
%109 = load i32, i32* %17
%110 = load i32, i32* %11
%111 = mul nsw i32 %109, %110
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %108, i64 %112
store double* %113, double** %22
%114 = load double*, double** %9
%115 = load i32, i32* %18
%116 = load i32, i32* %11
%117 = mul nsw i32 %115, %116
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %114, i64 %118
store double* %119, double** %23
%120 = load double*, double** %22
%121 = load double*, double** %23
%122 = load i32, i32* %11
%123 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @sqeuclidean_distance to i32 (double*, double*, i32, ...)*)(double* %120, double* %121, i32 %122)
%124 = sitofp i32 %123 to double
store double %124, double* %21
%125 = load double, double* %21
%126 = load double, double* %12
%127 = fcmp ole double %125, %126
br i1 %127, label %128, label %233
128: ; preds = %107
%129 = load i32, i32* %13
%130 = icmp eq i32 %129, 1
br i1 %130, label %137, label %131
131: ; preds = %128
%132 = load i32, i32* %13
%133 = icmp eq i32 %132, 3
br i1 %133, label %137, label %134
134: ; preds = %131
%135 = load i32, i32* %13
%136 = icmp eq i32 %135, 0
br i1 %136, label %137, label %180
137: ; preds = %134, %131, %128
%138 = load i32, i32* %17
%139 = load i32*, i32** %24
%140 = load i32, i32* %19
%141 = mul nsw i32 2, %140
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i32, i32* %139, i64 %142
store i32 %138, i32* %143
%144 = load i32, i32* %18
%145 = load i32*, i32** %24
%146 = load i32, i32* %19
%147 = mul nsw i32 2, %146
%148 = add nsw i32 %147, 1
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i32, i32* %145, i64 %149
store i32 %144, i32* %150
%151 = load double, double* %21
%152 = load double*, double** %25
%153 = load i32, i32* %19
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %152, i64 %154
store double %151, double* %155
%156 = load i32, i32* %19
%157 = add nsw i32 %156, 1
store i32 %157, i32* %19
%158 = load i32, i32* %19
%159 = load i32, i32* %20
%160 = icmp eq i32 %158, %159
br i1 %160, label %161, label %179
161: ; preds = %137
%162 = load i32, i32* %20
%163 = mul nsw i32 %162, 2
store i32 %163, i32* %20
%164 = load i32*, i32** %24
%165 = bitcast i32* %164 to i8*
%166 = load i32, i32* %20
%167 = mul nsw i32 2, %166
%168 = sext i32 %167 to i64
%169 = mul i64 %168, 4
%170 = call i8* @realloc(i8* %165, i64 %169)
%171 = bitcast i8* %170 to i32*
store i32* %171, i32** %24
%172 = load double*, double** %25
%173 = bitcast double* %172 to i8*
%174 = load i32, i32* %20
%175 = sext i32 %174 to i64
%176 = mul i64 %175, 8
%177 = call i8* @realloc(i8* %173, i64 %176)
%178 = bitcast i8* %177 to double*
store double* %178, double** %25
br label %179
179: ; preds = %161, %137
br label %180
180: ; preds = %179, %134
%181 = load i32, i32* %13
%182 = icmp eq i32 %181, 2
br i1 %182, label %189, label %183
183: ; preds = %180
%184 = load i32, i32* %13
%185 = icmp eq i32 %184, 4
br i1 %185, label %189, label %186
186: ; preds = %183
%187 = load i32, i32* %13
%188 = icmp eq i32 %187, 0
br i1 %188, label %189, label %232
189: ; preds = %186, %183, %180
%190 = load i32, i32* %18
%191 = load i32*, i32** %24
%192 = load i32, i32* %19
%193 = mul nsw i32 2, %192
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds i32, i32* %191, i64 %194
store i32 %190, i32* %195
%196 = load i32, i32* %17
%197 = load i32*, i32** %24
%198 = load i32, i32* %19
%199 = mul nsw i32 2, %198
%200 = add nsw i32 %199, 1
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds i32, i32* %197, i64 %201
store i32 %196, i32* %202
%203 = load double, double* %21
%204 = load double*, double** %25
%205 = load i32, i32* %19
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds double, double* %204, i64 %206
store double %203, double* %207
%208 = load i32, i32* %19
%209 = add nsw i32 %208, 1
store i32 %209, i32* %19
%210 = load i32, i32* %19
%211 = load i32, i32* %20
%212 = icmp eq i32 %210, %211
br i1 %212, label %213, label %231
213: ; preds = %189
%214 = load i32, i32* %20
%215 = mul nsw i32 %214, 2
store i32 %215, i32* %20
%216 = load i32*, i32** %24
%217 = bitcast i32* %216 to i8*
%218 = load i32, i32* %20
%219 = mul nsw i32 2, %218
%220 = sext i32 %219 to i64
%221 = mul i64 %220, 4
%222 = call i8* @realloc(i8* %217, i64 %221)
%223 = bitcast i8* %222 to i32*
store i32* %223, i32** %24
%224 = load double*, double** %25
%225 = bitcast double* %224 to i8*
%226 = load i32, i32* %20
%227 = sext i32 %226 to i64
%228 = mul i64 %227, 8
%229 = call i8* @realloc(i8* %225, i64 %228)
%230 = bitcast i8* %229 to double*
store double* %230, double** %25
br label %231
231: ; preds = %213, %189
br label %232
232: ; preds = %231, %186
br label %233
233: ; preds = %232, %107
br label %234
234: ; preds = %233
%235 = load i32, i32* %17
%236 = add nsw i32 %235, 1
store i32 %236, i32* %17
br label %103
237: ; preds = %103
br label %238
238: ; preds = %237
%239 = load i32, i32* %18
%240 = add nsw i32 %239, 1
store i32 %240, i32* %18
br label %45
241: ; preds = %45
%242 = load i32, i32* %19
store i32 %242, i32* %20
%243 = load i32*, i32** %24
%244 = bitcast i32* %243 to i8*
%245 = load i32, i32* %20
%246 = mul nsw i32 2, %245
%247 = sext i32 %246 to i64
%248 = mul i64 %247, 4
%249 = call i8* @realloc(i8* %244, i64 %248)
%250 = bitcast i8* %249 to i32*
store i32* %250, i32** %24
%251 = load double*, double** %25
%252 = bitcast double* %251 to i8*
%253 = load i32, i32* %20
%254 = sext i32 %253 to i64
%255 = mul i64 %254, 8
%256 = call i8* @realloc(i8* %252, i64 %255)
%257 = bitcast i8* %256 to double*
store double* %257, double** %25
%258 = load i32*, i32** %24
%259 = load i32**, i32*** %15
store i32* %258, i32** %259
%260 = load double*, double** %25
%261 = load double**, double*** %14
store double* %260, double** %261
%262 = load i32, i32* %20
%263 = load i32*, i32** %16
store i32 %262, i32* %263
ret void
}

LLVM IR (-O2):
define void @sppdist_sqeuclidean(double* %0, i32 %1, i32 %2, double %3, i32 %4, double** nocapture %5, i32** nocapture %6, i32* nocapture writeonly %7) {
%9 = shl nsw i32 %1, 1
%10 = bitcast i32** %6 to i8**
%11 = load i8*, i8** %10
%12 = shl nsw i32 %1, 2
%13 = sext i32 %12 to i64
%14 = shl nsw i64 %13, 2
%15 = tail call i8* @realloc(i8* %11, i64 %14)
%16 = bitcast i8* %15 to i32*
%17 = bitcast double** %5 to i8**
%18 = load i8*, i8** %17
%19 = sext i32 %9 to i64
%20 = shl nsw i64 %19, 3
%21 = tail call i8* @realloc(i8* %18, i64 %20)
%22 = bitcast i8* %21 to double*
%23 = icmp sgt i32 %1, 0
br i1 %23, label %24, label %154
24: ; preds = %8
%25 = icmp ult i32 %4, 3
%26 = sext i32 %2 to i64
%27 = zext i32 %1 to i64
%28 = zext i32 %1 to i64
br label %36
29: ; preds = %147, %68
%30 = phi i32 [ %69, %68 ], [ %148, %147 ]
%31 = phi i32 [ %70, %68 ], [ %149, %147 ]
%32 = phi i32* [ %71, %68 ], [ %150, %147 ]
%33 = phi double* [ %72, %68 ], [ %151, %147 ]
%34 = add nuw nsw i64 %38, 1
%35 = icmp eq i64 %73, %28
br i1 %35, label %154, label %36
36: ; preds = %24, %29
%37 = phi i64 [ 0, %24 ], [ %73, %29 ]
%38 = phi i64 [ 1, %24 ], [ %34, %29 ]
%39 = phi double* [ %22, %24 ], [ %33, %29 ]
%40 = phi i32* [ %16, %24 ], [ %32, %29 ]
%41 = phi i32 [ 0, %24 ], [ %31, %29 ]
%42 = phi i32 [ %9, %24 ], [ %30, %29 ]
br i1 %25, label %43, label %68
43: ; preds = %36
%44 = shl nsw i32 %41, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %40, i64 %45
%47 = trunc i64 %37 to i32
store i32 %47, i32* %46
%48 = or i32 %44, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %40, i64 %49
store i32 %47, i32* %50
%51 = sext i32 %41 to i64
%52 = getelementptr inbounds double, double* %39, i64 %51
store double 0.000000e+00, double* %52
%53 = add nsw i32 %41, 1
%54 = icmp eq i32 %53, %42
br i1 %54, label %55, label %68
55: ; preds = %43
%56 = shl nsw i32 %42, 1
%57 = bitcast i32* %40 to i8*
%58 = shl nsw i32 %42, 2
%59 = sext i32 %58 to i64
%60 = shl nsw i64 %59, 2
%61 = tail call i8* @realloc(i8* %57, i64 %60)
%62 = bitcast i8* %61 to i32*
%63 = bitcast double* %39 to i8*
%64 = sext i32 %56 to i64
%65 = shl nsw i64 %64, 3
%66 = tail call i8* @realloc(i8* %63, i64 %65)
%67 = bitcast i8* %66 to double*
br label %68
68: ; preds = %43, %55, %36
%69 = phi i32 [ %56, %55 ], [ %42, %43 ], [ %42, %36 ]
%70 = phi i32 [ %42, %55 ], [ %53, %43 ], [ %41, %36 ]
%71 = phi i32* [ %62, %55 ], [ %40, %43 ], [ %40, %36 ]
%72 = phi double* [ %67, %55 ], [ %39, %43 ], [ %39, %36 ]
%73 = add nuw nsw i64 %37, 1
%74 = icmp ult i64 %73, %27
br i1 %74, label %75, label %29
75: ; preds = %68
%76 = mul nsw i64 %37, %26
%77 = getelementptr inbounds double, double* %0, i64 %76
%78 = trunc i64 %37 to i32
%79 = trunc i64 %37 to i32
br label %80
80: ; preds = %75, %147
%81 = phi i64 [ %38, %75 ], [ %152, %147 ]
%82 = phi double* [ %72, %75 ], [ %151, %147 ]
%83 = phi i32* [ %71, %75 ], [ %150, %147 ]
%84 = phi i32 [ %70, %75 ], [ %149, %147 ]
%85 = phi i32 [ %69, %75 ], [ %148, %147 ]
%86 = mul nsw i64 %81, %26
%87 = getelementptr inbounds double, double* %0, i64 %86
%88 = tail call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @sqeuclidean_distance to i32 (double*, double*, i32, ...)*)(double* %87, double* %77, i32 %2)
%89 = sitofp i32 %88 to double
%90 = fcmp ugt double %89, %3
br i1 %90, label %147, label %91
91: ; preds = %80
switch i32 %4, label %117 [
i32 3, label %92
i32 1, label %92
i32 0, label %92
]
92: ; preds = %91, %91, %91
%93 = shl nsw i32 %84, 1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %83, i64 %94
%96 = trunc i64 %81 to i32
store i32 %96, i32* %95
%97 = or i32 %93, 1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %83, i64 %98
store i32 %78, i32* %99
%100 = sext i32 %84 to i64
%101 = getelementptr inbounds double, double* %82, i64 %100
store double %89, double* %101
%102 = add nsw i32 %84, 1
%103 = icmp eq i32 %102, %85
br i1 %103, label %104, label %117
104: ; preds = %92
%105 = shl nsw i32 %85, 1
%106 = bitcast i32* %83 to i8*
%107 = shl nsw i32 %85, 2
%108 = sext i32 %107 to i64
%109 = shl nsw i64 %108, 2
%110 = tail call i8* @realloc(i8* %106, i64 %109)
%111 = bitcast i8* %110 to i32*
%112 = bitcast double* %82 to i8*
%113 = sext i32 %105 to i64
%114 = shl nsw i64 %113, 3
%115 = tail call i8* @realloc(i8* %112, i64 %114)
%116 = bitcast i8* %115 to double*
br label %117
117: ; preds = %91, %92, %104
%118 = phi i32 [ %105, %104 ], [ %85, %92 ], [ %85, %91 ]
%119 = phi i32 [ %85, %104 ], [ %102, %92 ], [ %84, %91 ]
%120 = phi i32* [ %111, %104 ], [ %83, %92 ], [ %83, %91 ]
%121 = phi double* [ %116, %104 ], [ %82, %92 ], [ %82, %91 ]
switch i32 %4, label %147 [
i32 4, label %122
i32 2, label %122
i32 0, label %122
]
122: ; preds = %117, %117, %117
%123 = shl nsw i32 %119, 1
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i32, i32* %120, i64 %124
store i32 %79, i32* %125
%126 = or i32 %123, 1
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i32, i32* %120, i64 %127
%129 = trunc i64 %81 to i32
store i32 %129, i32* %128
%130 = sext i32 %119 to i64
%131 = getelementptr inbounds double, double* %121, i64 %130
store double %89, double* %131
%132 = add nsw i32 %119, 1
%133 = icmp eq i32 %132, %118
br i1 %133, label %134, label %147
134: ; preds = %122
%135 = shl nsw i32 %118, 1
%136 = bitcast i32* %120 to i8*
%137 = shl nsw i32 %118, 2
%138 = sext i32 %137 to i64
%139 = shl nsw i64 %138, 2
%140 = tail call i8* @realloc(i8* %136, i64 %139)
%141 = bitcast i8* %140 to i32*
%142 = bitcast double* %121 to i8*
%143 = sext i32 %135 to i64
%144 = shl nsw i64 %143, 3
%145 = tail call i8* @realloc(i8* %142, i64 %144)
%146 = bitcast i8* %145 to double*
br label %147
147: ; preds = %117, %80, %122, %134
%148 = phi i32 [ %135, %134 ], [ %118, %122 ], [ %118, %117 ], [ %85, %80 ]
%149 = phi i32 [ %118, %134 ], [ %132, %122 ], [ %119, %117 ], [ %84, %80 ]
%150 = phi i32* [ %141, %134 ], [ %120, %122 ], [ %120, %117 ], [ %83, %80 ]
%151 = phi double* [ %146, %134 ], [ %121, %122 ], [ %121, %117 ], [ %82, %80 ]
%152 = add nuw nsw i64 %81, 1
%153 = icmp eq i64 %152, %28
br i1 %153, label %29, label %80
154: ; preds = %29, %8
%155 = phi i32 [ 0, %8 ], [ %31, %29 ]
%156 = phi i32* [ %16, %8 ], [ %32, %29 ]
%157 = phi double* [ %22, %8 ], [ %33, %29 ]
%158 = bitcast i32* %156 to i8*
%159 = shl nsw i32 %155, 1
%160 = sext i32 %159 to i64
%161 = shl nsw i64 %160, 2
%162 = tail call i8* @realloc(i8* %158, i64 %161)
%163 = bitcast double* %157 to i8*
%164 = sext i32 %155 to i64
%165 = shl nsw i64 %164, 3
%166 = tail call i8* @realloc(i8* %163, i64 %165)
store i8* %162, i8** %10
store i8* %166, i8** %17
store i32 %155, i32* %7
ret void
}