void corner_dtrtr_l_2_lib4(int kna, double *A, int sda, double *C) {
  const int bs = 4;
  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];
  } 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];
  }
}


x86 assembly (clang, -O0):
<corner_dtrtr_l_2_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   $0x1,-0x4(%rbp)
jne    1184 <corner_dtrtr_l_2_lib4+0x84>
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)
jmp    11b8 <corner_dtrtr_l_2_lib4+0xb8>
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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrtr_l_2_lib4>:
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rcx)
cmp    $0x1,%edi
jne    112a <corner_dtrtr_l_2_lib4+0x2a>
lea    -0x3(,%rdx,4),%eax
cltq
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x20(%rcx)
lea    (%rsi,%rax,8),%rsi
add    $0x20,%rsi
jmp    1138 <corner_dtrtr_l_2_lib4+0x38>
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x20(%rcx)
add    $0x28,%rsi
movsd  (%rsi),%xmm0
movsd  %xmm0,0x28(%rcx)
ret

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

LLVM IR (-O2):
define void @corner_dtrtr_l_2_lib4(i32 %0, double* nocapture %1, i32 %2, double* nocapture writeonly %3) {
%5 = icmp eq i32 %0, 1
%6 = load double, double* %1
store double %6, double* %3
br i1 %5, label %7, label %15
7: ; preds = %4
%8 = shl i32 %2, 2
%9 = add i32 %8, -3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = getelementptr inbounds double, double* %3, i64 4
%13 = load double, double* %11
store double %13, double* %12
%14 = getelementptr inbounds double, double* %11, i64 4
br label %20
15: ; preds = %4
%16 = getelementptr inbounds double, double* %1, i64 1
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %3, i64 4
store double %17, double* %18
%19 = getelementptr inbounds double, double* %1, i64 5
br label %20
20: ; preds = %15, %7
%21 = phi double* [ %14, %7 ], [ %19, %15 ]
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %3, i64 5
store double %22, double* %23
ret void
}