double laplacian_u(double (*u)(double x, double y), double h, double x,
                   double y) {
  double d2udx2 = (u(x + h, y) - 2 * u(x, y) + u(x - h, y)) / (h * h);
  double d2udy2 = (u(x, y + h) - 2 * u(x, y) + u(x, y - h)) / (h * h);
  return d2udy2 + d2udx2;
}


x86 assembly (clang, -O0):
<laplacian_u>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian_u>:
push   %rbx
sub    $0x70,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%rbx
addsd  %xmm1,%xmm0
movaps %xmm2,%xmm1
call   *%rdi
movapd %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movaps %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movapd %xmm0,0x50(%rsp)
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,0x60(%rsp)
movapd %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movaps %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movapd 0x40(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
movapd 0x20(%rsp),%xmm0
unpcklpd 0x30(%rsp),%xmm0
addpd  %xmm1,%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movapd 0x50(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
addpd  0x20(%rsp),%xmm1
movapd 0x60(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @laplacian_u(double (double, double)* %0, double %1, double %2, double %3) {
%5 = alloca double (double, double)*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double (double, double)* %0, double (double, double)** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double (double, double)*, double (double, double)** %5
%12 = load double, double* %7
%13 = load double, double* %6
%14 = fadd double %12, %13
%15 = load double, double* %8
%16 = call double %11(double %14, double %15)
%17 = load double (double, double)*, double (double, double)** %5
%18 = load double, double* %7
%19 = load double, double* %8
%20 = call double %17(double %18, double %19)
%21 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %20, double %16)
%22 = load double (double, double)*, double (double, double)** %5
%23 = load double, double* %7
%24 = load double, double* %6
%25 = fsub double %23, %24
%26 = load double, double* %8
%27 = call double %22(double %25, double %26)
%28 = fadd double %21, %27
%29 = load double, double* %6
%30 = load double, double* %6
%31 = fmul double %29, %30
%32 = fdiv double %28, %31
store double %32, double* %9
%33 = load double (double, double)*, double (double, double)** %5
%34 = load double, double* %7
%35 = load double, double* %8
%36 = load double, double* %6
%37 = fadd double %35, %36
%38 = call double %33(double %34, double %37)
%39 = load double (double, double)*, double (double, double)** %5
%40 = load double, double* %7
%41 = load double, double* %8
%42 = call double %39(double %40, double %41)
%43 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %42, double %38)
%44 = load double (double, double)*, double (double, double)** %5
%45 = load double, double* %7
%46 = load double, double* %8
%47 = load double, double* %6
%48 = fsub double %46, %47
%49 = call double %44(double %45, double %48)
%50 = fadd double %43, %49
%51 = load double, double* %6
%52 = load double, double* %6
%53 = fmul double %51, %52
%54 = fdiv double %50, %53
store double %54, double* %10
%55 = load double, double* %10
%56 = load double, double* %9
%57 = fadd double %55, %56
ret double %57
}

LLVM IR (-O2):
define double @laplacian_u(double (double, double)* nocapture %0, double %1, double %2, double %3) {
%5 = fadd double %1, %2
%6 = tail call double %0(double %5, double %3)
%7 = tail call double %0(double %2, double %3)
%8 = fsub double %2, %1
%9 = tail call double %0(double %8, double %3)
%10 = fmul double %1, %1
%11 = fadd double %1, %3
%12 = tail call double %0(double %2, double %11)
%13 = tail call double %0(double %2, double %3)
%14 = insertelement <2 x double> poison, double %7, i64 0
%15 = insertelement <2 x double> %14, double %13, i64 1
%16 = insertelement <2 x double> poison, double %6, i64 0
%17 = insertelement <2 x double> %16, double %12, i64 1
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> <double -2.000000e+00, double -2.000000e+00>, <2 x double> %17)
%19 = fsub double %3, %1
%20 = tail call double %0(double %2, double %19)
%21 = insertelement <2 x double> poison, double %9, i64 0
%22 = insertelement <2 x double> %21, double %20, i64 1
%23 = fadd <2 x double> %18, %22
%24 = insertelement <2 x double> poison, double %10, i64 0
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> zeroinitializer
%26 = fdiv <2 x double> %23, %25
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%28 = fadd <2 x double> %26, %27
%29 = extractelement <2 x double> %28, i64 0
ret double %29
}