void nbr_check_distance(int num_neighbors, const int *restrict nbr_add,
                        double *restrict nbr_dist) {
  int nchk;
  double distance;
  for (nchk = 0; nchk < num_neighbors; ++nchk) {
    if (nbr_add[nchk] >= 0) {
      distance = nbr_dist[nchk];
      if ((!(distance < 0. || 0. < distance)))
        distance = 1.e-14;
      nbr_dist[nchk] = distance;
    }
  }
}


x86 assembly (clang, -O0):
<nbr_check_distance>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1198 <nbr_check_distance+0x98>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1185 <nbr_check_distance+0x85>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
ja     1173 <nbr_check_distance+0x73>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
ja     1173 <nbr_check_distance+0x73>
movsd  0xe92(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    118a <nbr_check_distance+0x8a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <nbr_check_distance+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbr_check_distance>:
test   %edi,%edi
jle    1134 <nbr_check_distance+0x34>
mov    %edi,%ecx
cmp    $0x1,%edi
jne    1135 <nbr_check_distance+0x35>
xor    %eax,%eax
test   $0x1,%cl
je     1134 <nbr_check_distance+0x34>
cmpl   $0x0,(%rsi,%rax,4)
js     1134 <nbr_check_distance+0x34>
movsd  (%rdx,%rax,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jne    112f <nbr_check_distance+0x2f>
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
ret
mov    %ecx,%edi
and    $0xfffffffe,%edi
xor    %eax,%eax
xorpd  %xmm0,%xmm0
movsd  0xeb8(%rip),%xmm1
jmp    115f <nbr_check_distance+0x5f>
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x8(%rdx,%rax,8)
add    $0x2,%rax
cmp    %rax,%rdi
je     110d <nbr_check_distance+0xd>
cmpl   $0x0,(%rsi,%rax,4)
js     1179 <nbr_check_distance+0x79>
movsd  (%rdx,%rax,8),%xmm2
ucomisd %xmm2,%xmm0
jne    1174 <nbr_check_distance+0x74>
movapd %xmm1,%xmm2
movsd  %xmm2,(%rdx,%rax,8)
cmpl   $0x0,0x4(%rsi,%rax,4)
js     1156 <nbr_check_distance+0x56>
movsd  0x8(%rdx,%rax,8),%xmm2
ucomisd %xmm2,%xmm0
jne    1150 <nbr_check_distance+0x50>
movapd %xmm1,%xmm2
jmp    1150 <nbr_check_distance+0x50>

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

LLVM IR (-O2):
define void @nbr_check_distance(i32 %0, i32* noalias nocapture %1, double* noalias nocapture %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %48
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = and i64 %6, 1
%8 = icmp eq i32 %0, 1
br i1 %8, label %36, label %9
9: ; preds = %5
%10 = and i64 %6, 4294967294
br label %11
11: ; preds = %32, %9
%12 = phi i64 [ 0, %9 ], [ %33, %32 ]
%13 = phi i64 [ 0, %9 ], [ %34, %32 ]
%14 = getelementptr inbounds i32, i32* %1, i64 %12
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, -1
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = getelementptr inbounds double, double* %2, i64 %12
%19 = load double, double* %18
%20 = fcmp one double %19, 0.000000e+00
%21 = select i1 %20, double %19, double 0x3D06849B86A12B9B
store double %21, double* %18
br label %22
22: ; preds = %11, %17
%23 = or i64 %12, 1
%24 = getelementptr inbounds i32, i32* %1, i64 %23
%25 = load i32, i32* %24
%26 = icmp sgt i32 %25, -1
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = getelementptr inbounds double, double* %2, i64 %23
%29 = load double, double* %28
%30 = fcmp one double %29, 0.000000e+00
%31 = select i1 %30, double %29, double 0x3D06849B86A12B9B
store double %31, double* %28
br label %32
32: ; preds = %27, %22
%33 = add nuw nsw i64 %12, 2
%34 = add i64 %13, 2
%35 = icmp eq i64 %34, %10
br i1 %35, label %36, label %11
36: ; preds = %32, %5
%37 = phi i64 [ 0, %5 ], [ %33, %32 ]
%38 = icmp eq i64 %7, 0
br i1 %38, label %48, label %39
39: ; preds = %36
%40 = getelementptr inbounds i32, i32* %1, i64 %37
%41 = load i32, i32* %40
%42 = icmp sgt i32 %41, -1
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = getelementptr inbounds double, double* %2, i64 %37
%45 = load double, double* %44
%46 = fcmp one double %45, 0.000000e+00
%47 = select i1 %46, double %45, double 0x3D06849B86A12B9B
store double %47, double* %44
br label %48
48: ; preds = %36, %43, %39, %3
ret void
}