#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 */
void lcfit2_evaluate_fn(double (*lnl_fn)(double, void *), void *lnl_fn_args,
                        const size_t n, const double *t, double *lnl) {
  for (size_t i = 0; i < n; ++i) {
    lnl[i] = lnl_fn(t[i], lnl_fn_args);
  }
}


x86 assembly (clang, -O0):
<lcfit2_evaluate_fn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1167 <lcfit2_evaluate_fn+0x67>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x10(%rbp),%rdi
call   *%rax
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1124 <lcfit2_evaluate_fn+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcfit2_evaluate_fn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     114b <lcfit2_evaluate_fn+0x4b>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rbp,8),%xmm0
mov    %r12,%rdi
call   *%r13
movsd  %xmm0,(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <lcfit2_evaluate_fn+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lcfit2_evaluate_fn(double (double, i8*)* %0, i8* %1, i64 %2, double* %3, double* %4) {
%6 = alloca double (double, i8*)*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca double*
%10 = alloca double*
%11 = alloca i64
store double (double, i8*)* %0, double (double, i8*)** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store double* %3, double** %9
store double* %4, double** %10
store i64 0, i64* %11
br label %12
12: ; preds = %27, %5
%13 = load i64, i64* %11
%14 = load i64, i64* %8
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load double (double, i8*)*, double (double, i8*)** %6
%18 = load double*, double** %9
%19 = load i64, i64* %11
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = load double, double* %20
%22 = load i8*, i8** %7
%23 = call double %17(double %21, i8* %22)
%24 = load double*, double** %10
%25 = load i64, i64* %11
%26 = getelementptr inbounds double, double* %24, i64 %25
store double %23, double* %26
br label %27
27: ; preds = %16
%28 = load i64, i64* %11
%29 = add i64 %28, 1
store i64 %29, i64* %11
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @lcfit2_evaluate_fn(double (double, i8*)* nocapture %0, i8* %1, i64 %2, double* nocapture %3, double* nocapture writeonly %4) {
%6 = icmp eq i64 %2, 0
br i1 %6, label %7, label %8
7: ; preds = %8, %5
ret void
8: ; preds = %5, %8
%9 = phi i64 [ %14, %8 ], [ 0, %5 ]
%10 = getelementptr inbounds double, double* %3, i64 %9
%11 = load double, double* %10
%12 = tail call double %0(double %11, i8* %1)
%13 = getelementptr inbounds double, double* %4, i64 %9
store double %12, double* %13
%14 = add nuw i64 %9, 1
%15 = icmp eq i64 %14, %2
br i1 %15, label %7, label %8
}