#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 abs(int);
double sqrt(double);
void c_connections(int natoms, double *x, double *y, double *z,
                   double *atom_radii, int max_atoms_molecule, int *connected,
                   int iwidth) {
  double temp_distance;
  int i, j;
  int bondNum = 0;
  for (i = 0; i < natoms; i++) {
    bondNum = 0;
#pragma omp parallel for ordered
    for (j = 0; j < natoms; j++) {
      if (abs(i - j) < max_atoms_molecule) {
        temp_distance =
            sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) +
                 (z[i] - z[j]) * (z[i] - z[j]));
        if (temp_distance <= (1.5 * (atom_radii[i] + atom_radii[j]))) {
          connected[i * iwidth + bondNum] = j;
          bondNum++;
        }
      }
    }
  }
  return;
}


x86 assembly (clang, -O0):
<c_connections>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c8 <c_connections+0x1a8>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b5 <c_connections+0x195>
mov    -0x3c(%rbp),%edi
sub    -0x40(%rbp),%edi
call   1030 <abs@plt>
cmp    -0x2c(%rbp),%eax
jge    12a2 <c_connections+0x182>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x40(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm2
movsd  0xd91(%rip),%xmm0
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     129d <c_connections+0x17d>
mov    -0x40(%rbp),%edx
mov    0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   0x18(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12a2 <c_connections+0x182>
jmp    12a7 <c_connections+0x187>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    116e <c_connections+0x4e>
jmp    12ba <c_connections+0x19a>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1154 <c_connections+0x34>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_connections>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
jle    1241 <c_connections+0x131>
mov    %r8,%rbp
mov    %rdx,%r14
mov    %edi,%r13d
xor    %ebx,%ebx
xorpd  %xmm2,%xmm2
movsd  0xec3(%rip),%xmm3
mov    %rsi,0x10(%rsp)
mov    %r9d,0x4(%rsp)
mov    %rcx,0x8(%rsp)
jmp    115d <c_connections+0x4d>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %r13,%rbx
je     1241 <c_connections+0x131>
mov    %ebx,%eax
imul   0x68(%rsp),%eax
mov    %rax,0x18(%rsp)
mov    %ebx,%r15d
xor    %r12d,%r12d
xor    %r11d,%r11d
jmp    118d <c_connections+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12
add    $0xffffffff,%r15d
cmp    %r12,%r13
je     1150 <c_connections+0x40>
mov    %r15d,%eax
neg    %eax
cmovs  %r15d,%eax
cmp    %r9d,%eax
jge    1180 <c_connections+0x70>
movsd  (%rsi,%rbx,8),%xmm1
subsd  (%rsi,%r12,8),%xmm1
movsd  (%r14,%rbx,8),%xmm0
subsd  (%r14,%r12,8),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  (%rcx,%rbx,8),%xmm0
subsd  (%rcx,%r12,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     11e0 <c_connections+0xd0>
sqrtsd %xmm0,%xmm0
jmp    120a <c_connections+0xfa>
nopl   (%rax)
mov    %r11,0x20(%rsp)
call   1030 <sqrt@plt>
mov    0x20(%rsp),%r11
movsd  0xe09(%rip),%xmm3
xorpd  %xmm2,%xmm2
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rcx
mov    0x4(%rsp),%r9d
movsd  0x0(%rbp,%rbx,8),%xmm1
addsd  0x0(%rbp,%r12,8),%xmm1
mulsd  %xmm3,%xmm1
ucomisd %xmm0,%xmm1
jb     1180 <c_connections+0x70>
mov    0x18(%rsp),%rax
add    %r11d,%eax
cltq
mov    0x60(%rsp),%rdi
mov    %r12d,(%rdi,%rax,4)
add    $0x1,%r11d
jmp    1180 <c_connections+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @c_connections(i32 %0, double* %1, double* %2, double* %3, double* %4, i32 %5, i32* %6, i32 %7) {
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 %0, i32* %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store double* %4, double** %13
store i32 %5, i32* %14
store i32* %6, i32** %15
store i32 %7, i32* %16
store i32 0, i32* %20
store i32 0, i32* %18
br label %21
21: ; preds = %140, %8
%22 = load i32, i32* %18
%23 = load i32, i32* %9
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %143
25: ; preds = %21
store i32 0, i32* %20
store i32 0, i32* %19
br label %26
26: ; preds = %136, %25
%27 = load i32, i32* %19
%28 = load i32, i32* %9
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %139
30: ; preds = %26
%31 = load i32, i32* %18
%32 = load i32, i32* %19
%33 = sub nsw i32 %31, %32
%34 = call i32 @abs(i32 %33)
%35 = load i32, i32* %14
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %135
37: ; preds = %30
%38 = load double*, double** %10
%39 = load i32, i32* %18
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %10
%44 = load i32, i32* %19
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fsub double %42, %47
%49 = load double*, double** %10
%50 = load i32, i32* %18
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load double*, double** %10
%55 = load i32, i32* %19
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = fsub double %53, %58
%60 = load double*, double** %11
%61 = load i32, i32* %18
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = load double*, double** %11
%66 = load i32, i32* %19
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = fsub double %64, %69
%71 = load double*, double** %11
%72 = load i32, i32* %18
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
%76 = load double*, double** %11
%77 = load i32, i32* %19
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = fsub double %75, %80
%82 = fmul double %70, %81
%83 = call double @llvm.fmuladd.f64(double %48, double %59, double %82)
%84 = load double*, double** %12
%85 = load i32, i32* %18
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %84, i64 %86
%88 = load double, double* %87
%89 = load double*, double** %12
%90 = load i32, i32* %19
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = fsub double %88, %93
%95 = load double*, double** %12
%96 = load i32, i32* %18
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %95, i64 %97
%99 = load double, double* %98
%100 = load double*, double** %12
%101 = load i32, i32* %19
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %100, i64 %102
%104 = load double, double* %103
%105 = fsub double %99, %104
%106 = call double @llvm.fmuladd.f64(double %94, double %105, double %83)
%107 = call double @sqrt(double %106)
store double %107, double* %17
%108 = load double, double* %17
%109 = load double*, double** %13
%110 = load i32, i32* %18
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load double*, double** %13
%115 = load i32, i32* %19
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds double, double* %114, i64 %116
%118 = load double, double* %117
%119 = fadd double %113, %118
%120 = fmul double 1.500000e+00, %119
%121 = fcmp ole double %108, %120
br i1 %121, label %122, label %134
122: ; preds = %37
%123 = load i32, i32* %19
%124 = load i32*, i32** %15
%125 = load i32, i32* %18
%126 = load i32, i32* %16
%127 = mul nsw i32 %125, %126
%128 = load i32, i32* %20
%129 = add nsw i32 %127, %128
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %124, i64 %130
store i32 %123, i32* %131
%132 = load i32, i32* %20
%133 = add nsw i32 %132, 1
store i32 %133, i32* %20
br label %134
134: ; preds = %122, %37
br label %135
135: ; preds = %134, %30
br label %136
136: ; preds = %135
%137 = load i32, i32* %19
%138 = add nsw i32 %137, 1
store i32 %138, i32* %19
br label %26
139: ; preds = %26
br label %140
140: ; preds = %139
%141 = load i32, i32* %18
%142 = add nsw i32 %141, 1
store i32 %142, i32* %18
br label %21
143: ; preds = %21
ret void
}

LLVM IR (-O2):
define void @c_connections(i32 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, i32 %5, i32* nocapture writeonly %6, i32 %7) {
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %63
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %60, %10
%13 = phi i64 [ 0, %10 ], [ %61, %60 ]
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = getelementptr inbounds double, double* %2, i64 %13
%16 = getelementptr inbounds double, double* %3, i64 %13
%17 = getelementptr inbounds double, double* %4, i64 %13
%18 = trunc i64 %13 to i32
%19 = mul nsw i32 %18, %7
br label %20
20: ; preds = %12, %56
%21 = phi i64 [ 0, %12 ], [ %58, %56 ]
%22 = phi i32 [ 0, %12 ], [ %57, %56 ]
%23 = sub nsw i64 %13, %21
%24 = trunc i64 %23 to i32
%25 = tail call i32 @llvm.abs.i32(i32 %24, i1 true)
%26 = icmp slt i32 %25, %5
br i1 %26, label %27, label %56
27: ; preds = %20
%28 = load double, double* %14
%29 = getelementptr inbounds double, double* %1, i64 %21
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = load double, double* %15
%33 = getelementptr inbounds double, double* %2, i64 %21
%34 = load double, double* %33
%35 = fsub double %32, %34
%36 = fmul double %35, %35
%37 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %36)
%38 = load double, double* %16
%39 = getelementptr inbounds double, double* %3, i64 %21
%40 = load double, double* %39
%41 = fsub double %38, %40
%42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %37)
%43 = tail call double @sqrt(double %42)
%44 = load double, double* %17
%45 = getelementptr inbounds double, double* %4, i64 %21
%46 = load double, double* %45
%47 = fadd double %44, %46
%48 = fmul double %47, 1.500000e+00
%49 = fcmp ugt double %43, %48
br i1 %49, label %56, label %50
50: ; preds = %27
%51 = add nsw i32 %22, %19
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %6, i64 %52
%54 = trunc i64 %21 to i32
store i32 %54, i32* %53
%55 = add nsw i32 %22, 1
br label %56
56: ; preds = %20, %50, %27
%57 = phi i32 [ %55, %50 ], [ %22, %27 ], [ %22, %20 ]
%58 = add nuw nsw i64 %21, 1
%59 = icmp eq i64 %58, %11
br i1 %59, label %60, label %20
60: ; preds = %56
%61 = add nuw nsw i64 %13, 1
%62 = icmp eq i64 %61, %11
br i1 %62, label %63, label %12
63: ; preds = %60, %8
ret void
}