void corner_dtrma_3_lib4(int kna, double *A, double *C, int sdc) {
  const int bs = 4;
  if (kna == 0 || kna == 3) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[1 + bs * 0] = A[1 + bs * 0];
    C[2 + bs * 0] = A[2 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    C[2 + bs * 1] = A[2 + bs * 1];
    C[2 + bs * 2] = A[2 + bs * 2];
    return;
  } else if (kna == 1) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C += 1 + bs * (sdc - 1);
    C[0 + bs * 0] = A[1 + bs * 0];
    C[1 + bs * 0] = A[2 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 1];
    C[1 + bs * 1] = A[2 + bs * 1];
    C[1 + bs * 2] = A[2 + bs * 2];
    return;
  } else {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[1 + bs * 0] = A[1 + bs * 0];
    C[1 + bs * 1] = A[1 + bs * 1];
    C += 2 + bs * (sdc - 1);
    C[0 + bs * 0] = A[2 + bs * 0];
    C[0 + bs * 1] = A[2 + bs * 1];
    C[0 + bs * 2] = A[2 + bs * 2];
    return;
  }
}


x86 assembly (clang, -O0):
<corner_dtrma_3_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x4,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112d <corner_dtrma_3_lib4+0x2d>
cmpl   $0x3,-0x4(%rbp)
jne    119c <corner_dtrma_3_lib4+0x9c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x50(%rax)
jmp    12b9 <corner_dtrma_3_lib4+0x1b9>
cmpl   $0x1,-0x4(%rbp)
jne    1232 <corner_dtrma_3_lib4+0x132>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x48(%rax)
jmp    12b9 <corner_dtrma_3_lib4+0x1b9>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrma_3_lib4>:
cmp    $0x3,%edi
je     1112 <corner_dtrma_3_lib4+0x12>
cmp    $0x1,%edi
je     114d <corner_dtrma_3_lib4+0x4d>
test   %edi,%edi
jne    1195 <corner_dtrma_3_lib4+0x95>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x10(%rdx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x30(%rdx)
movsd  0x50(%rsi),%xmm0
movsd  %xmm0,0x50(%rdx)
ret
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
lea    -0x3(,%rcx,4),%eax
cltq
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx,%rax,8)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx,%rax,8)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx,%rax,8)
movsd  0x50(%rsi),%xmm0
movsd  %xmm0,0x48(%rdx,%rax,8)
ret
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
lea    -0x2(,%rcx,4),%eax
cltq
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx,%rax,8)
movsd  0x50(%rsi),%xmm0
movsd  %xmm0,0x40(%rdx,%rax,8)
ret

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

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