#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 minkowski_distance(double const *, double const *, int, double);
void pdist_minkowski(const double *X, double *dm, int m, int n, double p) {
  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 = minkowski_distance(u, v, n, p);
    }
  }
}


x86 assembly (clang, -O0):
<pdist_minkowski>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d7 <pdist_minkowski+0xc7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c4 <pdist_minkowski+0xb4>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x24(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x28(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
call   1030 <minkowski_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_minkowski+0x3f>
jmp    11c9 <pdist_minkowski+0xb9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113a <pdist_minkowski+0x2a>
add    $0x40,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @pdist_minkowski(double* %0, double* %1, i32 %2, i32 %3, double %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%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 i32 %2, i32* %8
store i32 %3, i32* %9
store double %4, double* %10
%16 = load double*, double** %7
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* %8
%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* %8
%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* %9
%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* %9
%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** %13
%42 = load double*, double** %14
%43 = load i32, i32* %9
%44 = load double, double* %10
%45 = call double @minkowski_distance(double* %41, double* %42, i32 %43, double %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_minkowski(double* %0, double* nocapture writeonly %1, i32 %2, i32 %3, double %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %33
7: ; preds = %5
%8 = sext i32 %3 to i64
%9 = zext i32 %2 to i64
%10 = zext i32 %2 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* [ %1, %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 @minkowski_distance(double* %23, double* %28, i32 %3, double %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
}