#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 */
typedef int /*<<< orphan*/ __m128d;

/* Variables and functions */
int /*<<< orphan*/ _mm_add_pd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_loadu_pd(double *);
int /*<<< orphan*/ _mm_mul_pd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_set1_pd(double);
int /*<<< orphan*/ _mm_storeu_pd(double *, int /*<<< orphan*/);
void kernel(double *v1, double *v2, int m) {
  __m128d alpha = _mm_set1_pd(0.25);
  __m128d phi_e = _mm_loadu_pd(v1 + 1);
  __m128d phi_w = _mm_loadu_pd(v1 - 1);
  __m128d phi_n = _mm_loadu_pd(v1 + m);
  __m128d phi_s = _mm_loadu_pd(v1 - m);
  phi_e = _mm_add_pd(phi_e, phi_s);
  phi_e = _mm_add_pd(phi_e, phi_n);
  phi_e = _mm_add_pd(phi_e, phi_w);
  phi_e = _mm_mul_pd(alpha, phi_e);
  _mm_storeu_pd(v2, phi_e);
}


x86 assembly (clang, -O0):
<kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  0xe95(%rip),%xmm0
call   1030 <_mm_set1_pd@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
add    $0xfffffffffffffff8,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rcx
xor    %eax,%eax
sub    %rcx,%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <_mm_mul_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,(%rsp)
mov    %rdi,%rbp
movsd  0xe94(%rip),%xmm0
call   1030 <_mm_set1_pd@plt>
mov    %eax,%r15d
lea    0x8(%rbp),%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%r13d
lea    -0x8(%rbp),%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%r12d
movslq %ebx,%r14
lea    0x0(,%r14,8),%rdi
add    %rbp,%rdi
shl    $0x3,%r14
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%ebx
sub    %r14,%rbp
mov    %rbp,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,%edi
mov    %r12d,%esi
call   1040 <_mm_add_pd@plt>
mov    %r15d,%edi
mov    %eax,%esi
call   1060 <_mm_mul_pd@plt>
mov    (%rsp),%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <_mm_storeu_pd@plt>

LLVM IR (-O0):
define void @kernel(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%12 = call i32 @_mm_set1_pd(double 2.500000e-01)
store i32 %12, i32* %7
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = call i32 @_mm_loadu_pd(double* %14)
store i32 %15, i32* %8
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 -1
%18 = call i32 @_mm_loadu_pd(double* %17)
store i32 %18, i32* %9
%19 = load double*, double** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = call i32 @_mm_loadu_pd(double* %22)
store i32 %23, i32* %10
%24 = load double*, double** %4
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = sub i64 0, %26
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = call i32 @_mm_loadu_pd(double* %28)
store i32 %29, i32* %11
%30 = load i32, i32* %8
%31 = load i32, i32* %11
%32 = call i32 @_mm_add_pd(i32 %30, i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = load i32, i32* %10
%35 = call i32 @_mm_add_pd(i32 %33, i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = call i32 @_mm_add_pd(i32 %36, i32 %37)
store i32 %38, i32* %8
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = call i32 @_mm_mul_pd(i32 %39, i32 %40)
store i32 %41, i32* %8
%42 = load double*, double** %5
%43 = load i32, i32* %8
%44 = call i32 @_mm_storeu_pd(double* %42, i32 %43)
ret void
}

LLVM IR (-O2):
define void @kernel(double* %0, double* %1, i32 %2) {
%4 = tail call i32 @_mm_set1_pd(double 2.500000e-01)
%5 = getelementptr inbounds double, double* %0, i64 1
%6 = tail call i32 @_mm_loadu_pd(double* %5)
%7 = getelementptr inbounds double, double* %0, i64 -1
%8 = tail call i32 @_mm_loadu_pd(double* %7)
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = tail call i32 @_mm_loadu_pd(double* %10)
%12 = sub nsw i64 0, %9
%13 = getelementptr inbounds double, double* %0, i64 %12
%14 = tail call i32 @_mm_loadu_pd(double* %13)
%15 = tail call i32 @_mm_add_pd(i32 %6, i32 %14)
%16 = tail call i32 @_mm_add_pd(i32 %15, i32 %11)
%17 = tail call i32 @_mm_add_pd(i32 %16, i32 %8)
%18 = tail call i32 @_mm_mul_pd(i32 %4, i32 %17)
%19 = tail call i32 @_mm_storeu_pd(double* %1, i32 %18)
ret void
}