void corner_dtrtri_4x4_lib4(double *A, int use_inv_diag_A, double *inv_diag_A,
                            double *C) {
  const int bs = 4;
  double c_00, c_10, c_11, c_20, c_21, c_22, c_30, c_31, c_32, c_33;
  if (use_inv_diag_A) {
    c_00 = inv_diag_A[0];
    c_11 = inv_diag_A[1];
    c_22 = inv_diag_A[2];
    c_33 = inv_diag_A[3];
  } else {
    c_00 = 1.0 / A[0 + bs * 0];
    c_11 = 1.0 / A[1 + bs * 1];
    c_22 = 1.0 / A[2 + bs * 2];
    c_33 = 1.0 / A[3 + bs * 3];
  }
  C[0 + bs * 0] = c_00;
  C[1 + bs * 1] = c_11;
  C[2 + bs * 2] = c_22;
  C[3 + bs * 3] = c_33;
  c_10 = A[1 + bs * 0];
  c_32 = A[3 + bs * 2];
  c_10 = -c_11 * c_10 * c_00;
  c_32 = -c_33 * c_32 * c_22;
  C[0 + bs * 1] = c_10;
  C[2 + bs * 3] = c_32;
  c_20 = A[2 + bs * 0];
  c_30 = A[3 + bs * 0];
  c_21 = A[2 + bs * 1];
  c_31 = A[3 + bs * 1];
  c_30 = -c_32 * c_20 - c_33 * c_30;
  c_31 = -c_32 * c_21 - c_33 * c_31;
  c_20 = -c_22 * c_20;
  c_21 = -c_22 * c_21;
  c_30 = c_30 * c_00 + c_31 * c_10;
  c_20 = c_20 * c_00 + c_21 * c_10;
  c_31 = c_31 * c_11;
  c_21 = c_21 * c_11;
  C[0 + 2 * bs] = c_20;
  C[1 + 2 * bs] = c_21;
  C[0 + 3 * bs] = c_30;
  C[1 + 3 * bs] = c_31;
  return;
}


