double best_nearby(delta, point, prevbest, nvars)
double delta[250];
double point[250];
double prevbest;
{
  double minf;
  double z[250];
  double ftmp;
  int i;
  minf = prevbest;
  for (i = 0; i < nvars; i++) {
    z[i] = point[i];
  }
  for (i = 0; i < nvars; i++) {
    z[i] = point[i] + delta[i];
    ftmp = f(z, nvars);
    if (ftmp < minf) {
      minf = ftmp;
    } else {
      delta[i] = 0.0 - delta[i];
      z[i] = point[i] + delta[i];
      ftmp = f(z, nvars);
      if (ftmp < minf) {
        minf = ftmp;
      } else {
        z[i] = point[i];
      }
    }
  }
  for (i = 0; i < nvars; i++) {
    point[i] = z[i];
  }
  return minf;
}


x86 assembly (clang, -O0):
<best_nearby>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1182 <best_nearby+0x72>
mov    -0x10(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x80c(%rbp),%rax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    113f <best_nearby+0x2f>
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12e8 <best_nearby+0x1d8>
mov    -0x10(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x80c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movslq -0x80c(%rbp),%rax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
lea    -0x800(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1030 <f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x808(%rbp)
ff
movsd  -0x808(%rbp),%xmm1
ff
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1211 <best_nearby+0x101>
movsd  -0x808(%rbp),%xmm0
ff
movsd  %xmm0,-0x28(%rbp)
jmp    12cf <best_nearby+0x1bf>
mov    -0x8(%rbp),%rax
movslq -0x80c(%rbp),%rcx
xorps  %xmm0,%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x80c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movslq -0x80c(%rbp),%rax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
lea    -0x800(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1030 <f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x808(%rbp)
ff
movsd  -0x808(%rbp),%xmm1
ff
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12aa <best_nearby+0x19a>
movsd  -0x808(%rbp),%xmm0
ff
movsd  %xmm0,-0x28(%rbp)
jmp    12ca <best_nearby+0x1ba>
mov    -0x10(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x80c(%rbp),%rax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
jmp    12cf <best_nearby+0x1bf>
jmp    12d4 <best_nearby+0x1c4>
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    118c <best_nearby+0x7c>
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1335 <best_nearby+0x225>
movslq -0x80c(%rbp),%rax
movsd  -0x800(%rbp,%rax,8),%xmm0
ff ff
mov    -0x10(%rbp),%rax
movslq -0x80c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    12f2 <best_nearby+0x1e2>
movsd  -0x28(%rbp),%xmm0
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<best_nearby>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7e8,%rsp
test   %edx,%edx
jle    1234 <best_nearby+0x114>
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %edx,%r14d
lea    0x0(,%r14,8),%rdx
lea    0x10(%rsp),%r12
mov    %r12,%rdi
movsd  %xmm0,0x8(%rsp)
call   1040 <memcpy@plt>
movsd  0x8(%rsp),%xmm0
xor    %ebx,%ebx
jmp    117d <best_nearby+0x5d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     120f <best_nearby+0xef>
movsd  %xmm0,0x8(%rsp)
movsd  0x0(%r13,%rbx,8),%xmm0
addsd  0x0(%rbp,%rbx,8),%xmm0
movsd  %xmm0,0x10(%rsp,%rbx,8)
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <best_nearby+0x50>
xorpd  %xmm0,%xmm0
subsd  0x0(%rbp,%rbx,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
addsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,0x10(%rsp,%rbx,8)
mov    %r12,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <best_nearby+0x50>
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,0x10(%rsp,%rbx,8)
movsd  0x8(%rsp),%xmm0
jmp    1170 <best_nearby+0x50>
test   %r15d,%r15d
jle    1234 <best_nearby+0x114>
shl    $0x3,%r14
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
mov    %r14,%rdx
movsd  %xmm0,0x8(%rsp)
call   1040 <memcpy@plt>
movsd  0x8(%rsp),%xmm0
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @best_nearby(double* nocapture %0, double* nocapture %1, double %2, i32 %3) {
%5 = bitcast double* %1 to i8*
%6 = alloca [250 x double]
%7 = bitcast [250 x double]* %6 to i8*
%8 = icmp sgt i32 %3, 0
br i1 %8, label %9, label %44
9: ; preds = %4
%10 = zext i32 %3 to i64
%11 = shl nuw nsw i64 %10, 3
%12 = getelementptr inbounds [250 x double], [250 x double]* %6, i64 0, i64 0
%13 = zext i32 %3 to i64
br label %18
14: ; preds = %40
br i1 %8, label %15, label %44
15: ; preds = %14
%16 = zext i32 %3 to i64
%17 = shl nuw nsw i64 %16, 3
br label %44
18: ; preds = %9, %40
%19 = phi i64 [ 0, %9 ], [ %42, %40 ]
%20 = phi double [ %2, %9 ], [ %41, %40 ]
%21 = getelementptr inbounds double, double* %1, i64 %19
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %0, i64 %19
%24 = load double, double* %23
%25 = fadd double %22, %24
%26 = getelementptr inbounds [250 x double], [250 x double]* %6, i64 0, i64 %19
store double %25, double* %26
%27 = call i32 (double*, i32, ...) bitcast (i32 (...)* @f to i32 (double*, i32, ...)*)(double* %12, i32 %3)
%28 = sitofp i32 %27 to double
%29 = fcmp ogt double %20, %28
br i1 %29, label %40, label %30
30: ; preds = %18
%31 = load double, double* %23
%32 = fsub double 0.000000e+00, %31
store double %32, double* %23
%33 = load double, double* %21
%34 = fadd double %32, %33
store double %34, double* %26
%35 = call i32 (double*, i32, ...) bitcast (i32 (...)* @f to i32 (double*, i32, ...)*)(double* %12, i32 %3)
%36 = sitofp i32 %35 to double
%37 = fcmp ogt double %20, %36
br i1 %37, label %40, label %38
38: ; preds = %30
%39 = load double, double* %21
store double %39, double* %26
br label %40
40: ; preds = %30, %18, %38
%41 = phi double [ %20, %38 ], [ %28, %18 ], [ %36, %30 ]
%42 = add nuw nsw i64 %19, 1
%43 = icmp eq i64 %42, %13
br i1 %43, label %14, label %18
44: ; preds = %4, %15, %14
%45 = phi double [ %41, %15 ], [ %41, %14 ], [ %2, %4 ]
ret double %45
}