double laplacian_u(double (*u)(double x, double y), double h, double x,
                   double y) {
  return (4 * u(x, y) - u(x - 1, y) - u(x + 1, y) - u(x, y - 1) - u(x, y + 1)) /
         (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  0xebf(%rip),%xmm1
subsd  %xmm1,%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  0xe95(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe74(%rip),%xmm0
addsd  -0x18(%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
movsd  0xe41(%rip),%xmm2
subsd  %xmm2,%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  0xe19(%rip),%xmm1
addsd  -0x20(%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,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
addsd  0xecb(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
mulsd  0xebe(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xeaf(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe81(%rip),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  0xe67(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
call   *%rbx
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x18(%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 = fsub double %14, 1.000000e+00
%16 = load double, double* %8
%17 = call double %13(double %15, double %16)
%18 = fneg double %17
%19 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %12, double %18)
%20 = load double (double, double)*, double (double, double)** %5
%21 = load double, double* %7
%22 = fadd double %21, 1.000000e+00
%23 = load double, double* %8
%24 = call double %20(double %22, double %23)
%25 = fsub double %19, %24
%26 = load double (double, double)*, double (double, double)** %5
%27 = load double, double* %7
%28 = load double, double* %8
%29 = fsub double %28, 1.000000e+00
%30 = call double %26(double %27, double %29)
%31 = fsub double %25, %30
%32 = load double (double, double)*, double (double, double)** %5
%33 = load double, double* %7
%34 = load double, double* %8
%35 = fadd double %34, 1.000000e+00
%36 = call double %32(double %33, double %35)
%37 = fsub double %31, %36
%38 = load double, double* %6
%39 = load double, double* %6
%40 = fmul double %38, %39
%41 = fdiv double %37, %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 = fadd double %2, -1.000000e+00
%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 %2, 1.000000e+00
%11 = tail call double %0(double %10, double %3)
%12 = fsub double %9, %11
%13 = fadd double %3, -1.000000e+00
%14 = tail call double %0(double %2, double %13)
%15 = fsub double %12, %14
%16 = fadd double %3, 1.000000e+00
%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
}