double laplacian_u(double (*u)(double x, double y), double h, double x,
                   double y) {
  return (4 * u(x, y) - u(x - h, y) - u(x + h, y) - u(x, y - h) - u(x, y + h));
}


x86 assembly (clang, -O0):
<laplacian_u>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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
movsd  -0x20(%rbp),%xmm1
call   *%rax
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe94(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x10(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian_u>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%rbx
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   *%rdi
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
mulsd  0xeb8(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x20,%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
store double (double, double)* %0, double (double, double)** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double (double, double)*, double (double, double)** %5
%10 = load double, double* %7
%11 = load double, double* %8
%12 = call double %9(double %10, double %11)
%13 = load double (double, double)*, double (double, double)** %5
%14 = load double, double* %7
%15 = load double, double* %6
%16 = fsub double %14, %15
%17 = load double, double* %8
%18 = call double %13(double %16, double %17)
%19 = fneg double %18
%20 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %12, double %19)
%21 = load double (double, double)*, double (double, double)** %5
%22 = load double, double* %7
%23 = load double, double* %6
%24 = fadd double %22, %23
%25 = load double, double* %8
%26 = call double %21(double %24, double %25)
%27 = fsub double %20, %26
%28 = load double (double, double)*, double (double, double)** %5
%29 = load double, double* %7
%30 = load double, double* %8
%31 = load double, double* %6
%32 = fsub double %30, %31
%33 = call double %28(double %29, double %32)
%34 = fsub double %27, %33
%35 = load double (double, double)*, double (double, double)** %5
%36 = load double, double* %7
%37 = load double, double* %8
%38 = load double, double* %6
%39 = fadd double %37, %38
%40 = call double %35(double %36, double %39)
%41 = fsub double %34, %40
ret double %41
}

LLVM IR (-O2):
define double @laplacian_u(double (double, double)* nocapture %0, double %1, double %2, double %3) {
%5 = tail call double %0(double %2, double %3)
%6 = fsub double %2, %1
%7 = tail call double %0(double %6, double %3)
%8 = fneg double %7
%9 = tail call double @llvm.fmuladd.f64(double %5, double 4.000000e+00, double %8)
%10 = fadd double %1, %2
%11 = tail call double %0(double %10, double %3)
%12 = fsub double %9, %11
%13 = fsub double %3, %1
%14 = tail call double %0(double %2, double %13)
%15 = fsub double %12, %14
%16 = fadd double %1, %3
%17 = tail call double %0(double %2, double %16)
%18 = fsub double %15, %17
ret double %18
}