void corner_dlauum_nt_2x2_lib4(double *A, double *B, int alg, double *C,
                               double *D) {
  const int bs = 4;
  double a_0, a_1, b_0, b_1, d_00, d_10, d_11;
  a_0 = A[0 + bs * 0];
  b_0 = B[0 + bs * 0];
  d_00 = a_0 * b_0;
  a_0 = A[0 + bs * 1];
  a_1 = A[1 + bs * 1];
  b_0 = B[0 + bs * 1];
  b_1 = B[1 + bs * 1];
  d_00 += a_0 * b_0;
  d_10 = a_1 * b_0;
  d_11 = a_1 * b_1;
  if (alg != 0) {
    if (alg == 1) {
      d_00 = C[0 + bs * 0] + d_00;
      d_10 = C[1 + bs * 0] + d_10;
      d_11 = C[1 + bs * 1] + d_11;
    } else {
      d_00 = C[0 + bs * 0] - d_00;
      d_10 = C[1 + bs * 0] - d_10;
      d_11 = C[1 + bs * 1] - d_11;
    }
  }
  D[0 + bs * 0] = d_00;
  D[1 + bs * 0] = d_10;
  D[1 + bs * 1] = d_11;
}


x86 assembly (clang, -O0):
<corner_dlauum_nt_2x2_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x4,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1247 <corner_dlauum_nt_2x2_lib4+0x147>
cmpl   $0x1,-0x14(%rbp)
jne    120a <corner_dlauum_nt_2x2_lib4+0x10a>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x28(%rax),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1242 <corner_dlauum_nt_2x2_lib4+0x142>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x28(%rax),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1247 <corner_dlauum_nt_2x2_lib4+0x147>
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x68(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x28(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dlauum_nt_2x2_lib4>:
movsd  (%rdi),%xmm2
movsd  0x28(%rdi),%xmm0
mulsd  (%rsi),%xmm2
movsd  0x20(%rsi),%xmm3
movsd  0x20(%rdi),%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm3
unpcklpd %xmm3,%xmm1
mulsd  0x28(%rsi),%xmm0
test   %edx,%edx
je     115d <corner_dlauum_nt_2x2_lib4+0x5d>
cmp    $0x1,%edx
jne    1144 <corner_dlauum_nt_2x2_lib4+0x44>
movupd (%rcx),%xmm2
addpd  %xmm2,%xmm1
addsd  0x28(%rcx),%xmm0
jmp    115d <corner_dlauum_nt_2x2_lib4+0x5d>
movupd (%rcx),%xmm2
subpd  %xmm1,%xmm2
movsd  0x28(%rcx),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
movupd %xmm1,(%r8)
movsd  %xmm0,0x28(%r8)
ret

LLVM IR (-O0):
define void @corner_dlauum_nt_2x2_lib4(double* %0, double* %1, i32 %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
store i32 4, i32* %11
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
store double %21, double* %12
%22 = load double*, double** %7
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
store double %24, double* %14
%25 = load double, double* %12
%26 = load double, double* %14
%27 = fmul double %25, %26
store double %27, double* %16
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 4
%30 = load double, double* %29
store double %30, double* %12
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 5
%33 = load double, double* %32
store double %33, double* %13
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 4
%36 = load double, double* %35
store double %36, double* %14
%37 = load double*, double** %7
%38 = getelementptr inbounds double, double* %37, i64 5
%39 = load double, double* %38
store double %39, double* %15
%40 = load double, double* %12
%41 = load double, double* %14
%42 = load double, double* %16
%43 = call double @llvm.fmuladd.f64(double %40, double %41, double %42)
store double %43, double* %16
%44 = load double, double* %13
%45 = load double, double* %14
%46 = fmul double %44, %45
store double %46, double* %17
%47 = load double, double* %13
%48 = load double, double* %15
%49 = fmul double %47, %48
store double %49, double* %18
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %88
52: ; preds = %5
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %71
55: ; preds = %52
%56 = load double*, double** %9
%57 = getelementptr inbounds double, double* %56, i64 0
%58 = load double, double* %57
%59 = load double, double* %16
%60 = fadd double %58, %59
store double %60, double* %16
%61 = load double*, double** %9
%62 = getelementptr inbounds double, double* %61, i64 1
%63 = load double, double* %62
%64 = load double, double* %17
%65 = fadd double %63, %64
store double %65, double* %17
%66 = load double*, double** %9
%67 = getelementptr inbounds double, double* %66, i64 5
%68 = load double, double* %67
%69 = load double, double* %18
%70 = fadd double %68, %69
store double %70, double* %18
br label %87
71: ; preds = %52
%72 = load double*, double** %9
%73 = getelementptr inbounds double, double* %72, i64 0
%74 = load double, double* %73
%75 = load double, double* %16
%76 = fsub double %74, %75
store double %76, double* %16
%77 = load double*, double** %9
%78 = getelementptr inbounds double, double* %77, i64 1
%79 = load double, double* %78
%80 = load double, double* %17
%81 = fsub double %79, %80
store double %81, double* %17
%82 = load double*, double** %9
%83 = getelementptr inbounds double, double* %82, i64 5
%84 = load double, double* %83
%85 = load double, double* %18
%86 = fsub double %84, %85
store double %86, double* %18
br label %87
87: ; preds = %71, %55
br label %88
88: ; preds = %87, %5
%89 = load double, double* %16
%90 = load double*, double** %10
%91 = getelementptr inbounds double, double* %90, i64 0
store double %89, double* %91
%92 = load double, double* %17
%93 = load double*, double** %10
%94 = getelementptr inbounds double, double* %93, i64 1
store double %92, double* %94
%95 = load double, double* %18
%96 = load double*, double** %10
%97 = getelementptr inbounds double, double* %96, i64 5
store double %95, double* %97
ret void
}

LLVM IR (-O2):
define void @corner_dlauum_nt_2x2_lib4(double* nocapture %0, double* nocapture %1, i32 %2, double* nocapture %3, double* nocapture writeonly %4) {
%6 = load double, double* %0
%7 = load double, double* %1
%8 = fmul double %6, %7
%9 = getelementptr inbounds double, double* %0, i64 4
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %0, i64 5
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %1, i64 4
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 5
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %10, double %14, double %8)
%18 = fmul double %12, %14
%19 = fmul double %12, %16
%20 = insertelement <2 x double> poison, double %17, i64 0
%21 = insertelement <2 x double> %20, double %18, i64 1
switch i32 %2, label %29 [
i32 0, label %36
i32 1, label %22
]
22: ; preds = %5
%23 = bitcast double* %3 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = fadd <2 x double> %21, %24
%26 = getelementptr inbounds double, double* %3, i64 5
%27 = load double, double* %26
%28 = fadd double %19, %27
br label %36
29: ; preds = %5
%30 = bitcast double* %3 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = fsub <2 x double> %31, %21
%33 = getelementptr inbounds double, double* %3, i64 5
%34 = load double, double* %33
%35 = fsub double %34, %19
br label %36
36: ; preds = %5, %22, %29
%37 = phi double [ %28, %22 ], [ %35, %29 ], [ %19, %5 ]
%38 = phi <2 x double> [ %25, %22 ], [ %32, %29 ], [ %21, %5 ]
%39 = bitcast double* %4 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = getelementptr inbounds double, double* %4, i64 5
store double %37, double* %40
ret void
}