#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 squared_distance_between_particles(double *, double *);
void compute_squared_distance_matrix(double **model, int nparticles,
                                     double **squared_distance_matrix) {
  int particle1, particle2;
  for (particle1 = 0; particle1 < nparticles; particle1++) {
    for (particle2 = particle1 + 1; particle2 < nparticles; particle2++) {
      squared_distance_matrix[particle1][particle2] =
          squared_distance_between_particles(model[particle1],
                                             model[particle2]);
      squared_distance_matrix[particle2][particle1] =
          squared_distance_matrix[particle1][particle2];
    }
  }
}


x86 assembly (clang, -O0):
<compute_squared_distance_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c8 <compute_squared_distance_matrix+0xb8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b5 <compute_squared_distance_matrix+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <squared_distance_between_particles@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113f <compute_squared_distance_matrix+0x2f>
jmp    11ba <compute_squared_distance_matrix+0xaa>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <compute_squared_distance_matrix+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_squared_distance_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    118b <compute_squared_distance_matrix+0x7b>
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %esi,%r15d
mov    $0x1,%r13d
xor    %ebp,%ebp
jmp    114d <compute_squared_distance_matrix+0x3d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13
mov    (%rsp),%rbp
cmp    %r15,%rbp
je     118b <compute_squared_distance_matrix+0x7b>
lea    0x1(%rbp),%rax
mov    %rax,(%rsp)
cmp    %r15,%rax
jae    1140 <compute_squared_distance_matrix+0x30>
mov    %r13,%r12
nopl   (%rax)
mov    (%rbx,%rbp,8),%rdi
mov    (%rbx,%r12,8),%rsi
call   1030 <squared_distance_between_particles@plt>
mov    (%r14,%rbp,8),%rax
movsd  %xmm0,(%rax,%r12,8)
mov    (%r14,%r12,8),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%r12
cmp    %r12,%r15
jne    1160 <compute_squared_distance_matrix+0x50>
jmp    1140 <compute_squared_distance_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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