#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 */
int get_euclidean_distance(double *, double *, int, int);
int generate_dist_matrix(int node_count, double *x_coordinates,
                         double *y_coordinates, int **dist_matrix) {
  int i, j;
  for (i = 0; i < node_count; i++) {
    for (j = 0; j < node_count; j++) {
      dist_matrix[i][j] =
          get_euclidean_distance(x_coordinates, y_coordinates, i, j);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<generate_dist_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1196 <generate_dist_matrix+0x86>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <generate_dist_matrix+0x73>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1030 <get_euclidean_distance@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1141 <generate_dist_matrix+0x31>
jmp    1188 <generate_dist_matrix+0x78>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112e <generate_dist_matrix+0x1e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_dist_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1169 <generate_dist_matrix+0x59>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
xor    %r13d,%r13d
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1030 <get_euclidean_distance@plt>
mov    (%r14,%r13,8),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <generate_dist_matrix+0x30>
add    $0x1,%r13
cmp    %rbp,%r13
jne    1130 <generate_dist_matrix+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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