double laplacian_u(double (*u)(double x, double y), double h, double x,
                   double y) {
  double upx = u(x + h, y);
  double umx = u(x - h, y);
  double upy = u(x, y + h);
  double umy = u(x, y - h);
  double u0 = u(x, y);
  return (4 * u0 - upx - upy - umx - umy) / (h * h);
}


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,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe3f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian_u>:
push   %rbx
sub    $0x40,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%rbx
addsd  %xmm1,%xmm0
movaps %xmm2,%xmm1
call   *%rdi
movsd  %xmm0,0x38(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
mulsd  0xe73(%rip),%xmm0
subsd  0x38(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%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
%11 = alloca double
%12 = alloca double
%13 = 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
%14 = load double (double, double)*, double (double, double)** %5
%15 = load double, double* %7
%16 = load double, double* %6
%17 = fadd double %15, %16
%18 = load double, double* %8
%19 = call double %14(double %17, double %18)
store double %19, double* %9
%20 = load double (double, double)*, double (double, double)** %5
%21 = load double, double* %7
%22 = load double, double* %6
%23 = fsub double %21, %22
%24 = load double, double* %8
%25 = call double %20(double %23, double %24)
store double %25, double* %10
%26 = load double (double, double)*, double (double, double)** %5
%27 = load double, double* %7
%28 = load double, double* %8
%29 = load double, double* %6
%30 = fadd double %28, %29
%31 = call double %26(double %27, double %30)
store double %31, double* %11
%32 = load double (double, double)*, double (double, double)** %5
%33 = load double, double* %7
%34 = load double, double* %8
%35 = load double, double* %6
%36 = fsub double %34, %35
%37 = call double %32(double %33, double %36)
store double %37, double* %12
%38 = load double (double, double)*, double (double, double)** %5
%39 = load double, double* %7
%40 = load double, double* %8
%41 = call double %38(double %39, double %40)
store double %41, double* %13
%42 = load double, double* %13
%43 = load double, double* %9
%44 = fneg double %43
%45 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %42, double %44)
%46 = load double, double* %11
%47 = fsub double %45, %46
%48 = load double, double* %10
%49 = fsub double %47, %48
%50 = load double, double* %12
%51 = fsub double %49, %50
%52 = load double, double* %6
%53 = load double, double* %6
%54 = fmul double %52, %53
%55 = fdiv double %51, %54
ret double %55
}

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 = fsub double %2, %1
%8 = tail call double %0(double %7, double %3)
%9 = fadd double %1, %3
%10 = tail call double %0(double %2, double %9)
%11 = fsub double %3, %1
%12 = tail call double %0(double %2, double %11)
%13 = tail call double %0(double %2, double %3)
%14 = fneg double %6
%15 = tail call double @llvm.fmuladd.f64(double %13, double 4.000000e+00, double %14)
%16 = fsub double %15, %10
%17 = fsub double %16, %8
%18 = fsub double %17, %12
%19 = fmul double %1, %1
%20 = fdiv double %18, %19
ret double %20
}