#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 lap_avx(double *v1, double *v2, int dim_m, int dim_n, int lda) {
  const int m = dim_m;
  for (int j = 0; j < dim_n - 0; ++j) {
    for (int i = 0; i < dim_m - 0 - (dim_m - 0) % 4; i = i + 4) {
      kernel(v1 + i + j * lda, v2 + i + j * lda, lda);
    }
  }
}


x86 assembly (clang, -O0):
<lap_avx>:
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   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x0,%ecx
cmp    %ecx,%eax
jge    11dd <lap_avx+0xcd>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%ecx
sub    $0x0,%ecx
mov    -0x14(%rbp),%eax
sub    $0x0,%eax
mov    $0x4,%esi
cltd
idiv   %esi
mov    -0x2c(%rbp),%eax
sub    %edx,%ecx
cmp    %ecx,%eax
jge    11ca <lap_avx+0xba>
mov    -0x8(%rbp),%rdi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <kernel@plt>
mov    -0x28(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <lap_avx+0x3f>
jmp    11cf <lap_avx+0xbf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1137 <lap_avx+0x27>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lap_avx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
test   %ecx,%ecx
jle    11b1 <lap_avx+0xa1>
mov    %r8d,%r12d
lea    0x3(%rdx),%r13d
test   %edx,%edx
cmovns %edx,%r13d
and    $0xfffffffc,%r13d
movslq %r8d,%rax
mov    %ecx,%ecx
mov    %rcx,0x18(%rsp)
shl    $0x3,%rax
mov    %rax,0x20(%rsp)
xor    %r14d,%r14d
jmp    117a <lap_avx+0x6a>
nopl   0x0(%rax)
add    $0x1,%r14
mov    0x20(%rsp),%rax
add    %rax,0x10(%rsp)
add    %rax,0x8(%rsp)
cmp    0x18(%rsp),%r14
je     11b1 <lap_avx+0xa1>
test   %r13d,%r13d
jle    1160 <lap_avx+0x50>
xor    %r15d,%r15d
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%rbp
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1030 <kernel@plt>
add    $0x20,%rbp
add    $0x20,%rbx
add    $0x4,%r15d
cmp    %r15d,%r13d
jg     1190 <lap_avx+0x80>
jmp    1160 <lap_avx+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @lap_avx(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
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
%14 = load i32, i32* %8
store i32 %14, i32* %11
store i32 0, i32* %12
br label %15
15: ; preds = %55, %5
%16 = load i32, i32* %12
%17 = load i32, i32* %9
%18 = sub nsw i32 %17, 0
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %58
20: ; preds = %15
store i32 0, i32* %13
br label %21
21: ; preds = %51, %20
%22 = load i32, i32* %13
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 0
%25 = load i32, i32* %8
%26 = sub nsw i32 %25, 0
%27 = srem i32 %26, 4
%28 = sub nsw i32 %24, %27
%29 = icmp slt i32 %22, %28
br i1 %29, label %30, label %54
30: ; preds = %21
%31 = load double*, double** %6
%32 = load i32, i32* %13
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load i32, i32* %12
%36 = load i32, i32* %10
%37 = mul nsw i32 %35, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %34, i64 %38
%40 = load double*, double** %7
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load i32, i32* %12
%45 = load i32, i32* %10
%46 = mul nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %43, i64 %47
%49 = load i32, i32* %10
%50 = call i32 @kernel(double* %39, double* %48, i32 %49)
br label %51
51: ; preds = %30
%52 = load i32, i32* %13
%53 = add nsw i32 %52, 4
store i32 %53, i32* %13
br label %21
54: ; preds = %21
br label %55
55: ; preds = %54
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
br label %15
58: ; preds = %15
ret void
}

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