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


x86 assembly (clang, -O0):
<corner_dtrma_2_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     1137 <corner_dtrma_2_lib4+0x37>
cmpl   $0x2,-0x4(%rbp)
je     1137 <corner_dtrma_2_lib4+0x37>
cmpl   $0x3,-0x4(%rbp)
jne    1170 <corner_dtrma_2_lib4+0x70>
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)
jmp    11c1 <corner_dtrma_2_lib4+0xc1>
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  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrma_2_lib4>:
cmp    $0x3,%edi
ja     1127 <corner_dtrma_2_lib4+0x27>
cmp    $0x1,%edi
je     1127 <corner_dtrma_2_lib4+0x27>
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
ret
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
lea    -0x3(,%rcx,4),%eax
cltq
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx,%rax,8)
ret

LLVM IR (-O0):
define void @corner_dtrma_2_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 %18, label %12
12: ; preds = %4
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 2
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %34
18: ; preds = %15, %12, %4
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = load double*, double** %7
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double*, double** %6
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double*, double** %7
%28 = getelementptr inbounds double, double* %27, i64 1
store double %26, double* %28
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 5
%31 = load double, double* %30
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 5
store double %31, double* %33
br label %57
34: ; preds = %15
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
%40 = load i32, i32* %8
%41 = sub nsw i32 %40, 1
%42 = mul nsw i32 4, %41
%43 = add nsw i32 1, %42
%44 = load double*, double** %7
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds double, double* %44, i64 %45
store double* %46, double** %7
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i64 1
%49 = load double, double* %48
%50 = load double*, double** %7
%51 = getelementptr inbounds double, double* %50, i64 0
store double %49, double* %51
%52 = load double*, double** %6
%53 = getelementptr inbounds double, double* %52, i64 5
%54 = load double, double* %53
%55 = load double*, double** %7
%56 = getelementptr inbounds double, double* %55, i64 4
store double %54, double* %56
br label %57
57: ; preds = %34, %18
ret void
}

LLVM IR (-O2):
define void @corner_dtrma_2_lib4(i32 %0, double* nocapture %1, double* nocapture writeonly %2, i32 %3) {
switch i32 %0, label %13 [
i32 3, label %5
i32 2, label %5
i32 0, label %5
]
5: ; preds = %4, %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 5
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %2, i64 5
store double %11, double* %12
br label %24
13: ; preds = %4
%14 = load double, double* %1
store double %14, double* %2
%15 = shl i32 %3, 2
%16 = add i32 %15, -3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %2, i64 %17
%19 = getelementptr inbounds double, double* %1, i64 1
%20 = load double, double* %19
store double %20, double* %18
%21 = getelementptr inbounds double, double* %1, i64 5
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %18, i64 4
store double %22, double* %23
br label %24
24: ; preds = %13, %5
ret void
}