double laplacian_u(double (*u)(double x, double y), double h, double x,
                   double y) {
  return (4 * u(x, y) - u(x, y + h) - u(x + h, y) - u(x - h, y) - u(x, y - h)) /
         (h * 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
movsd  -0x20(%rbp),%xmm1
addsd  -0x10(%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
subsd  -0x10(%rbp),%xmm0
movsd  -0x20(%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
subsd  -0x10(%rbp),%xmm1
call   *%rax
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian_u>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   *%rdi
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
mulsd  0xeb8(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm1
subsd  0x8(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
divsd  %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* %8
%16 = load double, double* %6
%17 = fadd double %15, %16
%18 = call double %13(double %14, 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* %6
%31 = fsub double %29, %30
%32 = load double, double* %8
%33 = call double %28(double %31, 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 = fsub double %37, %38
%40 = call double %35(double %36, double %39)
%41 = fsub double %34, %40
%42 = load double, double* %6
%43 = load double, double* %6
%44 = fmul double %42, %43
%45 = fdiv double %41, %44
ret double %45
}

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 = fadd double %1, %3
%7 = tail call double %0(double %2, double %6)
%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 %2, %1
%14 = tail call double %0(double %13, double %3)
%15 = fsub double %12, %14
%16 = fsub double %3, %1
%17 = tail call double %0(double %2, double %16)
%18 = fsub double %15, %17
%19 = fmul double %1, %1
%20 = fdiv double %18, %19
ret double %20
}