#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;
  int offset = dim_m + 1;
  for (int j = 0; j < dim_m - 2; ++j) {
    for (int i = 0; i < dim_n - 2 - (dim_n - 2) % 2; i = i + 2) {
      kernel(v1 + offset + j * dim_m + i, v2 + offset + 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)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11f8 <laplacian+0xe8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    -0x2c(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11e5 <laplacian+0xd5>
mov    -0x8(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x24(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1030 <kernel@plt>
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
jmp    1154 <laplacian+0x44>
jmp    11ea <laplacian+0xda>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113c <laplacian+0x2c>
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     11c1 <laplacian+0xb1>
mov    %edx,%r14d
lea    -0x2(%r14),%eax
mov    %rax,0x20(%rsp)
mov    %ecx,%eax
add    $0xfffffffe,%eax
shr    $0x1f,%eax
lea    (%rcx,%rax,1),%ebp
add    $0xfffffffe,%ebp
and    $0xfffffffe,%ebp
mov    %edx,%eax
lea    (%rdi,%rax,8),%rcx
add    $0x8,%rcx
mov    %rcx,0x10(%rsp)
lea    (%rsi,%rax,8),%rcx
add    $0x8,%rcx
mov    %rcx,0x8(%rsp)
shl    $0x3,%rax
mov    %rax,0x18(%rsp)
xor    %r12d,%r12d
jmp    118a <laplacian+0x7a>
xchg   %ax,%ax
add    $0x1,%r12
mov    0x18(%rsp),%rax
add    %rax,0x8(%rsp)
add    %rax,0x10(%rsp)
cmp    0x20(%rsp),%r12
je     11c1 <laplacian+0xb1>
test   %ebp,%ebp
jle    1170 <laplacian+0x60>
xor    %r13d,%r13d
mov    0x10(%rsp),%r15
mov    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
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     11a0 <laplacian+0x90>
jmp    1170 <laplacian+0x60>
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
%12 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %7
store i32 %13, i32* %9
%14 = load i32, i32* %7
%15 = add nsw i32 %14, 1
store i32 %15, i32* %10
store i32 0, i32* %11
br label %16
16: ; preds = %62, %4
%17 = load i32, i32* %11
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 2
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %65
21: ; preds = %16
store i32 0, i32* %12
br label %22
22: ; preds = %58, %21
%23 = load i32, i32* %12
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 2
%26 = load i32, i32* %8
%27 = sub nsw i32 %26, 2
%28 = srem i32 %27, 2
%29 = sub nsw i32 %25, %28
%30 = icmp slt i32 %23, %29
br i1 %30, label %31, label %61
31: ; preds = %22
%32 = load double*, double** %5
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load i32, i32* %11
%37 = load i32, i32* %7
%38 = mul nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %35, i64 %39
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double*, double** %6
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load i32, i32* %11
%49 = load i32, i32* %7
%50 = mul nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %47, i64 %51
%53 = load i32, i32* %12
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load i32, i32* %7
%57 = call i32 @kernel(double* %43, double* %55, i32 %56)
br label %58
58: ; preds = %31
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 2
store i32 %60, i32* %12
br label %22
61: ; preds = %22
br label %62
62: ; preds = %61
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
br label %16
65: ; preds = %16
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 %24
6: ; preds = %4
%7 = add nsw i32 %2, -2
%8 = add nuw nsw i32 %2, 1
%9 = add nsw i32 %3, -2
%10 = srem i32 %9, 2
%11 = sub nsw i32 %9, %10
%12 = icmp sgt i32 %11, 0
%13 = zext i32 %8 to i64
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = getelementptr inbounds double, double* %1, i64 %13
%16 = zext i32 %2 to i64
%17 = zext i32 %7 to i64
br label %18
18: ; preds = %6, %25
%19 = phi i64 [ 0, %6 ], [ %26, %25 ]
br i1 %12, label %20, label %25
20: ; preds = %18
%21 = mul nsw i64 %19, %16
%22 = getelementptr inbounds double, double* %14, i64 %21
%23 = getelementptr inbounds double, double* %15, i64 %21
br label %28
24: ; preds = %25, %4
ret void
25: ; preds = %28, %18
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %24, label %18
28: ; preds = %20, %28
%29 = phi i64 [ 0, %20 ], [ %33, %28 ]
%30 = getelementptr inbounds double, double* %22, i64 %29
%31 = getelementptr inbounds double, double* %23, i64 %29
%32 = tail call i32 @kernel(double* %30, double* %31, i32 %2)
%33 = add nuw i64 %29, 2
%34 = trunc i64 %33 to i32
%35 = icmp sgt i32 %11, %34
br i1 %35, label %28, label %25
}