#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 */
int /*<<< orphan*/ fisError(char *);
double stub1(double, double);
double fisArrayOperation(double *array, int size,
                         double (*fcn)(double, double)) {
  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    1139 <fisArrayOperation+0x29>
lea    0xecc(%rip),%rdi
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    1184 <fisArrayOperation+0x74>
mov    -0x18(%rbp),%rax
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm1
call   *%rax
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <fisArrayOperation+0x3d>
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,%r15
test   %esi,%esi
je     1154 <fisArrayOperation+0x44>
movsd  (%r15),%xmm0
cmp    $0x2,%esi
jl     1165 <fisArrayOperation+0x55>
mov    %rdx,%r14
mov    %esi,%r12d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r15,%rbx,8),%xmm1
call   *%r14
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <fisArrayOperation+0x30>
jmp    1165 <fisArrayOperation+0x55>
lea    0xea5(%rip),%rdi
call   1030 <fisError@plt>
movsd  (%r15),%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 (double, double)* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double (double, double)*
%7 = alloca i32
%8 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double (double, double)* %2, double (double, 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 @fisError(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 = %30, %13
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load double (double, double)*, double (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 = call double %22(double %23, double %28)
store double %29, double* %8
br label %30
30: ; preds = %21
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %17
33: ; preds = %17
%34 = load double, double* %8
ret double %34
}

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