void solution_update_ftcs(int n, double *curr, double const *last, double alpha,
                          double dx, double dt, double bc_0, double bc_1) {
  double const r = alpha * dt / (dx * dx);
  curr[0] = bc_0;
  curr[n - 1] = bc_1;
  for (int i = 1; i < n - 1; i++)
    curr[i] = r * last[i + 1] + (1 - 2 * r) * last[i] + r * last[i - 1];
}


x86 assembly (clang, -O0):
<solution_update_ftcs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
movsd  %xmm3,-0x38(%rbp)
movsd  %xmm4,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11fc <solution_update_ftcs+0xfc>
movsd  -0x48(%rbp),%xmm1
mov    -0x18(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x48(%rbp),%xmm3
addsd  %xmm3,%xmm3
movsd  0xe57(%rip),%xmm0
subsd  %xmm3,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x4c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1170 <solution_update_ftcs+0x70>
pop    %rbp
ret

x86 assembly (clang, -O2):
<solution_update_ftcs>:
movsd  %xmm3,(%rsi)
movslq %edi,%rax
movsd  %xmm4,-0x8(%rsi,%rax,8)
cmp    $0x3,%edi
jl     1293 <solution_update_ftcs+0x193>
mulsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
add    $0xffffffff,%edi
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movsd  0xeca(%rip),%xmm8
subsd  %xmm2,%xmm8
mov    %edi,%r9d
lea    -0x1(%r9),%r8
mov    $0x1,%ecx
cmp    $0x4,%r8
jb     11ef <solution_update_ftcs+0xef>
lea    0x8(%rsi),%rax
lea    (%rdx,%r9,8),%rdi
add    $0x8,%rdi
cmp    %rdi,%rax
jae    116f <solution_update_ftcs+0x6f>
lea    (%rsi,%r9,8),%rax
cmp    %rdx,%rax
ja     11ef <solution_update_ftcs+0xef>
mov    %r8,%rdi
and    $0xfffffffffffffffc,%rdi
lea    0x1(%rdi),%rcx
movapd %xmm8,%xmm2
unpcklpd %xmm8,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
xor    %eax,%eax
xchg   %ax,%ax
movupd 0x20(%rdx,%rax,8),%xmm4
movupd (%rdx,%rax,8),%xmm5
movupd 0x8(%rdx,%rax,8),%xmm6
movupd 0x10(%rdx,%rax,8),%xmm7
movupd 0x18(%rdx,%rax,8),%xmm1
mulpd  %xmm2,%xmm6
mulpd  %xmm2,%xmm1
mulpd  %xmm3,%xmm7
addpd  %xmm7,%xmm6
mulpd  %xmm3,%xmm4
addpd  %xmm1,%xmm4
mulpd  %xmm3,%xmm5
addpd  %xmm6,%xmm5
addpd  %xmm7,%xmm4
movupd %xmm5,0x8(%rsi,%rax,8)
movupd %xmm4,0x18(%rsi,%rax,8)
add    $0x4,%rax
cmp    %rax,%rdi
jne    1190 <solution_update_ftcs+0x90>
cmp    %rdi,%r8
je     1293 <solution_update_ftcs+0x193>
mov    %rcx,%rax
not    %rax
test   $0x1,%r9b
jne    122a <solution_update_ftcs+0x12a>
movsd  (%rdx,%rcx,8),%xmm1
mulsd  %xmm8,%xmm1
movsd  0x8(%rdx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x8(%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsi,%rcx,8)
add    $0x1,%rcx
add    %r9,%rax
je     1293 <solution_update_ftcs+0x193>
nop
movsd  (%rdx,%rcx,8),%xmm1
mulsd  %xmm8,%xmm1
movsd  0x8(%rdx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x8(%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rsi,%rcx,8)
movsd  0x8(%rdx,%rcx,8),%xmm1
mulsd  %xmm8,%xmm1
movsd  0x10(%rdx,%rcx,8),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  (%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsi,%rcx,8)
lea    0x2(%rcx),%rax
mov    %rax,%rcx
cmp    %rax,%r9
jne    1230 <solution_update_ftcs+0x130>
ret

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

LLVM IR (-O2):
define void @solution_update_ftcs(i32 %0, double* nocapture writeonly %1, double* nocapture %2, double %3, double %4, double %5, double %6, double %7) {
%9 = fmul double %3, %5
%10 = fmul double %4, %4
%11 = fdiv double %9, %10
store double %6, double* %1
%12 = add nsw i32 %0, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %1, i64 %13
store double %7, double* %14
%15 = icmp sgt i32 %0, 2
br i1 %15, label %16, label %98
16: ; preds = %8
%17 = tail call double @llvm.fmuladd.f64(double %11, double -2.000000e+00, double 1.000000e+00)
%18 = zext i32 %12 to i64
%19 = add nsw i64 %18, -1
%20 = icmp ult i64 %19, 4
br i1 %20, label %76, label %21
21: ; preds = %16
%22 = getelementptr double, double* %1, i64 1
%23 = getelementptr double, double* %1, i64 %18
%24 = add nuw nsw i64 %18, 1
%25 = getelementptr double, double* %2, i64 %24
%26 = icmp ult double* %22, %25
%27 = icmp ugt double* %23, %2
%28 = and i1 %26, %27
br i1 %28, label %76, label %29
29: ; preds = %21
%30 = and i64 %19, -4
%31 = or i64 %30, 1
%32 = insertelement <2 x double> poison, double %17, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = insertelement <2 x double> poison, double %17, i64 0
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> zeroinitializer
%36 = insertelement <2 x double> poison, double %11, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = insertelement <2 x double> poison, double %11, i64 0
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> zeroinitializer
br label %40
40: ; preds = %40, %29
%41 = phi i64 [ 0, %29 ], [ %72, %40 ]
%42 = or i64 %41, 1
%43 = or i64 %41, 2
%44 = getelementptr inbounds double, double* %2, i64 %43
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %44, i64 2
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %2, i64 %42
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = fmul <2 x double> %33, %52
%57 = fmul <2 x double> %35, %55
%58 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %46, <2 x double> %56)
%59 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %39, <2 x double> %49, <2 x double> %57)
%60 = getelementptr inbounds double, double* %2, i64 %41
%61 = bitcast double* %60 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = getelementptr inbounds double, double* %60, i64 2
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %37, <2 x double> %62, <2 x double> %58)
%67 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %39, <2 x double> %65, <2 x double> %59)
%68 = getelementptr inbounds double, double* %1, i64 %42
%69 = bitcast double* %68 to <2 x double>*
store <2 x double> %66, <2 x double>* %69
%70 = getelementptr inbounds double, double* %68, i64 2
%71 = bitcast double* %70 to <2 x double>*
store <2 x double> %67, <2 x double>* %71
%72 = add nuw i64 %41, 4
%73 = icmp eq i64 %72, %30
br i1 %73, label %74, label %40
74: ; preds = %40
%75 = icmp eq i64 %19, %30
br i1 %75, label %98, label %76
76: ; preds = %21, %16, %74
%77 = phi i64 [ 1, %21 ], [ 1, %16 ], [ %31, %74 ]
%78 = xor i64 %77, -1
%79 = and i64 %18, 1
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %94
81: ; preds = %76
%82 = add nuw nsw i64 %77, 1
%83 = getelementptr inbounds double, double* %2, i64 %82
%84 = load double, double* %83
%85 = getelementptr inbounds double, double* %2, i64 %77
%86 = load double, double* %85
%87 = fmul double %17, %86
%88 = tail call double @llvm.fmuladd.f64(double %11, double %84, double %87)
%89 = add nsw i64 %77, -1
%90 = getelementptr inbounds double, double* %2, i64 %89
%91 = load double, double* %90
%92 = tail call double @llvm.fmuladd.f64(double %11, double %91, double %88)
%93 = getelementptr inbounds double, double* %1, i64 %77
store double %92, double* %93
br label %94
94: ; preds = %81, %76
%95 = phi i64 [ %77, %76 ], [ %82, %81 ]
%96 = sub nsw i64 0, %18
%97 = icmp eq i64 %78, %96
br i1 %97, label %98, label %99
98: ; preds = %94, %99, %74, %8
ret void
99: ; preds = %94, %99
%100 = phi i64 [ %113, %99 ], [ %95, %94 ]
%101 = add nuw nsw i64 %100, 1
%102 = getelementptr inbounds double, double* %2, i64 %101
%103 = load double, double* %102
%104 = getelementptr inbounds double, double* %2, i64 %100
%105 = load double, double* %104
%106 = fmul double %17, %105
%107 = tail call double @llvm.fmuladd.f64(double %11, double %103, double %106)
%108 = add nsw i64 %100, -1
%109 = getelementptr inbounds double, double* %2, i64 %108
%110 = load double, double* %109
%111 = tail call double @llvm.fmuladd.f64(double %11, double %110, double %107)
%112 = getelementptr inbounds double, double* %1, i64 %100
store double %111, double* %112
%113 = add nuw nsw i64 %100, 2
%114 = getelementptr inbounds double, double* %2, i64 %113
%115 = load double, double* %114
%116 = getelementptr inbounds double, double* %2, i64 %101
%117 = load double, double* %116
%118 = fmul double %17, %117
%119 = tail call double @llvm.fmuladd.f64(double %11, double %115, double %118)
%120 = getelementptr inbounds double, double* %2, i64 %100
%121 = load double, double* %120
%122 = tail call double @llvm.fmuladd.f64(double %11, double %121, double %119)
%123 = getelementptr inbounds double, double* %1, i64 %101
store double %122, double* %123
%124 = icmp eq i64 %113, %18
br i1 %124, label %98, label %99
}