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


x86 assembly (clang, -O0):
<diff2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%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,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <_f@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <_f@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diff2>:
sub    $0x28,%rsp
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
addsd  %xmm1,%xmm0
call   1030 <_f@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%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  0x8(%rsp),%xmm0
call   1030 <_f@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <_f@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe7e(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @diff2(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %3
store double %1, double* %4
%7 = load double, double* %3
%8 = load double, double* %4
%9 = fadd double %7, %8
%10 = call double @_f(double %9)
%11 = load double, double* %3
%12 = call double @_f(double %11)
%13 = fsub double %10, %12
store double %13, double* %5
%14 = load double, double* %3
%15 = load double, double* %4
%16 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %15, double %14)
%17 = call double @_f(double %16)
%18 = load double, double* %3
%19 = call double @_f(double %18)
%20 = fsub double %17, %19
store double %20, double* %6
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fmul double 5.000000e-01, %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %21, double %24)
%26 = load double, double* %4
%27 = fdiv double %25, %26
ret double %27
}

LLVM IR (-O2):
define double @diff2(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 = fmul double %10, -5.000000e-01
%12 = tail call double @llvm.fmuladd.f64(double %6, double 2.000000e+00, double %11)
%13 = fdiv double %12, %1
ret double %13
}