#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 buildNeighborList(int *, int *, int *, int **);
int /*<<< orphan*/ md(int *, int *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int, int);
int rand();
int /*<<< orphan*/ srand(long);
int main() {
  int sizeClass, passes, iter, nAtom, err, localSize, globalSize, i, j,
      totalPairs;
  int probSizes[4] = {12288, 24576, 36864, 73728};
  sizeClass = 1;
  passes = 1;
  iter = 1;
  err = 0;
  localSize = 128;
  globalSize = 32;
  srand(8650341L);
  int position_x[32];
  int position_y[32];
  int position_z[32];
  int force_x[32];
  int force_y[32];
  int force_z[32];
  int NL[32][32];
  int neighborList[32 * 32];
  for (i = 0; i < 32; i++) {
    position_x[i] = rand();
    position_y[i] = rand();
    position_z[i] = rand();
  }
  for (i = 0; i < 32; i++) {
    for (j = 0; j < 32; ++j) {
      NL[i][j] = 0;
    }
  }
  totalPairs = buildNeighborList(position_x, position_y, position_z, NL);
  for (i = 0; i < 32; i++) {
    for (j = 0; j < 32; ++j)
      neighborList[i * 32 + j] = NL[i][j];
  }
  md(force_x, force_y, force_z, position_x, position_y, position_z,
     neighborList);
  for (i = 0; i < 32; i++) {
    printf("after, X:%i Y:%i Z%i \n", force_x[i], force_y[i], force_z[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2350,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x80,-0x1c(%rbp)
movl   $0x20,-0x20(%rbp)
mov    $0x83fe65,%edi
call   1050 <srand@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jge    1207 <main+0xb7>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0xc0(%rbp,%rax,4)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x140(%rbp,%rax,4)
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x1c0(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b3 <main+0x63>
movl   $0x0,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jge    1267 <main+0x117>
movl   $0x0,-0x28(%rbp)
cmpl   $0x20,-0x28(%rbp)
jge    1254 <main+0x104>
movslq -0x24(%rbp),%rcx
lea    -0x1340(%rbp),%rax
shl    $0x7,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121f <main+0xcf>
jmp    1259 <main+0x109>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <main+0xbe>
lea    -0xc0(%rbp),%rdi
lea    -0x140(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
lea    -0x1340(%rbp),%rcx
call   1040 <buildNeighborList@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jge    12f9 <main+0x1a9>
movl   $0x0,-0x28(%rbp)
cmpl   $0x20,-0x28(%rbp)
jge    12e6 <main+0x196>
movslq -0x24(%rbp),%rcx
lea    -0x1340(%rbp),%rax
shl    $0x7,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x24(%rbp),%eax
shl    $0x5,%eax
add    -0x28(%rbp),%eax
cltq
mov    %ecx,-0x2340(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12a3 <main+0x153>
jmp    12eb <main+0x19b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1292 <main+0x142>
lea    -0x240(%rbp),%rdi
lea    -0x2c0(%rbp),%rsi
lea    -0x340(%rbp),%rdx
lea    -0xc0(%rbp),%rcx
lea    -0x140(%rbp),%r8
lea    -0x1c0(%rbp),%r9
lea    -0x2340(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <md@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x20,-0x24(%rbp)
jge    137f <main+0x22f>
movslq -0x24(%rbp),%rax
mov    -0x240(%rbp,%rax,4),%esi
movslq -0x24(%rbp),%rax
mov    -0x2c0(%rbp,%rax,4),%edx
movslq -0x24(%rbp),%rax
mov    -0x340(%rbp,%rax,4),%ecx
lea    0xca4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    133a <main+0x1ea>
xor    %eax,%eax
add    $0x2350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2318,%rsp
mov    $0x83fe65,%edi
call   1060 <srand@plt>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,0x290(%rsp,%rbx,4)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,0x210(%rsp,%rbx,4)
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,0x190(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    1190 <main+0x20>
lea    0x1310(%rsp),%r13
xor    %ebp,%ebp
mov    $0x1000,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0x290(%rsp),%r14
lea    0x210(%rsp),%r15
lea    0x190(%rsp),%r12
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1040 <buildNeighborList@plt>
lea    0x310(%rsp),%rbx
mov    $0x1000,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <memcpy@plt>
mov    %rbx,(%rsp)
lea    0x110(%rsp),%rdi
lea    0x90(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r14,%rcx
mov    %r15,%r8
mov    %r12,%r9
call   1070 <md@plt>
lea    0xdb4(%rip),%rbx
nopl   0x0(%rax)
mov    0x110(%rsp,%rbp,4),%esi
mov    0x90(%rsp,%rbp,4),%edx
mov    0x10(%rsp,%rbp,4),%ecx
mov    %rbx,%rdi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    $0x20,%rbp
jne    1250 <main+0xe0>
xor    %eax,%eax
add    $0x2318,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.probSizes = [4 x i32] [i32 12288, i32 24576, i32 36864, i32 73728]
@.str = [23 x i8] c"after, X:%i Y:%i Z%i \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x i32]
%13 = alloca [32 x i32]
%14 = alloca [32 x i32]
%15 = alloca [32 x i32]
%16 = alloca [32 x i32]
%17 = alloca [32 x i32]
%18 = alloca [32 x i32]
%19 = alloca [32 x [32 x i32]]
%20 = alloca [1024 x i32]
store i32 0, i32* %1
%21 = bitcast [4 x i32]* %12 to i8*
store i32 1, i32* %2
store i32 1, i32* %3
store i32 1, i32* %4
store i32 0, i32* %6
store i32 128, i32* %7
store i32 32, i32* %8
%22 = call i32 @srand(i64 8650341)
store i32 0, i32* %9
br label %23
23: ; preds = %39, %0
%24 = load i32, i32* %9
%25 = icmp slt i32 %24, 32
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = call i32 (...) @rand()
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 %29
store i32 %27, i32* %30
%31 = call i32 (...) @rand()
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 %33
store i32 %31, i32* %34
%35 = call i32 (...) @rand()
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %26
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %23
42: ; preds = %23
store i32 0, i32* %9
br label %43
43: ; preds = %61, %42
%44 = load i32, i32* %9
%45 = icmp slt i32 %44, 32
br i1 %45, label %46, label %64
46: ; preds = %43
store i32 0, i32* %10
br label %47
47: ; preds = %57, %46
%48 = load i32, i32* %10
%49 = icmp slt i32 %48, 32
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [32 x [32 x i32]], [32 x [32 x i32]]* %19, i64 0, i64 %52
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [32 x i32], [32 x i32]* %53, i64 0, i64 %55
store i32 0, i32* %56
br label %57
57: ; preds = %50
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %47
60: ; preds = %47
br label %61
61: ; preds = %60
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %43
64: ; preds = %43
%65 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 0
%66 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 0
%67 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%68 = getelementptr inbounds [32 x [32 x i32]], [32 x [32 x i32]]* %19, i64 0, i64 0
%69 = bitcast [32 x i32]* %68 to i32**
%70 = call i32 @buildNeighborList(i32* %65, i32* %66, i32* %67, i32** %69)
store i32 %70, i32* %11
store i32 0, i32* %9
br label %71
71: ; preds = %96, %64
%72 = load i32, i32* %9
%73 = icmp slt i32 %72, 32
br i1 %73, label %74, label %99
74: ; preds = %71
store i32 0, i32* %10
br label %75
75: ; preds = %92, %74
%76 = load i32, i32* %10
%77 = icmp slt i32 %76, 32
br i1 %77, label %78, label %95
78: ; preds = %75
%79 = load i32, i32* %9
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [32 x [32 x i32]], [32 x [32 x i32]]* %19, i64 0, i64 %80
%82 = load i32, i32* %10
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [32 x i32], [32 x i32]* %81, i64 0, i64 %83
%85 = load i32, i32* %84
%86 = load i32, i32* %9
%87 = mul nsw i32 %86, 32
%88 = load i32, i32* %10
%89 = add nsw i32 %87, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 %90
store i32 %85, i32* %91
br label %92
92: ; preds = %78
%93 = load i32, i32* %10
%94 = add nsw i32 %93, 1
store i32 %94, i32* %10
br label %75
95: ; preds = %75
br label %96
96: ; preds = %95
%97 = load i32, i32* %9
%98 = add nsw i32 %97, 1
store i32 %98, i32* %9
br label %71
99: ; preds = %71
%100 = getelementptr inbounds [32 x i32], [32 x i32]* %16, i64 0, i64 0
%101 = getelementptr inbounds [32 x i32], [32 x i32]* %17, i64 0, i64 0
%102 = getelementptr inbounds [32 x i32], [32 x i32]* %18, i64 0, i64 0
%103 = getelementptr inbounds [32 x i32], [32 x i32]* %13, i64 0, i64 0
%104 = getelementptr inbounds [32 x i32], [32 x i32]* %14, i64 0, i64 0
%105 = getelementptr inbounds [32 x i32], [32 x i32]* %15, i64 0, i64 0
%106 = getelementptr inbounds [1024 x i32], [1024 x i32]* %20, i64 0, i64 0
%107 = call i32 @md(i32* %100, i32* %101, i32* %102, i32* %103, i32* %104, i32* %105, i32* %106)
store i32 0, i32* %9
br label %108
108: ; preds = %125, %99
%109 = load i32, i32* %9
%110 = icmp slt i32 %109, 32
br i1 %110, label %111, label %128
111: ; preds = %108
%112 = load i32, i32* %9
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [32 x i32], [32 x i32]* %16, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = load i32, i32* %9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [32 x i32], [32 x i32]* %17, i64 0, i64 %117
%119 = load i32, i32* %118
%120 = load i32, i32* %9
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [32 x i32], [32 x i32]* %18, i64 0, i64 %121
%123 = load i32, i32* %122
%124 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %115, i32 %119, i32 %123)
br label %125
125: ; preds = %111
%126 = load i32, i32* %9
%127 = add nsw i32 %126, 1
store i32 %127, i32* %9
br label %108
128: ; preds = %108
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"after, X:%i Y:%i Z%i \0A\00"
define i32 @main() {
%1 = alloca [32 x i32]
%2 = alloca [32 x i32]
%3 = alloca [32 x i32]
%4 = alloca [32 x i32]
%5 = alloca [32 x i32]
%6 = alloca [32 x i32]
%7 = alloca [32 x [32 x i32]]
%8 = bitcast [32 x [32 x i32]]* %7 to i8*
%9 = alloca [1024 x i32]
%10 = bitcast [1024 x i32]* %9 to i8*
%11 = tail call i32 @srand(i64 8650341)
%12 = bitcast [32 x i32]* %1 to i8*
%13 = bitcast [32 x i32]* %2 to i8*
%14 = bitcast [32 x i32]* %3 to i8*
%15 = bitcast [32 x i32]* %4 to i8*
%16 = bitcast [32 x i32]* %5 to i8*
%17 = bitcast [32 x i32]* %6 to i8*
br label %18
18: ; preds = %0, %18
%19 = phi i64 [ 0, %0 ], [ %26, %18 ]
%20 = tail call i32 (...) @rand()
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 %19
store i32 %20, i32* %21
%22 = tail call i32 (...) @rand()
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 %19
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %19
store i32 %24, i32* %25
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, 32
br i1 %27, label %28, label %18
28: ; preds = %18
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %1, i64 0, i64 0
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %2, i64 0, i64 0
%31 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%32 = bitcast [32 x [32 x i32]]* %7 to i32**
%33 = call i32 @buildNeighborList(i32* %29, i32* %30, i32* %31, i32** %32)
%34 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 0
%35 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 0
%36 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%37 = getelementptr inbounds [1024 x i32], [1024 x i32]* %9, i64 0, i64 0
%38 = call i32 @md(i32* %34, i32* %35, i32* %36, i32* %29, i32* %30, i32* %31, i32* %37)
br label %39
39: ; preds = %28, %39
%40 = phi i64 [ 0, %28 ], [ %48, %39 ]
%41 = getelementptr inbounds [32 x i32], [32 x i32]* %4, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = getelementptr inbounds [32 x i32], [32 x i32]* %5, i64 0, i64 %40
%44 = load i32, i32* %43
%45 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 %40
%46 = load i32, i32* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %42, i32 %44, i32 %46)
%48 = add nuw nsw i64 %40, 1
%49 = icmp eq i64 %48, 32
br i1 %49, label %50, label %39
50: ; preds = %39
ret i32 0
}