#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);
void laplacian(double *v1, double *v2, int dim_m, int dim_n) {
  int m = dim_m;
#pragma omp parallel for schedule(static)
  for (int j = 1; j < dim_m - 1; ++j) {
    for (int i = 1; i < dim_n - 1 - (dim_n - 1) % 2; i = i + 2) {
      kernel(v1 + j * dim_m + i, v2 + j * dim_m + i, dim_m);
    }
  }
}


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    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d9 <laplacian+0xc9>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    -0x28(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11c6 <laplacian+0xb6>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1030 <kernel@plt>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    114b <laplacian+0x3b>
jmp    11cb <laplacian+0xbb>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1133 <laplacian+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laplacian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edx
jl     11d1 <laplacian+0xc1>
mov    %edx,%r14d
lea    -0x1(%r14),%eax
mov    %rax,0x20(%rsp)
mov    %ecx,%eax
add    $0xffffffff,%eax
shr    $0x1f,%eax
lea    (%rcx,%rax,1),%ebp
add    $0xffffffff,%ebp
and    $0xfffffffe,%ebp
mov    %edx,%eax
lea    (%rsi,%rax,8),%rcx
add    $0x8,%rcx
mov    %rcx,0x10(%rsp)
lea    (%rdi,%rax,8),%rcx
add    $0x8,%rcx
mov    %rcx,0x8(%rsp)
shl    $0x3,%rax
mov    %rax,0x18(%rsp)
mov    $0x1,%r12d
jmp    119a <laplacian+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
mov    0x18(%rsp),%rax
add    %rax,0x10(%rsp)
add    %rax,0x8(%rsp)
cmp    0x20(%rsp),%r12
je     11d1 <laplacian+0xc1>
cmp    $0x2,%ebp
jl     1180 <laplacian+0x70>
mov    $0x1,%r13d
mov    0x8(%rsp),%r15
mov    0x10(%rsp),%rbx
nop
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <kernel@plt>
add    $0x10,%rbx
add    $0x10,%r15
add    $0x2,%r13d
cmp    %r13d,%ebp
jg     11b0 <laplacian+0xa0>
jmp    1180 <laplacian+0x70>
add    $0x28,%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) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %7
store i32 %12, i32* %9
store i32 1, i32* %10
br label %13
13: ; preds = %53, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %7
%16 = sub nsw i32 %15, 1
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %56
18: ; preds = %13
store i32 1, i32* %11
br label %19
19: ; preds = %49, %18
%20 = load i32, i32* %11
%21 = load i32, i32* %8
%22 = sub nsw i32 %21, 1
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 1
%25 = srem i32 %24, 2
%26 = sub nsw i32 %22, %25
%27 = icmp slt i32 %20, %26
br i1 %27, label %28, label %52
28: ; preds = %19
%29 = load double*, double** %5
%30 = load i32, i32* %10
%31 = load i32, i32* %7
%32 = mul nsw i32 %30, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load i32, i32* %11
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double*, double** %6
%39 = load i32, i32* %10
%40 = load i32, i32* %7
%41 = mul nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %38, i64 %42
%44 = load i32, i32* %11
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load i32, i32* %7
%48 = call i32 @kernel(double* %37, double* %46, i32 %47)
br label %49
49: ; preds = %28
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 2
store i32 %51, i32* %11
br label %19
52: ; preds = %19
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %13
56: ; preds = %13
ret void
}

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