void corner_dtrmm_l_u_nt_1x4_lib4(double *A, double *B, int alg, double *C,
                                  double *D) {
  const int bs = 4;
  double a_0, b_0, d_0, d_1, d_2, d_3;
  a_0 = A[0];
  b_0 = B[0];
  d_0 = a_0 * b_0;
  b_0 = B[1];
  d_1 = a_0 * b_0;
  b_0 = B[2];
  d_2 = a_0 * b_0;
  b_0 = B[3];
  d_3 = a_0 * b_0;
  if (alg != 0) {
    if (alg == 1) {
      d_0 = C[0 + bs * 0] + d_0;
      d_1 = C[0 + bs * 1] + d_1;
      d_2 = C[0 + bs * 2] + d_2;
      d_3 = C[0 + bs * 3] + d_3;
    } else {
      d_0 = C[0 + bs * 0] - d_0;
      d_1 = C[0 + bs * 1] - d_1;
      d_2 = C[0 + bs * 2] - d_2;
      d_3 = C[0 + bs * 3] - d_3;
    }
  }
  D[0 + bs * 0] = d_0;
  D[0 + bs * 1] = d_1;
  D[0 + bs * 2] = d_2;
  D[0 + bs * 3] = d_3;
}


x86 assembly (clang, -O0):
<corner_dtrmm_l_u_nt_1x4_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,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1252 <corner_dtrmm_l_u_nt_1x4_lib4+0x152>
cmpl   $0x1,-0x14(%rbp)
jne    1202 <corner_dtrmm_l_u_nt_1x4_lib4+0x102>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x20(%rax),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x40(%rax),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x60(%rax),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    124d <corner_dtrmm_l_u_nt_1x4_lib4+0x14d>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x20(%rax),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x40(%rax),%xmm0
subsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x60(%rax),%xmm0
subsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1252 <corner_dtrmm_l_u_nt_1x4_lib4+0x152>
movsd  -0x48(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x40(%rax)
movsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x60(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrmm_l_u_nt_1x4_lib4>:
movupd (%rsi),%xmm2
movupd 0x10(%rsi),%xmm1
movsd  (%rdi),%xmm0
unpcklpd %xmm0,%xmm0
mulpd  %xmm0,%xmm1
mulpd  %xmm2,%xmm0
test   %edx,%edx
je     1162 <corner_dtrmm_l_u_nt_1x4_lib4+0x62>
cmp    $0x1,%edx
jne    113f <corner_dtrmm_l_u_nt_1x4_lib4+0x3f>
movsd  (%rcx),%xmm2
movsd  0x40(%rcx),%xmm3
movhpd 0x20(%rcx),%xmm2
movhpd 0x60(%rcx),%xmm3
addpd  %xmm3,%xmm1
addpd  %xmm2,%xmm0
jmp    1162 <corner_dtrmm_l_u_nt_1x4_lib4+0x62>
movsd  (%rcx),%xmm2
movsd  0x40(%rcx),%xmm3
movhpd 0x20(%rcx),%xmm2
movhpd 0x60(%rcx),%xmm3
subpd  %xmm1,%xmm3
subpd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd %xmm3,%xmm1
movlpd %xmm0,(%r8)
movhpd %xmm0,0x20(%r8)
movlpd %xmm1,0x40(%r8)
movhpd %xmm1,0x60(%r8)
ret

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

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