#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 diff3(double x, double h) {
  double f1, f2, f3;
  f1 = _f(x + h) - _f(x);
  f2 = _f(x + 2. * h) - _f(x);
  f3 = _f(x + 3. * h) - _f(x);
  return (3. * f1 - 1.5 * f2 + f3 / 3.) / h;
}


x86 assembly (clang, -O0):
<diff3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1030 <_f@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <_f@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <_f@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <_f@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe66(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <_f@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <_f@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe08(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xdf3(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff3>:
sub    $0x28,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,(%rsp)
addsd  %xmm1,%xmm0
call   1030 <_f@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <_f@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  (%rsp),%xmm0
call   1030 <_f@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <_f@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
addsd  (%rsp),%xmm0
call   1030 <_f@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1030 <_f@plt>
movsd  0x20(%rsp),%xmm3
subsd  %xmm0,%xmm3
movsd  0x8(%rsp),%xmm1
mulsd  0xe4c(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
movsd  0xe36(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @diff3(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
%8 = load double, double* %3
%9 = load double, double* %4
%10 = fadd double %8, %9
%11 = call double @_f(double %10)
%12 = load double, double* %3
%13 = call double @_f(double %12)
%14 = fsub double %11, %13
store double %14, double* %5
%15 = load double, double* %3
%16 = load double, double* %4
%17 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %16, double %15)
%18 = call double @_f(double %17)
%19 = load double, double* %3
%20 = call double @_f(double %19)
%21 = fsub double %18, %20
store double %21, double* %6
%22 = load double, double* %3
%23 = load double, double* %4
%24 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %23, double %22)
%25 = call double @_f(double %24)
%26 = load double, double* %3
%27 = call double @_f(double %26)
%28 = fsub double %25, %27
store double %28, double* %7
%29 = load double, double* %5
%30 = load double, double* %6
%31 = fmul double 1.500000e+00, %30
%32 = fneg double %31
%33 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %29, double %32)
%34 = load double, double* %7
%35 = fdiv double %34, 3.000000e+00
%36 = fadd double %33, %35
%37 = load double, double* %4
%38 = fdiv double %36, %37
ret double %38
}

LLVM IR (-O2):
define double @diff3(double %0, double %1) {
%3 = fadd double %0, %1
%4 = tail call double @_f(double %3)
%5 = tail call double @_f(double %0)
%6 = fsub double %4, %5
%7 = tail call double @llvm.fmuladd.f64(double %1, double 2.000000e+00, double %0)
%8 = tail call double @_f(double %7)
%9 = tail call double @_f(double %0)
%10 = fsub double %8, %9
%11 = tail call double @llvm.fmuladd.f64(double %1, double 3.000000e+00, double %0)
%12 = tail call double @_f(double %11)
%13 = tail call double @_f(double %0)
%14 = fsub double %12, %13
%15 = fmul double %10, -1.500000e+00
%16 = tail call double @llvm.fmuladd.f64(double %6, double 3.000000e+00, double %15)
%17 = fdiv double %14, 3.000000e+00
%18 = fadd double %16, %17
%19 = fdiv double %18, %1
ret double %19
}