#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);
double fp(double *x, int i) {
  return ((f(x[i - 1]) - f(x[i - 2])) / (x[i - 1] - x[i - 2]));
}


x86 assembly (clang, -O0):
<fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <f@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fp>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movslq %esi,%rbx
movsd  -0x8(%rdi,%rbx,8),%xmm0
call   1030 <f@plt>
movsd  %xmm0,(%rsp)
movsd  -0x10(%r14,%rbx,8),%xmm0
call   1030 <f@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  -0x8(%r14,%rbx,8),%xmm0
subsd  -0x10(%r14,%rbx,8),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @fp(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%5 = load double*, double** %3
%6 = load i32, i32* %4
%7 = sub nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds double, double* %5, i64 %8
%10 = load double, double* %9
%11 = call double @f(double %10)
%12 = load double*, double** %3
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %12, i64 %15
%17 = load double, double* %16
%18 = call double @f(double %17)
%19 = fsub double %11, %18
%20 = load double*, double** %3
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %20, i64 %23
%25 = load double, double* %24
%26 = load double*, double** %3
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %26, i64 %29
%31 = load double, double* %30
%32 = fsub double %25, %31
%33 = fdiv double %19, %32
ret double %33
}

LLVM IR (-O2):
define double @fp(double* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds double, double* %0, i64 %4
%6 = load double, double* %5
%7 = tail call double @f(double %6)
%8 = add nsw i32 %1, -2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = tail call double @f(double %11)
%13 = fsub double %7, %12
%14 = load double, double* %5
%15 = load double, double* %10
%16 = fsub double %14, %15
%17 = fdiv double %13, %16
ret double %17
}