#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 f(double *, unsigned int const, void *);
double best_nearby(double *delta, double *point, const double prevbest,
                   const unsigned int nvars, void *__fun_evals) {
  double minf;
  double z[250];
  double ftmp;
  unsigned 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, __fun_evals);
    if (ftmp < minf) {
      minf = ftmp;
    } else {
      delta[i] = 0.0 - delta[i];
      z[i] = point[i] + delta[i];
      ftmp = f(z, nvars, __fun_evals);
      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)
mov    %rcx,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1184 <best_nearby+0x74>
mov    -0x10(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80c(%rbp),%eax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    1143 <best_nearby+0x33>
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    12dc <best_nearby+0x1cc>
mov    -0x10(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x80c(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x80c(%rbp),%eax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
lea    -0x800(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <f@plt>
movsd  %xmm0,-0x808(%rbp)
ff
movsd  -0x808(%rbp),%xmm1
ff
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    120e <best_nearby+0xfe>
movsd  -0x808(%rbp),%xmm0
ff
movsd  %xmm0,-0x30(%rbp)
jmp    12c3 <best_nearby+0x1b3>
mov    -0x8(%rbp),%rax
mov    -0x80c(%rbp),%ecx
xorps  %xmm0,%xmm0
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x80c(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x80c(%rbp),%eax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
lea    -0x800(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <f@plt>
movsd  %xmm0,-0x808(%rbp)
ff
movsd  -0x808(%rbp),%xmm1
ff
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a0 <best_nearby+0x190>
movsd  -0x808(%rbp),%xmm0
ff
movsd  %xmm0,-0x30(%rbp)
jmp    12be <best_nearby+0x1ae>
mov    -0x10(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80c(%rbp),%eax
movsd  %xmm0,-0x800(%rbp,%rax,8)
ff ff
jmp    12c3 <best_nearby+0x1b3>
jmp    12c8 <best_nearby+0x1b8>
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    118e <best_nearby+0x7e>
movl   $0x0,-0x80c(%rbp)
mov    -0x80c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1327 <best_nearby+0x217>
mov    -0x80c(%rbp),%eax
movsd  -0x800(%rbp,%rax,8),%xmm0
ff ff
mov    -0x10(%rbp),%rax
mov    -0x80c(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x80c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80c(%rbp)
jmp    12e6 <best_nearby+0x1d6>
movsd  -0x30(%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
je     122b <best_nearby+0x10b>
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %edx,%r14d
lea    0x0(,%r14,8),%rdx
lea    0x10(%rsp),%rdi
movsd  %xmm0,0x8(%rsp)
call   1040 <memcpy@plt>
movsd  0x8(%rsp),%xmm0
xor    %r13d,%r13d
jmp    117d <best_nearby+0x5d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%r14
je     1206 <best_nearby+0xe6>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%r13,8),%xmm0
addsd  0x0(%rbp,%r13,8),%xmm0
movsd  %xmm0,0x10(%rsp,%r13,8)
lea    0x10(%rsp),%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1030 <f@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <best_nearby+0x50>
xorpd  %xmm0,%xmm0
subsd  0x0(%rbp,%r13,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r13,8)
addsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,0x10(%rsp,%r13,8)
lea    0x10(%rsp),%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1030 <f@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm0,%xmm1
ja     1170 <best_nearby+0x50>
movsd  (%rbx,%r13,8),%xmm0
movsd  %xmm0,0x10(%rsp,%r13,8)
movsd  0x8(%rsp),%xmm0
jmp    1170 <best_nearby+0x50>
test   %r12d,%r12d
je     122b <best_nearby+0x10b>
shl    $0x3,%r14
lea    0x10(%rsp),%rsi
mov    %rbx,%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, i8* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca i8*
%11 = alloca double
%12 = alloca [250 x double]
%13 = alloca double
%14 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%15 = load double, double* %8
store double %15, double* %11
store i32 0, i32* %14
br label %16
16: ; preds = %29, %5
%17 = load i32, i32* %14
%18 = load i32, i32* %9
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load double*, double** %7
%22 = load i32, i32* %14
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load i32, i32* %14
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 %27
store double %25, double* %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %14
%31 = add i32 %30, 1
store i32 %31, i32* %14
br label %16
32: ; preds = %16
store i32 0, i32* %14
br label %33
33: ; preds = %106, %32
%34 = load i32, i32* %14
%35 = load i32, i32* %9
%36 = icmp ult i32 %34, %35
br i1 %36, label %37, label %109
37: ; preds = %33
%38 = load double*, double** %7
%39 = load i32, i32* %14
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %6
%44 = load i32, i32* %14
%45 = zext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fadd double %42, %47
%49 = load i32, i32* %14
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 %50
store double %48, double* %51
%52 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 0
%53 = load i32, i32* %9
%54 = load i8*, i8** %10
%55 = call double @f(double* %52, i32 %53, i8* %54)
store double %55, double* %13
%56 = load double, double* %13
%57 = load double, double* %11
%58 = fcmp olt double %56, %57
br i1 %58, label %59, label %61
59: ; preds = %37
%60 = load double, double* %13
store double %60, double* %11
br label %105
61: ; preds = %37
%62 = load double*, double** %6
%63 = load i32, i32* %14
%64 = zext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = fsub double 0.000000e+00, %66
%68 = load double*, double** %6
%69 = load i32, i32* %14
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = load double*, double** %7
%73 = load i32, i32* %14
%74 = zext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = load double*, double** %6
%78 = load i32, i32* %14
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fadd double %76, %81
%83 = load i32, i32* %14
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 %84
store double %82, double* %85
%86 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 0
%87 = load i32, i32* %9
%88 = load i8*, i8** %10
%89 = call double @f(double* %86, i32 %87, i8* %88)
store double %89, double* %13
%90 = load double, double* %13
%91 = load double, double* %11
%92 = fcmp olt double %90, %91
br i1 %92, label %93, label %95
93: ; preds = %61
%94 = load double, double* %13
store double %94, double* %11
br label %104
95: ; preds = %61
%96 = load double*, double** %7
%97 = load i32, i32* %14
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds double, double* %96, i64 %98
%100 = load double, double* %99
%101 = load i32, i32* %14
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 %102
store double %100, double* %103
br label %104
104: ; preds = %95, %93
br label %105
105: ; preds = %104, %59
br label %106
106: ; preds = %105
%107 = load i32, i32* %14
%108 = add i32 %107, 1
store i32 %108, i32* %14
br label %33
109: ; preds = %33
store i32 0, i32* %14
br label %110
110: ; preds = %123, %109
%111 = load i32, i32* %14
%112 = load i32, i32* %9
%113 = icmp ult i32 %111, %112
br i1 %113, label %114, label %126
114: ; preds = %110
%115 = load i32, i32* %14
%116 = zext i32 %115 to i64
%117 = getelementptr inbounds [250 x double], [250 x double]* %12, i64 0, i64 %116
%118 = load double, double* %117
%119 = load double*, double** %7
%120 = load i32, i32* %14
%121 = zext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
store double %118, double* %122
br label %123
123: ; preds = %114
%124 = load i32, i32* %14
%125 = add i32 %124, 1
store i32 %125, i32* %14
br label %110
126: ; preds = %110
%127 = load double, double* %11
ret double %127
}

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