void DiagOfTriXTri(double *ll, double *l0, double *lu, double *rl, double *r0,
                   double *ru, double *d, int N) {
  register int i;
  d[0] = l0[0] * r0[0] + lu[0] * rl[0];
  for (i = 1; i < N - 1; i++) {
    d[i] = ll[i - 1] * ru[i - 1] + l0[i] * r0[i] + lu[i] * rl[i];
  }
  d[N - 1] = ll[N - 2] * ru[N - 2] + l0[N - 1] * r0[N - 1];
}


x86 assembly (clang, -O0):
<DiagOfTriXTri>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
mulsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ee <DiagOfTriXTri+0xee>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115a <DiagOfTriXTri+0x5a>
mov    -0x8(%rbp),%rax
mov    0x18(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
mov    0x18(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
mov    0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rax
mov    0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
mov    0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
pop    %rbp
ret

x86 assembly (clang, -O2):
<DiagOfTriXTri>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x40(%rsp),%eax
mov    0x38(%rsp),%r14
movsd  (%rsi),%xmm0
movsd  (%rdx),%xmm1
mulsd  (%rcx),%xmm1
mulsd  (%r8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
lea    -0x1(%rax),%ebp
mov    %ebp,-0x24(%rsp)
cmp    $0x3,%eax
jl     1308 <DiagOfTriXTri+0x208>
mov    -0x24(%rsp),%r13d
lea    -0x1(%r13),%rax
mov    $0x1,%r12d
cmp    $0x2,%rax
jb     129d <DiagOfTriXTri+0x19d>
mov    %rax,-0x8(%rsp)
lea    0x8(%r14),%rbx
lea    (%r14,%r13,8),%rax
lea    (%rdi,%r13,8),%r10
add    $0xfffffffffffffff8,%r10
lea    -0x8(%r9,%r13,8),%r11
lea    0x8(%rsi),%rbp
mov    %rbp,-0x18(%rsp)
lea    (%rsi,%r13,8),%r15
lea    0x8(%r8),%rbp
mov    %rbp,-0x10(%rsp)
lea    (%r8,%r13,8),%rbp
mov    %rbp,-0x20(%rsp)
cmp    %r10,%rbx
setb   -0x25(%rsp)
cmp    %rdi,%rax
seta   -0x26(%rsp)
cmp    %r11,%rbx
setb   %r10b
cmp    %r9,%rax
seta   -0x27(%rsp)
cmp    %r15,%rbx
setb   %r11b
cmp    %rax,-0x18(%rsp)
lea    0x8(%rdx),%rbp
setb   -0x18(%rsp)
cmp    -0x20(%rsp),%rbx
setb   -0x20(%rsp)
cmp    %rax,-0x10(%rsp)
lea    (%rdx,%r13,8),%r15
setb   -0x10(%rsp)
cmp    %r15,%rbx
setb   %r15b
cmp    %rax,%rbp
lea    (%rcx,%r13,8),%rbp
setb   -0x28(%rsp)
cmp    %rbp,%rbx
lea    0x8(%rcx),%rbp
setb   %bl
cmp    %rax,%rbp
setb   %bpl
mov    -0x26(%rsp),%al
test   %al,-0x25(%rsp)
jne    129d <DiagOfTriXTri+0x19d>
and    -0x27(%rsp),%r10b
jne    129d <DiagOfTriXTri+0x19d>
and    -0x18(%rsp),%r11b
jne    129d <DiagOfTriXTri+0x19d>
mov    -0x10(%rsp),%al
and    %al,-0x20(%rsp)
jne    129d <DiagOfTriXTri+0x19d>
and    -0x28(%rsp),%r15b
jne    129d <DiagOfTriXTri+0x19d>
and    %bpl,%bl
jne    129d <DiagOfTriXTri+0x19d>
mov    -0x8(%rsp),%rbx
mov    %rbx,%rax
and    $0xfffffffffffffffe,%rax
mov    %rbx,%r12
or     $0x1,%r12
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movupd (%rdi,%rbp,8),%xmm0
movupd (%r9,%rbp,8),%xmm1
mulpd  %xmm0,%xmm1
movupd 0x8(%rsi,%rbp,8),%xmm0
movupd 0x8(%r8,%rbp,8),%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd 0x8(%rdx,%rbp,8),%xmm0
movupd 0x8(%rcx,%rbp,8),%xmm1
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x8(%r14,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%rax
jne    1250 <DiagOfTriXTri+0x150>
cmp    %rax,%rbx
je     1308 <DiagOfTriXTri+0x208>
lea    (%rdi,%r12,8),%r15
add    $0xfffffffffffffff8,%r15
lea    -0x8(%r9,%r12,8),%r11
lea    (%r14,%r12,8),%rax
lea    (%rcx,%r12,8),%rcx
lea    (%rdx,%r12,8),%rdx
lea    (%r8,%r12,8),%rbp
lea    (%rsi,%r12,8),%r10
sub    %r12,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r15,%rbx,8),%xmm0
movsd  (%r10,%rbx,8),%xmm1
mulsd  0x0(%rbp,%rbx,8),%xmm1
mulsd  (%r11,%rbx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  (%rdx,%rbx,8),%xmm1
mulsd  (%rcx,%rbx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    12d0 <DiagOfTriXTri+0x1d0>
mov    0x40(%rsp),%eax
cltq
movsd  -0x10(%rdi,%rax,8),%xmm0
movslq -0x24(%rsp),%rcx
movsd  (%rsi,%rcx,8),%xmm1
mulsd  (%r8,%rcx,8),%xmm1
mulsd  -0x10(%r9,%rax,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rcx,8)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DiagOfTriXTri(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, i32 %7) {
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
store double* %0, double** %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 i32 %7, i32* %16
%18 = load double*, double** %10
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = load double*, double** %13
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %11
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %12
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = fmul double %26, %29
%31 = call double @llvm.fmuladd.f64(double %20, double %23, double %30)
%32 = load double*, double** %15
%33 = getelementptr inbounds double, double* %32, i64 0
store double %31, double* %33
store i32 1, i32* %17
br label %34
34: ; preds = %79, %8
%35 = load i32, i32* %17
%36 = load i32, i32* %16
%37 = sub nsw i32 %36, 1
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %82
39: ; preds = %34
%40 = load double*, double** %9
%41 = load i32, i32* %17
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %40, i64 %43
%45 = load double, double* %44
%46 = load double*, double** %14
%47 = load i32, i32* %17
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %46, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %10
%53 = load i32, i32* %17
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = load double*, double** %13
%58 = load i32, i32* %17
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = fmul double %56, %61
%63 = call double @llvm.fmuladd.f64(double %45, double %51, double %62)
%64 = load double*, double** %11
%65 = load i32, i32* %17
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = load double*, double** %12
%70 = load i32, i32* %17
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = call double @llvm.fmuladd.f64(double %68, double %73, double %63)
%75 = load double*, double** %15
%76 = load i32, i32* %17
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %75, i64 %77
store double %74, double* %78
br label %79
79: ; preds = %39
%80 = load i32, i32* %17
%81 = add nsw i32 %80, 1
store i32 %81, i32* %17
br label %34
82: ; preds = %34
%83 = load double*, double** %9
%84 = load i32, i32* %16
%85 = sub nsw i32 %84, 2
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double, double* %83, i64 %86
%88 = load double, double* %87
%89 = load double*, double** %14
%90 = load i32, i32* %16
%91 = sub nsw i32 %90, 2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %89, i64 %92
%94 = load double, double* %93
%95 = load double*, double** %10
%96 = load i32, i32* %16
%97 = sub nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %95, i64 %98
%100 = load double, double* %99
%101 = load double*, double** %13
%102 = load i32, i32* %16
%103 = sub nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double, double* %101, i64 %104
%106 = load double, double* %105
%107 = fmul double %100, %106
%108 = call double @llvm.fmuladd.f64(double %88, double %94, double %107)
%109 = load double*, double** %15
%110 = load i32, i32* %16
%111 = sub nsw i32 %110, 1
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds double, double* %109, i64 %112
store double %108, double* %113
ret void
}

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