#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 distance(double *, double *, double *, int, int);
scalar_t__ populateNeighborList(double *, int *, int, int **);
int buildNeighborList(double position_x[256], double position_y[256],
                      double position_z[256], int NL[256][16]) {
  int totalPairs, i, j, k;
  totalPairs = 0;
  double distIJ;
  for (i = 0; i < 256; i++) {
    int currList[16];
    double currDist[16];
    for (k = 0; k < 16; k++) {
      currList[k] = 0;
      currDist[k] = 999999999;
    }
    for (j = 0; j < 16; j++) {
      if (i == j) {
        continue;
      }
      distIJ = distance(position_x, position_y, position_z, i, j);
      currList[j] = j;
      currDist[j] = distIJ;
    }
    totalPairs += populateNeighborList(currDist, currList, i, NL);
  }
  return totalPairs;
}


x86 assembly (clang, -O0):
<buildNeighborList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x100,-0x28(%rbp)
jge    1232 <buildNeighborList+0x112>
movl   $0x0,-0x30(%rbp)
cmpl   $0x10,-0x30(%rbp)
jge    1196 <buildNeighborList+0x76>
movslq -0x30(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
movslq -0x30(%rbp),%rax
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x100(%rbp,%rax,8)
ff ff
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    115d <buildNeighborList+0x3d>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x10,-0x2c(%rbp)
jge    1200 <buildNeighborList+0xe0>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    11b8 <buildNeighborList+0x98>
jmp    11f2 <buildNeighborList+0xd2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1040 <distance@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%ecx
movslq -0x2c(%rbp),%rax
mov    %ecx,-0x80(%rbp,%rax,4)
movsd  -0x38(%rbp),%xmm0
movslq -0x2c(%rbp),%rax
movsd  %xmm0,-0x100(%rbp,%rax,8)
ff ff
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119d <buildNeighborList+0x7d>
lea    -0x100(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <populateNeighborList@plt>
mov    %rax,%rcx
movslq -0x24(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1149 <buildNeighborList+0x29>
mov    -0x24(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildNeighborList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1179 <buildNeighborList+0x59>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x50(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %ebx,%edx
mov    0x8(%rsp),%rcx
call   1030 <populateNeighborList@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1214 <buildNeighborList+0xf4>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xc0(%rsp)
xor    %r14d,%r14d
jmp    11ee <buildNeighborList+0xce>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    $0x10,%r14
je     1150 <buildNeighborList+0x30>
cmp    %r14,%rbx
je     11e0 <buildNeighborList+0xc0>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1040 <distance@plt>
mov    %r14d,0x10(%rsp,%r14,4)
movsd  %xmm0,0x50(%rsp,%r14,8)
jmp    11e0 <buildNeighborList+0xc0>
mov    %ebp,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @buildNeighborList(double* %0, double* %1, double* %2, [16 x i32]* %3) {
%5 = alloca [16 x i32]
%6 = bitcast [16 x i32]* %5 to i8*
%7 = alloca [16 x double]
%8 = bitcast [16 x double]* %7 to i8*
%9 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 0
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%11 = bitcast [16 x i32]* %3 to i32**
%12 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 2
%13 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 4
%14 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 6
%15 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 8
%16 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 10
%17 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 12
%18 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 14
%19 = bitcast [16 x double]* %7 to <2 x double>*
%20 = bitcast double* %12 to <2 x double>*
%21 = bitcast double* %13 to <2 x double>*
%22 = bitcast double* %14 to <2 x double>*
%23 = bitcast double* %15 to <2 x double>*
%24 = bitcast double* %16 to <2 x double>*
%25 = bitcast double* %17 to <2 x double>*
%26 = bitcast double* %18 to <2 x double>*
br label %27
27: ; preds = %4, %42
%28 = phi i64 [ 0, %4 ], [ %47, %42 ]
%29 = phi i32 [ 0, %4 ], [ %46, %42 ]
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %19
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %20
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %21
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %22
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %23
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %24
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %25
store <2 x double> <double 0x41CDCD64FF800000, double 0x41CDCD64FF800000>, <2 x double>* %26
%30 = trunc i64 %28 to i32
br label %31
31: ; preds = %27, %39
%32 = phi i64 [ 0, %27 ], [ %40, %39 ]
%33 = icmp eq i64 %28, %32
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = trunc i64 %32 to i32
%36 = call double @distance(double* %0, double* %1, double* %2, i32 %30, i32 %35)
%37 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %32
store i32 %35, i32* %37
%38 = getelementptr inbounds [16 x double], [16 x double]* %7, i64 0, i64 %32
store double %36, double* %38
br label %39
39: ; preds = %31, %34
%40 = add nuw nsw i64 %32, 1
%41 = icmp eq i64 %40, 16
br i1 %41, label %42, label %31
42: ; preds = %39
%43 = trunc i64 %28 to i32
%44 = call i64 @populateNeighborList(double* %9, i32* %10, i32 %43, i32** %11)
%45 = trunc i64 %44 to i32
%46 = add i32 %29, %45
%47 = add nuw nsw i64 %28, 1
%48 = icmp eq i64 %47, 256
br i1 %48, label %49, label %27
49: ; preds = %42
ret i32 %46
}