void objfn(double (*fun)(double *, void *), void *adar, int n, int m, double *x,
           double *lb, double *ub, double *fx) {
  int j;
  for (j = 0; j < m; j++) {
    fx[j] = fun(x + j * n, adar);
  }
}


x86 assembly (clang, -O0):
<objfn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1173 <objfn+0x73>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
imul   -0x14(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112d <objfn+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<objfn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    1150 <objfn+0x50>
mov    %r8,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movslq %edx,%r13
mov    %ecx,%ebp
shl    $0x3,%r13
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   *%r15
mov    0x48(%rsp),%rax
movsd  %xmm0,(%rax,%r12,8)
add    $0x1,%r12
add    %r13,%rbx
cmp    %r12,%rbp
jne    1130 <objfn+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @objfn(double (double*, i8*)* nocapture %0, i8* %1, i32 %2, i32 %3, double* %4, double* nocapture readnone %5, double* nocapture readnone %6, double* nocapture writeonly %7) {
%9 = icmp sgt i32 %3, 0
br i1 %9, label %10, label %21
10: ; preds = %8
%11 = sext i32 %2 to i64
%12 = zext i32 %3 to i64
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %19, %13 ]
%15 = mul nsw i64 %14, %11
%16 = getelementptr inbounds double, double* %4, i64 %15
%17 = tail call double %0(double* %16, i8* %1)
%18 = getelementptr inbounds double, double* %7, i64 %14
store double %17, double* %18
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %8
ret void
}