#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ __m128d;

/* Variables and functions */
int /*<<< orphan*/ _mm_load_sd(double *);
int /*<<< orphan*/ _mm_loadh_pd(int /*<<< orphan*/, double *);
int /*<<< orphan*/ _mm_store_pd(double *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_store_sd(double *, int /*<<< orphan*/);
void corner_dtrtr_l_2_lib4(int kna, double *A, int sda, double *C) {
  const int bs = 4;
  __m128d u0, u1, u2, u3, u4, u5;
  if (kna == 1) {
    u0 = _mm_load_sd(&A[0 + bs * 0]);
    _mm_store_sd(&C[0 + bs * 0], u0);
    A += 1 + bs * (sda - 1);
    C += bs;
    u1 = _mm_load_sd(&A[0 + bs * 0]);
    u1 = _mm_loadh_pd(u1, &A[0 + bs * 1]);
    _mm_store_pd(&C[0 + bs * 0], u1);
  } else {
    u0 = _mm_load_sd(&A[0 + bs * 0]);
    _mm_store_sd(&C[0 + bs * 0], u0);
    u1 = _mm_load_sd(&A[1 + bs * 0]);
    u1 = _mm_loadh_pd(u1, &A[1 + bs * 1]);
    _mm_store_pd(&C[0 + bs * 1], u1);
  }
}


x86 assembly (clang, -O0):
<corner_dtrtr_l_2_lib4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
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    11d9 <corner_dtrtr_l_2_lib4+0x99>
mov    -0x10(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
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),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x20,%rsi
call   1050 <_mm_loadh_pd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1030 <_mm_store_pd@plt>
jmp    1224 <corner_dtrtr_l_2_lib4+0xe4>
mov    -0x10(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    $0x28,%rsi
call   1050 <_mm_loadh_pd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x20,%rdi
mov    -0x2c(%rbp),%esi
call   1030 <_mm_store_pd@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_dtrtr_l_2_lib4>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <_mm_load_sd@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
cmp    $0x1,%ebp
jne    1192 <corner_dtrtr_l_2_lib4+0x52>
lea    -0x3(,%r15,4),%eax
ff
movslq %eax,%rbp
lea    (%rbx,%rbp,8),%rdi
add    $0x20,%r14
call   1040 <_mm_load_sd@plt>
lea    (%rbx,%rbp,8),%rsi
add    $0x20,%rsi
mov    %eax,%edi
call   1050 <_mm_loadh_pd@plt>
jmp    11ad <corner_dtrtr_l_2_lib4+0x6d>
lea    0x8(%rbx),%rdi
call   1040 <_mm_load_sd@plt>
add    $0x28,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <_mm_loadh_pd@plt>
add    $0x20,%r14
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_mm_store_pd@plt>

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
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = 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
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %46
18: ; preds = %4
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = call i32 @_mm_load_sd(double* %20)
store i32 %21, i32* %10
%22 = load double*, double** %8
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load i32, i32* %10
%25 = call i32 @_mm_store_sd(double* %23, i32 %24)
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = mul nsw i32 4, %27
%29 = add nsw i32 1, %28
%30 = load double*, double** %6
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds double, double* %30, i64 %31
store double* %32, double** %6
%33 = load double*, double** %8
%34 = getelementptr inbounds double, double* %33, i64 4
store double* %34, double** %8
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = call i32 @_mm_load_sd(double* %36)
store i32 %37, i32* %11
%38 = load i32, i32* %11
%39 = load double*, double** %6
%40 = getelementptr inbounds double, double* %39, i64 4
%41 = call i32 @_mm_loadh_pd(i32 %38, double* %40)
store i32 %41, i32* %11
%42 = load double*, double** %8
%43 = getelementptr inbounds double, double* %42, i64 0
%44 = load i32, i32* %11
%45 = call i32 @_mm_store_pd(double* %43, i32 %44)
br label %65
46: ; preds = %4
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = call i32 @_mm_load_sd(double* %48)
store i32 %49, i32* %10
%50 = load double*, double** %8
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load i32, i32* %10
%53 = call i32 @_mm_store_sd(double* %51, i32 %52)
%54 = load double*, double** %6
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = call i32 @_mm_load_sd(double* %55)
store i32 %56, i32* %11
%57 = load i32, i32* %11
%58 = load double*, double** %6
%59 = getelementptr inbounds double, double* %58, i64 5
%60 = call i32 @_mm_loadh_pd(i32 %57, double* %59)
store i32 %60, i32* %11
%61 = load double*, double** %8
%62 = getelementptr inbounds double, double* %61, i64 4
%63 = load i32, i32* %11
%64 = call i32 @_mm_store_pd(double* %62, i32 %63)
br label %65
65: ; preds = %46, %18
ret void
}

LLVM IR (-O2):
define void @corner_dtrtr_l_2_lib4(i32 %0, double* %1, i32 %2, double* %3) {
%5 = icmp eq i32 %0, 1
%6 = tail call i32 @_mm_load_sd(double* %1)
%7 = tail call i32 @_mm_store_sd(double* %3, i32 %6)
br i1 %5, label %8, label %18
8: ; preds = %4
%9 = shl i32 %2, 2
%10 = add i32 %9, -3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %1, i64 %11
%13 = getelementptr inbounds double, double* %3, i64 4
%14 = tail call i32 @_mm_load_sd(double* %12)
%15 = getelementptr inbounds double, double* %12, i64 4
%16 = tail call i32 @_mm_loadh_pd(i32 %14, double* %15)
%17 = tail call i32 @_mm_store_pd(double* %13, i32 %16)
br label %25
18: ; preds = %4
%19 = getelementptr inbounds double, double* %1, i64 1
%20 = tail call i32 @_mm_load_sd(double* %19)
%21 = getelementptr inbounds double, double* %1, i64 5
%22 = tail call i32 @_mm_loadh_pd(i32 %20, double* %21)
%23 = getelementptr inbounds double, double* %3, i64 4
%24 = tail call i32 @_mm_store_pd(double* %23, i32 %22)
br label %25
25: ; preds = %18, %8
ret void
}