#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double seuclidean_distance(double const *, double const *, double const *, int);
void pdist_seuclidean(const double *X, const double *var, double *dm, int m,
                      int n) {
  int i, j;
  const double *u, *v;
  double *it = dm;
  for (i = 0; i < m; i++) {
    for (j = i + 1; j < m; j++, it++) {
      u = X + (n * i);
      v = X + (n * j);
      *it = seuclidean_distance(var, u, v, n);
    }
  }
}


x86 assembly (clang, -O0):
<pdist_seuclidean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d6 <pdist_seuclidean+0xc6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c3 <pdist_seuclidean+0xb3>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x28(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1030 <seuclidean_distance@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
jmp    114f <pdist_seuclidean+0x3f>
jmp    11c8 <pdist_seuclidean+0xb8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <pdist_seuclidean+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdist_seuclidean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,(%rsp)
test   %ecx,%ecx
jle    11de <pdist_seuclidean+0xce>
mov    %r8d,%r15d
mov    %rdx,%rbx
mov    %rsi,%r14
movslq %r8d,%rdx
mov    %ecx,%r12d
mov    (%rsp),%rax
lea    (%rax,%rdx,8),%rbp
mov    %rdx,0x8(%rsp)
lea    0x0(,%rdx,8),%r13
mov    $0x1,%edi
xor    %eax,%eax
mov    %r12,0x10(%rsp)
jmp    117b <pdist_seuclidean+0x6b>
nopl   0x0(%rax)
add    $0x1,%rdi
mov    0x20(%rsp),%rbp
add    %r13,%rbp
mov    0x10(%rsp),%r12
mov    0x18(%rsp),%rax
cmp    %r12,%rax
je     11de <pdist_seuclidean+0xce>
lea    0x1(%rax),%rcx
cmp    %r12,%rcx
mov    %rbp,0x20(%rsp)
mov    %rcx,0x18(%rsp)
jae    1160 <pdist_seuclidean+0x50>
imul   0x8(%rsp),%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x28(%rsp)
mov    %rdi,0x30(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    0x28(%rsp),%rsi
mov    %rbp,%rdx
mov    %r15d,%ecx
call   1030 <seuclidean_distance@plt>
mov    0x30(%rsp),%rdi
movsd  %xmm0,(%rbx)
add    $0x8,%rbx
add    %r13,%rbp
add    $0xffffffffffffffff,%r12
cmp    %r12,%rdi
jne    11b0 <pdist_seuclidean+0xa0>
jmp    1160 <pdist_seuclidean+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @pdist_seuclidean(double* %0, double* %1, double* %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%16 = load double*, double** %8
store double* %16, double** %15
store i32 0, i32* %11
br label %17
17: ; preds = %53, %5
%18 = load i32, i32* %11
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %56
21: ; preds = %17
%22 = load i32, i32* %11
%23 = add nsw i32 %22, 1
store i32 %23, i32* %12
br label %24
24: ; preds = %47, %21
%25 = load i32, i32* %12
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %52
28: ; preds = %24
%29 = load double*, double** %6
%30 = load i32, i32* %10
%31 = load i32, i32* %11
%32 = mul nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
store double* %34, double** %13
%35 = load double*, double** %6
%36 = load i32, i32* %10
%37 = load i32, i32* %12
%38 = mul nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %35, i64 %39
store double* %40, double** %14
%41 = load double*, double** %7
%42 = load double*, double** %13
%43 = load double*, double** %14
%44 = load i32, i32* %10
%45 = call double @seuclidean_distance(double* %41, double* %42, double* %43, i32 %44)
%46 = load double*, double** %15
store double %45, double* %46
br label %47
47: ; preds = %28
%48 = load i32, i32* %12
%49 = add nsw i32 %48, 1
store i32 %49, i32* %12
%50 = load double*, double** %15
%51 = getelementptr inbounds double, double* %50, i32 1
store double* %51, double** %15
br label %24
52: ; preds = %24
br label %53
53: ; preds = %52
%54 = load i32, i32* %11
%55 = add nsw i32 %54, 1
store i32 %55, i32* %11
br label %17
56: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @pdist_seuclidean(double* %0, double* %1, double* nocapture writeonly %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, 0
br i1 %6, label %7, label %33
7: ; preds = %5
%8 = sext i32 %4 to i64
%9 = zext i32 %3 to i64
%10 = zext i32 %3 to i64
br label %15
11: ; preds = %24, %15
%12 = phi double* [ %18, %15 ], [ %31, %24 ]
%13 = add nuw nsw i64 %17, 1
%14 = icmp eq i64 %19, %10
br i1 %14, label %33, label %15
15: ; preds = %7, %11
%16 = phi i64 [ 0, %7 ], [ %19, %11 ]
%17 = phi i64 [ 1, %7 ], [ %13, %11 ]
%18 = phi double* [ %2, %7 ], [ %12, %11 ]
%19 = add nuw nsw i64 %16, 1
%20 = icmp ult i64 %19, %9
br i1 %20, label %21, label %11
21: ; preds = %15
%22 = mul nsw i64 %16, %8
%23 = getelementptr inbounds double, double* %0, i64 %22
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ %17, %21 ], [ %30, %24 ]
%26 = phi double* [ %18, %21 ], [ %31, %24 ]
%27 = mul nsw i64 %25, %8
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = tail call double @seuclidean_distance(double* %1, double* %23, double* %28, i32 %4)
store double %29, double* %26
%30 = add nuw nsw i64 %25, 1
%31 = getelementptr inbounds double, double* %26, i64 1
%32 = icmp eq i64 %30, %10
br i1 %32, label %11, label %24
33: ; preds = %11, %5
ret void
}