x86 assembly (clang, -O0):
<corner_dtrtri_4x4_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1160 <corner_dtrtri_4x4_lib4+0x60>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    11b7 <corner_dtrtri_4x4_lib4+0xb7>
mov    -0x8(%rbp),%rax
movsd  0xe94(%rip),%xmm0
divsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe7f(%rip),%xmm0
divsd  0x28(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe69(%rip),%xmm0
divsd  0x50(%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe53(%rip),%xmm0
divsd  0x78(%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x50(%rax)
movsd  -0x78(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x78(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x58(%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x70(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x70(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x38(%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x60(%rax)
movsd  -0x68(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x68(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrtri_4x4_lib4>:
test   %esi,%esi
je     1110 <corner_dtrtri_4x4_lib4+0x10>
movupd (%rdx),%xmm10
movupd 0x10(%rdx),%xmm0
jmp    113a <corner_dtrtri_4x4_lib4+0x3a>
movsd  (%rdi),%xmm2
movsd  0x50(%rdi),%xmm3
movhpd 0x28(%rdi),%xmm2
movhpd 0x78(%rdi),%xmm3
movapd 0xed4(%rip),%xmm10
movapd %xmm10,%xmm0
divpd  %xmm3,%xmm0
divpd  %xmm2,%xmm10
movlpd %xmm10,(%rcx)
movapd %xmm10,%xmm8
unpckhpd %xmm10,%xmm8
movhpd %xmm10,0x28(%rcx)
movlpd %xmm0,0x50(%rcx)
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
movhpd %xmm0,0x78(%rcx)
movapd 0xea7(%rip),%xmm3
movapd %xmm8,%xmm4
xorpd  %xmm3,%xmm4
mulsd  0x8(%rdi),%xmm4
mulsd  %xmm10,%xmm4
movapd %xmm2,%xmm5
xorpd  %xmm3,%xmm5
mulsd  0x58(%rdi),%xmm5
mulsd  %xmm0,%xmm5
movsd  %xmm4,0x20(%rcx)
movsd  %xmm5,0x70(%rcx)
movsd  0x10(%rdi),%xmm7
movsd  0x30(%rdi),%xmm9
xorpd  %xmm3,%xmm5
movsd  0x18(%rdi),%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm5,%xmm6
mulsd  %xmm7,%xmm6
subsd  %xmm1,%xmm6
movsd  0x38(%rdi),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm9,%xmm5
subsd  %xmm1,%xmm5
xorpd  %xmm0,%xmm3
mulsd  %xmm0,%xmm7
mulsd  %xmm9,%xmm3
movapd %xmm4,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm10,%xmm6
addsd  %xmm0,%xmm6
mulsd  %xmm3,%xmm4
mulsd  %xmm10,%xmm7
subsd  %xmm7,%xmm4
mulsd  %xmm8,%xmm5
mulsd  %xmm8,%xmm3
movsd  %xmm4,0x40(%rcx)
movsd  %xmm3,0x48(%rcx)
movsd  %xmm6,0x60(%rcx)
movsd  %xmm5,0x68(%rcx)
ret

LLVM IR (-O0):
define void @corner_dtrtri_4x4_lib4(double* %0, i32 %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%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 double
%19 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
store double* %3, double** %8
store i32 4, i32* %9
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %4
%23 = load double*, double** %7
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
store double %25, double* %10
%26 = load double*, double** %7
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
store double %28, double* %12
%29 = load double*, double** %7
%30 = getelementptr inbounds double, double* %29, i64 2
%31 = load double, double* %30
store double %31, double* %15
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 3
%34 = load double, double* %33
store double %34, double* %19
br label %52
35: ; preds = %4
%36 = load double*, double** %5
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fdiv double 1.000000e+00, %38
store double %39, double* %10
%40 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 5
%42 = load double, double* %41
%43 = fdiv double 1.000000e+00, %42
store double %43, double* %12
%44 = load double*, double** %5
%45 = getelementptr inbounds double, double* %44, i64 10
%46 = load double, double* %45
%47 = fdiv double 1.000000e+00, %46
store double %47, double* %15
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 15
%50 = load double, double* %49
%51 = fdiv double 1.000000e+00, %50
store double %51, double* %19
br label %52
52: ; preds = %35, %22
%53 = load double, double* %10
%54 = load double*, double** %8
%55 = getelementptr inbounds double, double* %54, i64 0
store double %53, double* %55
%56 = load double, double* %12
%57 = load double*, double** %8
%58 = getelementptr inbounds double, double* %57, i64 5
store double %56, double* %58
%59 = load double, double* %15
%60 = load double*, double** %8
%61 = getelementptr inbounds double, double* %60, i64 10
store double %59, double* %61
%62 = load double, double* %19
%63 = load double*, double** %8
%64 = getelementptr inbounds double, double* %63, i64 15
store double %62, double* %64
%65 = load double*, double** %5
%66 = getelementptr inbounds double, double* %65, i64 1
%67 = load double, double* %66
store double %67, double* %11
%68 = load double*, double** %5
%69 = getelementptr inbounds double, double* %68, i64 11
%70 = load double, double* %69
store double %70, double* %18
%71 = load double, double* %12
%72 = fneg double %71
%73 = load double, double* %11
%74 = fmul double %72, %73
%75 = load double, double* %10
%76 = fmul double %74, %75
store double %76, double* %11
%77 = load double, double* %19
%78 = fneg double %77
%79 = load double, double* %18
%80 = fmul double %78, %79
%81 = load double, double* %15
%82 = fmul double %80, %81
store double %82, double* %18
%83 = load double, double* %11
%84 = load double*, double** %8
%85 = getelementptr inbounds double, double* %84, i64 4
store double %83, double* %85
%86 = load double, double* %18
%87 = load double*, double** %8
%88 = getelementptr inbounds double, double* %87, i64 14
store double %86, double* %88
%89 = load double*, double** %5
%90 = getelementptr inbounds double, double* %89, i64 2
%91 = load double, double* %90
store double %91, double* %13
%92 = load double*, double** %5
%93 = getelementptr inbounds double, double* %92, i64 3
%94 = load double, double* %93
store double %94, double* %16
%95 = load double*, double** %5
%96 = getelementptr inbounds double, double* %95, i64 6
%97 = load double, double* %96
store double %97, double* %14
%98 = load double*, double** %5
%99 = getelementptr inbounds double, double* %98, i64 7
%100 = load double, double* %99
store double %100, double* %17
%101 = load double, double* %18
%102 = fneg double %101
%103 = load double, double* %13
%104 = load double, double* %19
%105 = load double, double* %16
%106 = fmul double %104, %105
%107 = fneg double %106
%108 = call double @llvm.fmuladd.f64(double %102, double %103, double %107)
store double %108, double* %16
%109 = load double, double* %18
%110 = fneg double %109
%111 = load double, double* %14
%112 = load double, double* %19
%113 = load double, double* %17
%114 = fmul double %112, %113
%115 = fneg double %114
%116 = call double @llvm.fmuladd.f64(double %110, double %111, double %115)
store double %116, double* %17
%117 = load double, double* %15
%118 = fneg double %117
%119 = load double, double* %13
%120 = fmul double %118, %119
store double %120, double* %13
%121 = load double, double* %15
%122 = fneg double %121
%123 = load double, double* %14
%124 = fmul double %122, %123
store double %124, double* %14
%125 = load double, double* %16
%126 = load double, double* %10
%127 = load double, double* %17
%128 = load double, double* %11
%129 = fmul double %127, %128
%130 = call double @llvm.fmuladd.f64(double %125, double %126, double %129)
store double %130, double* %16
%131 = load double, double* %13
%132 = load double, double* %10
%133 = load double, double* %14
%134 = load double, double* %11
%135 = fmul double %133, %134
%136 = call double @llvm.fmuladd.f64(double %131, double %132, double %135)
store double %136, double* %13
%137 = load double, double* %17
%138 = load double, double* %12
%139 = fmul double %137, %138
store double %139, double* %17
%140 = load double, double* %14
%141 = load double, double* %12
%142 = fmul double %140, %141
store double %142, double* %14
%143 = load double, double* %13
%144 = load double*, double** %8
%145 = getelementptr inbounds double, double* %144, i64 8
store double %143, double* %145
%146 = load double, double* %14
%147 = load double*, double** %8
%148 = getelementptr inbounds double, double* %147, i64 9
store double %146, double* %148
%149 = load double, double* %16
%150 = load double*, double** %8
%151 = getelementptr inbounds double, double* %150, i64 12
store double %149, double* %151
%152 = load double, double* %17
%153 = load double*, double** %8
%154 = getelementptr inbounds double, double* %153, i64 13
store double %152, double* %154
ret void
}

LLVM IR (-O2):
define void @corner_dtrtri_4x4_lib4(double* nocapture %0, i32 %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = icmp eq i32 %1, 0
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = bitcast double* %2 to <4 x double>*
%8 = load <4 x double>, <4 x double>* %7
br label %22
9: ; preds = %4
%10 = load double, double* %0
%11 = getelementptr inbounds double, double* %0, i64 5
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 10
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %0, i64 15
%16 = load double, double* %15
%17 = insertelement <4 x double> poison, double %10, i64 0
%18 = insertelement <4 x double> %17, double %12, i64 1
%19 = insertelement <4 x double> %18, double %14, i64 2
%20 = insertelement <4 x double> %19, double %16, i64 3
%21 = fdiv <4 x double> <double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00>, %20
br label %22
22: ; preds = %9, %6
%23 = phi <4 x double> [ %8, %6 ], [ %21, %9 ]
%24 = extractelement <4 x double> %23, i64 0
store double %24, double* %3
%25 = getelementptr inbounds double, double* %3, i64 5
%26 = extractelement <4 x double> %23, i64 1
store double %26, double* %25
%27 = getelementptr inbounds double, double* %3, i64 10
%28 = extractelement <4 x double> %23, i64 2
store double %28, double* %27
%29 = getelementptr inbounds double, double* %3, i64 15
%30 = extractelement <4 x double> %23, i64 3
store double %30, double* %29
%31 = getelementptr inbounds double, double* %0, i64 1
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %0, i64 11
%34 = load double, double* %33
%35 = fneg double %26
%36 = fmul double %32, %35
%37 = fmul double %24, %36
%38 = fneg double %30
%39 = fmul double %34, %38
%40 = fmul double %28, %39
%41 = getelementptr inbounds double, double* %3, i64 4
store double %37, double* %41
%42 = getelementptr inbounds double, double* %3, i64 14
store double %40, double* %42
%43 = getelementptr inbounds double, double* %0, i64 2
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %0, i64 3
%46 = load double, double* %45
%47 = getelementptr inbounds double, double* %0, i64 6
%48 = load double, double* %47
%49 = getelementptr inbounds double, double* %0, i64 7
%50 = load double, double* %49
%51 = fneg double %40
%52 = fmul double %46, %38
%53 = tail call double @llvm.fmuladd.f64(double %51, double %44, double %52)
%54 = fmul double %50, %38
%55 = tail call double @llvm.fmuladd.f64(double %51, double %48, double %54)
%56 = fneg double %28
%57 = fmul double %44, %56
%58 = fmul double %48, %56
%59 = fmul double %37, %55
%60 = tail call double @llvm.fmuladd.f64(double %53, double %24, double %59)
%61 = fmul double %37, %58
%62 = tail call double @llvm.fmuladd.f64(double %57, double %24, double %61)
%63 = fmul double %26, %55
%64 = fmul double %26, %58
%65 = getelementptr inbounds double, double* %3, i64 8
store double %62, double* %65
%66 = getelementptr inbounds double, double* %3, i64 9
store double %64, double* %66
%67 = getelementptr inbounds double, double* %3, i64 12
store double %60, double* %67
%68 = getelementptr inbounds double, double* %3, i64 13
store double %63, double* %68
ret void
}