void corner_dtrtr_l_3_lib4(int kna, double *A, int sda, double *C) {
  const int bs = 4;
  if (kna == 0) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    C[0 + bs * 2] = A[2 + bs * 0];
    C[1 + bs * 2] = A[2 + bs * 1];
    C[2 + bs * 2] = A[2 + bs * 2];
  } else if (kna == 1) {
    C[0 + bs * 0] = A[0 + bs * 0];
    A += 1 + bs * (sda - 1);
    C += bs;
    C[0 + bs * 0] = A[0 + bs * 0];
    C[1 + bs * 0] = A[0 + bs * 1];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    C[2 + bs * 1] = A[1 + bs * 2];
  } else if (kna == 2) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    A += 2 + bs * (sda - 1);
    C += 2 * bs;
    C[0 + bs * 0] = A[0 + bs * 0];
    C[1 + bs * 0] = A[0 + bs * 1];
    C[2 + bs * 0] = A[0 + bs * 2];
  } else {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    C[0 + bs * 2] = A[2 + bs * 0];
    C[1 + bs * 2] = A[2 + bs * 1];
    C[2 + bs * 2] = A[2 + bs * 2];
  }
}


x86 assembly (clang, -O0):
<corner_dtrtr_l_3_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x4,-0x24(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1192 <corner_dtrtr_l_3_lib4+0x92>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x50(%rax)
jmp    1348 <corner_dtrtr_l_3_lib4+0x248>
cmpl   $0x1,-0x4(%rbp)
jne    1233 <corner_dtrtr_l_3_lib4+0x133>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x48(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x30(%rax)
jmp    1343 <corner_dtrtr_l_3_lib4+0x243>
cmpl   $0x2,-0x4(%rbp)
jne    12d4 <corner_dtrtr_l_3_lib4+0x1d4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
jmp    133e <corner_dtrtr_l_3_lib4+0x23e>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x50(%rax)
jmp    1343 <corner_dtrtr_l_3_lib4+0x243>
jmp    1348 <corner_dtrtr_l_3_lib4+0x248>
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrtr_l_3_lib4>:
cmp    $0x2,%edi
je     1145 <corner_dtrtr_l_3_lib4+0x45>
cmp    $0x1,%edi
je     1189 <corner_dtrtr_l_3_lib4+0x89>
test   %edi,%edi
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x40(%rcx)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x48(%rcx)
add    $0x50,%rsi
jmp    11cd <corner_dtrtr_l_3_lib4+0xcd>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rcx)
lea    -0x2(,%rdx,4),%eax
cltq
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x40(%rcx)
movsd  0x20(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x48(%rcx)
lea    (%rsi,%rax,8),%rsi
add    $0x40,%rsi
jmp    11cd <corner_dtrtr_l_3_lib4+0xcd>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rcx)
lea    -0x3(,%rdx,4),%eax
cltq
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x20(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x8(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x40(%rcx)
movsd  0x28(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x48(%rcx)
lea    (%rsi,%rax,8),%rsi
add    $0x48,%rsi
movsd  (%rsi),%xmm0
movsd  %xmm0,0x50(%rcx)
ret

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

LLVM IR (-O2):
define void @corner_dtrtr_l_3_lib4(i32 %0, double* nocapture %1, i32 %2, double* writeonly %3) {
switch i32 %0, label %56 [
i32 0, label %5
i32 1, label %20
i32 2, label %38
]
5: ; preds = %4
%6 = load double, double* %1
store double %6, double* %3
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %3, i64 4
store double %8, double* %9
%10 = getelementptr inbounds double, double* %1, i64 5
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %3, i64 5
store double %11, double* %12
%13 = getelementptr inbounds double, double* %1, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %3, i64 8
store double %14, double* %15
%16 = getelementptr inbounds double, double* %1, i64 6
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %3, i64 9
store double %17, double* %18
%19 = getelementptr inbounds double, double* %1, i64 10
br label %71
20: ; preds = %4
%21 = load double, double* %1
store double %21, double* %3
%22 = shl i32 %2, 2
%23 = add i32 %22, -3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %1, i64 %24
%26 = getelementptr inbounds double, double* %3, i64 4
%27 = load double, double* %25
store double %27, double* %26
%28 = getelementptr inbounds double, double* %25, i64 4
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %3, i64 5
store double %29, double* %30
%31 = getelementptr inbounds double, double* %25, i64 1
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %3, i64 8
store double %32, double* %33
%34 = getelementptr inbounds double, double* %25, i64 5
%35 = load double, double* %34
%36 = getelementptr inbounds double, double* %3, i64 9
store double %35, double* %36
%37 = getelementptr inbounds double, double* %25, i64 9
br label %71
38: ; preds = %4
%39 = load double, double* %1
store double %39, double* %3
%40 = getelementptr inbounds double, double* %1, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %3, i64 4
store double %41, double* %42
%43 = getelementptr inbounds double, double* %1, i64 5
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %3, i64 5
store double %44, double* %45
%46 = shl i32 %2, 2
%47 = add i32 %46, -2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = getelementptr inbounds double, double* %3, i64 8
%51 = load double, double* %49
store double %51, double* %50
%52 = getelementptr inbounds double, double* %49, i64 4
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %3, i64 9
store double %53, double* %54
%55 = getelementptr inbounds double, double* %49, i64 8
br label %71
56: ; preds = %4
%57 = load double, double* %1
store double %57, double* %3
%58 = getelementptr inbounds double, double* %1, i64 1
%59 = load double, double* %58
%60 = getelementptr inbounds double, double* %3, i64 4
store double %59, double* %60
%61 = getelementptr inbounds double, double* %1, i64 5
%62 = load double, double* %61
%63 = getelementptr inbounds double, double* %3, i64 5
store double %62, double* %63
%64 = getelementptr inbounds double, double* %1, i64 2
%65 = load double, double* %64
%66 = getelementptr inbounds double, double* %3, i64 8
store double %65, double* %66
%67 = getelementptr inbounds double, double* %1, i64 6
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %3, i64 9
store double %68, double* %69
%70 = getelementptr inbounds double, double* %1, i64 10
br label %71
71: ; preds = %20, %56, %38, %5
%72 = phi double* [ %37, %20 ], [ %70, %56 ], [ %55, %38 ], [ %19, %5 ]
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %3, i64 10
store double %73, double* %74
ret void
}