#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ kernel(double *, double *, int, int);
void laplacian(double *v1, double *v2, int dim_m, int dim_n, int dim_k) {
  int m = dim_m;
#pragma omp parallel for schedule(static)
  for (int k = 1; k < dim_k + 1; ++k) {
    for (int j = 1; j < dim_m - 1; ++j) {
      for (int i = 1; i < dim_n - 1; ++i) {
        kernel(v1 + k * dim_n * dim_m + j * dim_m + i,
               v2 + k * dim_n * dim_m + j * dim_m + i, dim_m, dim_n);
      }
    }
  }
}


x86 assembly (clang, -O0):
<laplacian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    121d <laplacian+0x10d>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120a <laplacian+0xfa>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f7 <laplacian+0xe7>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x28(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <kernel@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <laplacian+0x57>
jmp    11fc <laplacian+0xec>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <laplacian+0x3f>
jmp    120f <laplacian+0xff>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1137 <laplacian+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,0x8(%rsp)
test   %r8d,%r8d
jle    1251 <laplacian+0x141>
mov    %ecx,%r12d
mov    %edx,%r15d
lea    -0x1(%r15),%eax
mov    %rax,0x40(%rsp)
lea    -0x1(%r12),%ecx
movslq %edx,%rdx
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
lea    (%rsi,%rdx,8),%rax
add    $0x8,%rax
mov    %rax,0x20(%rsp)
mov    %r12d,%eax
imul   %r15d,%eax
lea    (%rdi,%rdx,8),%rsi
add    $0x8,%rsi
mov    %rsi,0x18(%rsp)
shl    $0x3,%rdx
mov    %rdx,0x30(%rsp)
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x38(%rsp)
mov    $0x1,%ecx
mov    %eax,0x14(%rsp)
mov    %eax,0x4(%rsp)
jmp    11c0 <laplacian+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x28(%rsp),%rcx
add    $0x1,%rcx
mov    0x4(%rsp),%eax
add    0x14(%rsp),%eax
mov    %eax,0x4(%rsp)
cmp    0x8(%rsp),%rcx
je     1251 <laplacian+0x141>
mov    %rcx,0x28(%rsp)
cmp    $0x3,%r15d
jl     11a0 <laplacian+0x90>
movslq 0x4(%rsp),%rax
mov    0x20(%rsp),%rcx
lea    (%rcx,%rax,8),%rbx
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%r13
mov    $0x1,%r14d
jmp    1210 <laplacian+0x100>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
mov    0x30(%rsp),%rax
mov    0x50(%rsp),%rbx
add    %rax,%rbx
mov    0x48(%rsp),%r13
add    %rax,%r13
cmp    0x40(%rsp),%r14
je     11a0 <laplacian+0x90>
mov    0x38(%rsp),%rbp
mov    %r13,0x48(%rsp)
mov    %rbx,0x50(%rsp)
cmp    $0x3,%r12d
jl     11f0 <laplacian+0xe0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1030 <kernel@plt>
add    $0x8,%rbx
add    $0x8,%r13
add    $0xffffffffffffffff,%rbp
jne    1230 <laplacian+0x120>
jmp    11f0 <laplacian+0xe0>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @laplacian(double* %0, double* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%15 = load i32, i32* %8
store i32 %15, i32* %11
store i32 1, i32* %12
br label %16
16: ; preds = %77, %5
%17 = load i32, i32* %12
%18 = load i32, i32* %10
%19 = add nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %80
21: ; preds = %16
store i32 1, i32* %13
br label %22
22: ; preds = %73, %21
%23 = load i32, i32* %13
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %76
27: ; preds = %22
store i32 1, i32* %14
br label %28
28: ; preds = %69, %27
%29 = load i32, i32* %14
%30 = load i32, i32* %9
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %72
33: ; preds = %28
%34 = load double*, double** %6
%35 = load i32, i32* %12
%36 = load i32, i32* %9
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %8
%39 = mul nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %34, i64 %40
%42 = load i32, i32* %13
%43 = load i32, i32* %8
%44 = mul nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %41, i64 %45
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double*, double** %7
%51 = load i32, i32* %12
%52 = load i32, i32* %9
%53 = mul nsw i32 %51, %52
%54 = load i32, i32* %8
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %50, i64 %56
%58 = load i32, i32* %13
%59 = load i32, i32* %8
%60 = mul nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %57, i64 %61
%63 = load i32, i32* %14
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load i32, i32* %8
%67 = load i32, i32* %9
%68 = call i32 @kernel(double* %49, double* %65, i32 %66, i32 %67)
br label %69
69: ; preds = %33
%70 = load i32, i32* %14
%71 = add nsw i32 %70, 1
store i32 %71, i32* %14
br label %28
72: ; preds = %28
br label %73
73: ; preds = %72
%74 = load i32, i32* %13
%75 = add nsw i32 %74, 1
store i32 %75, i32* %13
br label %22
76: ; preds = %22
br label %77
77: ; preds = %76
%78 = load i32, i32* %12
%79 = add nsw i32 %78, 1
store i32 %79, i32* %12
br label %16
80: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @laplacian(double* %0, double* %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %4, 1
br i1 %6, label %26, label %7
7: ; preds = %5
%8 = add i32 %2, -1
%9 = icmp sgt i32 %2, 2
%10 = add i32 %3, -1
%11 = icmp sgt i32 %3, 2
%12 = mul i32 %3, %2
%13 = sext i32 %2 to i64
%14 = add nuw i32 %4, 1
%15 = zext i32 %14 to i64
%16 = zext i32 %8 to i64
%17 = zext i32 %10 to i64
br label %18
18: ; preds = %7, %33
%19 = phi i64 [ 1, %7 ], [ %34, %33 ]
br i1 %9, label %20, label %33
20: ; preds = %18
%21 = trunc i64 %19 to i32
%22 = mul i32 %12, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = getelementptr inbounds double, double* %1, i64 %23
br label %27
26: ; preds = %33, %5
ret void
27: ; preds = %20, %36
%28 = phi i64 [ 1, %20 ], [ %37, %36 ]
br i1 %11, label %29, label %36
29: ; preds = %27
%30 = mul nsw i64 %28, %13
%31 = getelementptr inbounds double, double* %24, i64 %30
%32 = getelementptr inbounds double, double* %25, i64 %30
br label %39
33: ; preds = %36, %18
%34 = add nuw nsw i64 %19, 1
%35 = icmp eq i64 %34, %15
br i1 %35, label %26, label %18
36: ; preds = %39, %27
%37 = add nuw nsw i64 %28, 1
%38 = icmp eq i64 %37, %16
br i1 %38, label %33, label %27
39: ; preds = %29, %39
%40 = phi i64 [ 1, %29 ], [ %44, %39 ]
%41 = getelementptr inbounds double, double* %31, i64 %40
%42 = getelementptr inbounds double, double* %32, i64 %40
%43 = tail call i32 @kernel(double* %41, double* %42, i32 %2, i32 %3)
%44 = add nuw nsw i64 %40, 1
%45 = icmp eq i64 %44, %17
br i1 %45, label %36, label %39
}