#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 kulsinski_distance_bool(char const *, char const *, int);
void pdist_kulsinski_bool(const char *X, double *dm, int m, int n) {
  int i, j;
  const char *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 = kulsinski_distance_bool(u, v, n);
    }
  }
}


x86 assembly (clang, -O0):
<pdist_kulsinski_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c5 <pdist_kulsinski_bool+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b2 <pdist_kulsinski_bool+0xa2>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x20(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <kulsinski_distance_bool@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
jmp    114a <pdist_kulsinski_bool+0x3a>
jmp    11b7 <pdist_kulsinski_bool+0xa7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1135 <pdist_kulsinski_bool+0x25>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pdist_kulsinski_bool>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,0x8(%rsp)
test   %edx,%edx
jle    11b6 <pdist_kulsinski_bool+0xa6>
mov    %rsi,%r13
movslq %ecx,%r15
mov    %edx,%r14d
mov    0x8(%rsp),%rax
lea    (%rax,%r15,1),%rbx
mov    $0x1,%ebp
xor    %r12d,%r12d
mov    %r14,0x10(%rsp)
jmp    116b <pdist_kulsinski_bool+0x5b>
nopl   0x0(%rax)
add    $0x1,%rbp
mov    0x20(%rsp),%rbx
add    %r15,%rbx
mov    0x10(%rsp),%r14
mov    0x18(%rsp),%r12
cmp    %r14,%r12
je     11b6 <pdist_kulsinski_bool+0xa6>
lea    0x1(%r12),%rax
cmp    %r14,%rax
mov    %rbx,0x20(%rsp)
mov    %rax,0x18(%rsp)
jae    1150 <pdist_kulsinski_bool+0x40>
imul   %r15,%r12
add    0x8(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <kulsinski_distance_bool@plt>
movsd  %xmm0,0x0(%r13)
add    $0x8,%r13
add    %r15,%rbx
add    $0xffffffffffffffff,%r14
cmp    %r14,%rbp
jne    1190 <pdist_kulsinski_bool+0x80>
jmp    1150 <pdist_kulsinski_bool+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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