#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 phi0, phi1;
  phi0 = _mm_loadu_pd(v1 + 1);
  phi0 = _mm_add_pd(_mm_loadu_pd(v1 - 1), phi0);
  phi0 = _mm_add_pd(_mm_loadu_pd(v1 + m), phi0);
  phi0 = _mm_add_pd(_mm_loadu_pd(v1 - m), phi0);
  phi0 = _mm_mul_pd(alpha, phi0);
  _mm_storeu_pd(v2, phi0);
}


x86 assembly (clang, -O0):
<kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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,%edi
mov    -0x1c(%rbp),%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,-0x1c(%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,%edi
mov    -0x1c(%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    $0x20,%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,%r12d
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xe94(%rip),%xmm0
call   1030 <_mm_set1_pd@plt>
mov    %eax,%r15d
lea    0x8(%rbx),%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%ebp
lea    -0x8(%rbx),%rdi
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,%r13d
movslq %r12d,%rbp
lea    (%rbx,%rbp,8),%rdi
shl    $0x3,%rbp
call   1070 <_mm_loadu_pd@plt>
mov    %eax,%edi
mov    %r13d,%esi
call   1040 <_mm_add_pd@plt>
mov    %eax,%r12d
sub    %rbp,%rbx
mov    %rbx,%rdi
call   1070 <_mm_loadu_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    %r14,%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
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
%10 = call i32 @_mm_set1_pd(double 2.500000e-01)
store i32 %10, i32* %7
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = call i32 @_mm_loadu_pd(double* %12)
store i32 %13, i32* %8
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 -1
%16 = call i32 @_mm_loadu_pd(double* %15)
%17 = load i32, i32* %8
%18 = call i32 @_mm_add_pd(i32 %16, i32 %17)
store i32 %18, i32* %8
%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)
%24 = load i32, i32* %8
%25 = call i32 @_mm_add_pd(i32 %23, i32 %24)
store i32 %25, i32* %8
%26 = load double*, double** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = sub i64 0, %28
%30 = getelementptr inbounds double, double* %26, i64 %29
%31 = call i32 @_mm_loadu_pd(double* %30)
%32 = load i32, i32* %8
%33 = call i32 @_mm_add_pd(i32 %31, i32 %32)
store i32 %33, i32* %8
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @_mm_mul_pd(i32 %34, i32 %35)
store i32 %36, i32* %8
%37 = load double*, double** %5
%38 = load i32, i32* %8
%39 = call i32 @_mm_storeu_pd(double* %37, i32 %38)
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 = tail call i32 @_mm_add_pd(i32 %8, i32 %6)
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds double, double* %0, i64 %10
%12 = tail call i32 @_mm_loadu_pd(double* %11)
%13 = tail call i32 @_mm_add_pd(i32 %12, i32 %9)
%14 = sub nsw i64 0, %10
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = tail call i32 @_mm_loadu_pd(double* %15)
%17 = tail call i32 @_mm_add_pd(i32 %16, i32 %13)
%18 = tail call i32 @_mm_mul_pd(i32 %4, i32 %17)
%19 = tail call i32 @_mm_storeu_pd(double* %1, i32 %18)
ret void
}