#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*/ __assume_aligned(double *, int);
int /*<<< orphan*/ memcpy(double *, double *, int const);
void apply_tri_special_plus(double *restrict u, double *restrict u_temp,
                            const double a, const double b, const int n) {
  __assume_aligned(u, 64);
  __assume_aligned(u_temp, 64);
  memcpy(u_temp, u, n * sizeof(double));
  int N = n - 1;
  for (int i = 1; i < N; i++) {
    u[i] += a * (u_temp[i - 1] + u_temp[i + 1]) + b * u_temp[i];
  }
}


x86 assembly (clang, -O0):
<apply_tri_special_plus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x40,%esi
call   1030 <__assume_aligned@plt>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
call   1030 <__assume_aligned@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    11ef <apply_tri_special_plus+0xcf>
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
addsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1180 <apply_tri_special_plus+0x60>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_tri_special_plus>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r15d
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x40,%esi
call   1030 <__assume_aligned@plt>
mov    %r14,%rdi
mov    $0x40,%esi
call   1030 <__assume_aligned@plt>
lea    0x0(,%r15,8),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <memcpy@plt>
cmp    $0x3,%r15d
jl     124e <apply_tri_special_plus+0x12e>
add    $0xffffffff,%r15d
movsd  (%r14),%xmm3
movsd  0x8(%r14),%xmm1
lea    -0x1(%r15),%rax
mov    $0x1,%edx
cmp    $0x2,%r15d
jne    119c <apply_tri_special_plus+0x7c>
movapd %xmm1,%xmm2
movapd %xmm3,%xmm0
jmp    1226 <apply_tri_special_plus+0x106>
mov    %rax,%rcx
and    $0xfffffffffffffffe,%rcx
neg    %rcx
mov    $0x1,%esi
movsd  0x8(%rsp),%xmm4
movsd  (%rsp),%xmm5
cs nopw 0x0(%rax,%rax,1)
movsd  0x8(%r14,%rsi,8),%xmm0
addsd  %xmm0,%xmm3
movapd %xmm1,%xmm2
mulsd  %xmm5,%xmm2
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
addsd  (%rbx,%rsi,8),%xmm3
movsd  %xmm3,(%rbx,%rsi,8)
movsd  0x10(%r14,%rsi,8),%xmm2
addsd  %xmm2,%xmm1
movapd %xmm0,%xmm3
mulsd  %xmm5,%xmm3
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
addsd  0x8(%rbx,%rsi,8),%xmm1
lea    0x2(%rsi),%rdx
movsd  %xmm1,0x8(%rbx,%rsi,8)
lea    0x2(%rcx,%rsi,1),%rdi
movapd %xmm2,%xmm1
movapd %xmm0,%xmm3
mov    %rdx,%rsi
cmp    $0x1,%rdi
jne    11c0 <apply_tri_special_plus+0xa0>
test   $0x1,%al
je     124e <apply_tri_special_plus+0x12e>
addsd  0x8(%r14,%rdx,8),%xmm0
mulsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
addsd  (%rbx,%rdx,8),%xmm1
movsd  %xmm1,(%rbx,%rdx,8)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @apply_tri_special_plus(double* noalias %0, double* noalias %1, double %2, double %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double %2, double* %8
store double %3, double* %9
store i32 %4, i32* %10
%13 = load double*, double** %6
%14 = call i32 @__assume_aligned(double* %13, i32 64)
%15 = load double*, double** %7
%16 = call i32 @__assume_aligned(double* %15, i32 64)
%17 = load double*, double** %7
%18 = load double*, double** %6
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 8
%22 = trunc i64 %21 to i32
%23 = call i32 @memcpy(double* %17, double* %18, i32 %22)
%24 = load i32, i32* %10
%25 = sub nsw i32 %24, 1
store i32 %25, i32* %11
store i32 1, i32* %12
br label %26
26: ; preds = %59, %5
%27 = load i32, i32* %12
%28 = load i32, i32* %11
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %62
30: ; preds = %26
%31 = load double, double* %8
%32 = load double*, double** %7
%33 = load i32, i32* %12
%34 = sub nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %32, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = load i32, i32* %12
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %38, i64 %41
%43 = load double, double* %42
%44 = fadd double %37, %43
%45 = load double, double* %9
%46 = load double*, double** %7
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double, double* %49
%51 = fmul double %45, %50
%52 = call double @llvm.fmuladd.f64(double %31, double %44, double %51)
%53 = load double*, double** %6
%54 = load i32, i32* %12
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = fadd double %57, %52
store double %58, double* %56
br label %59
59: ; preds = %30
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
store i32 %61, i32* %12
br label %26
62: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @apply_tri_special_plus(double* noalias %0, double* noalias %1, double %2, double %3, i32 %4) {
%6 = tail call i32 @__assume_aligned(double* %0, i32 64)
%7 = tail call i32 @__assume_aligned(double* %1, i32 64)
%8 = shl i32 %4, 3
%9 = tail call i32 @memcpy(double* %1, double* %0, i32 %8)
%10 = icmp sgt i32 %4, 2
br i1 %10, label %11, label %37
11: ; preds = %5
%12 = add nsw i32 %4, -1
%13 = zext i32 %12 to i64
%14 = load double, double* %1
%15 = getelementptr inbounds double, double* %1, i64 1
%16 = load double, double* %15
%17 = add nsw i64 %13, -1
%18 = and i64 %17, 1
%19 = icmp eq i32 %12, 2
br i1 %19, label %22, label %20
20: ; preds = %11
%21 = and i64 %17, -2
br label %38
22: ; preds = %38, %11
%23 = phi double [ %16, %11 ], [ %54, %38 ]
%24 = phi double [ %14, %11 ], [ %45, %38 ]
%25 = phi i64 [ 1, %11 ], [ %52, %38 ]
%26 = icmp eq i64 %18, 0
br i1 %26, label %37, label %27
27: ; preds = %22
%28 = add nuw nsw i64 %25, 1
%29 = getelementptr inbounds double, double* %1, i64 %28
%30 = load double, double* %29
%31 = fadd double %24, %30
%32 = fmul double %23, %3
%33 = tail call double @llvm.fmuladd.f64(double %2, double %31, double %32)
%34 = getelementptr inbounds double, double* %0, i64 %25
%35 = load double, double* %34
%36 = fadd double %35, %33
store double %36, double* %34
br label %37
37: ; preds = %27, %22, %5
ret void
38: ; preds = %38, %20
%39 = phi double [ %16, %20 ], [ %54, %38 ]
%40 = phi double [ %14, %20 ], [ %45, %38 ]
%41 = phi i64 [ 1, %20 ], [ %52, %38 ]
%42 = phi i64 [ 0, %20 ], [ %61, %38 ]
%43 = add nuw nsw i64 %41, 1
%44 = getelementptr inbounds double, double* %1, i64 %43
%45 = load double, double* %44
%46 = fadd double %40, %45
%47 = fmul double %39, %3
%48 = tail call double @llvm.fmuladd.f64(double %2, double %46, double %47)
%49 = getelementptr inbounds double, double* %0, i64 %41
%50 = load double, double* %49
%51 = fadd double %50, %48
store double %51, double* %49
%52 = add nuw nsw i64 %41, 2
%53 = getelementptr inbounds double, double* %1, i64 %52
%54 = load double, double* %53
%55 = fadd double %39, %54
%56 = fmul double %45, %3
%57 = tail call double @llvm.fmuladd.f64(double %2, double %55, double %56)
%58 = getelementptr inbounds double, double* %0, i64 %43
%59 = load double, double* %58
%60 = fadd double %59, %57
store double %60, double* %58
%61 = add i64 %42, 2
%62 = icmp eq i64 %61, %21
br i1 %62, label %22, label %38
}