double fisArrayOperation(double *array, int size, double (*fcn)()) {
  int i;
  double out;
  if (size == 0)
    fisError("Given size is zero!");
  out = array[0];
  for (i = 1; i < size; i++)
    out = (*fcn)(out, array[i]);
  return (out);
}


x86 assembly (clang, -O0):
<fisArrayOperation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    113b <fisArrayOperation+0x2b>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <fisError@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <fisArrayOperation+0x78>
mov    -0x18(%rbp),%rcx
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rdx
movsd  (%rax,%rdx,8),%xmm1
mov    $0x2,%al
call   *%rcx
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <fisArrayOperation+0x3f>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fisArrayOperation>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
test   %esi,%esi
je     1156 <fisArrayOperation+0x46>
movsd  (%r14),%xmm0
cmp    $0x2,%esi
jl     1169 <fisArrayOperation+0x59>
mov    %rdx,%r15
mov    %esi,%r12d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm1
mov    $0x2,%al
call   *%r15
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <fisArrayOperation+0x30>
jmp    1169 <fisArrayOperation+0x59>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <fisError@plt>
movsd  (%r14),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Given size is zero!\00"
define double @fisArrayOperation(double* %0, i32 %1, double (...)* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double (...)*
%7 = alloca i32
%8 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double (...)* %2, double (...)** %6
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @fisError to i32 (i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %3
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 0
%16 = load double, double* %15
store double %16, double* %8
store i32 1, i32* %7
br label %17
17: ; preds = %31, %13
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %34
21: ; preds = %17
%22 = load double (...)*, double (...)** %6
%23 = load double, double* %8
%24 = load double*, double** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = bitcast double (...)* %22 to double (double, double, ...)*
%30 = call double (double, double, ...) %29(double %23, double %28)
store double %30, double* %8
br label %31
31: ; preds = %21
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %17
34: ; preds = %17
%35 = load double, double* %8
ret double %35
}

LLVM IR (-O2):
@.str = [20 x i8] c"Given size is zero!\00"
define double @fisArrayOperation(double* nocapture %0, i32 %1, double (...)* nocapture %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @fisError to i32 (i8*, ...)*)(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = load double, double* %0
br label %22
8: ; preds = %3
%9 = load double, double* %0
%10 = icmp sgt i32 %1, 1
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = bitcast double (...)* %2 to double (double, double, ...)*
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 1, %11 ], [ %20, %14 ]
%16 = phi double [ %9, %11 ], [ %19, %14 ]
%17 = getelementptr inbounds double, double* %0, i64 %15
%18 = load double, double* %17
%19 = tail call double (double, double, ...) %12(double %16, double %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %5, %8
%23 = phi double [ %9, %8 ], [ %7, %5 ], [ %19, %14 ]
ret double %23
}