void kernel_dgetr_3_lib4(int tri, int kmax, int kna, double *A, double *C,
                         int sdc) {
  if (tri == 1) {
    kmax += 1;
  }
  const int bs = 4;
  int k;
  k = 0;
  if (kmax < kna)
    goto cleanup_loop;
  if (kna > 0) {
    for (; k < kna; k++) {
      C[0 + bs * 0] = A[0 + bs * 0];
      C[0 + bs * 1] = A[1 + bs * 0];
      C[0 + bs * 2] = A[2 + bs * 0];
      C += 1;
      A += bs;
    }
    C += bs * (sdc - 1);
  }
  for (; k < kmax - 3; k += 4) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[0 + bs * 2] = A[2 + bs * 0];
    C[1 + bs * 0] = A[0 + bs * 1];
    C[1 + bs * 1] = A[1 + bs * 1];
    C[1 + bs * 2] = A[2 + bs * 1];
    C[2 + bs * 0] = A[0 + bs * 2];
    C[2 + bs * 1] = A[1 + bs * 2];
    C[2 + bs * 2] = A[2 + bs * 2];
    C[3 + bs * 0] = A[0 + bs * 3];
    C[3 + bs * 1] = A[1 + bs * 3];
    C[3 + bs * 2] = A[2 + bs * 3];
    C += bs * sdc;
    A += bs * bs;
  }
cleanup_loop:
  for (; k < kmax; k++) {
    C[0 + bs * 0] = A[0 + bs * 0];
    C[0 + bs * 1] = A[1 + bs * 0];
    C[0 + bs * 2] = A[2 + bs * 0];
    C += 1;
    A += bs;
  }
  if (tri == 1) {
    kna = (bs - (bs - kna + kmax) % bs) % bs;
    if (kna == 1) {
      C[0 + bs * 1] = A[1 + bs * 0];
      C[0 + bs * 2] = A[2 + bs * 0];
      C[1 + bs * (sdc + 1)] = A[2 + bs * 1];
    } else {
      C[0 + bs * 1] = A[1 + bs * 0];
      C[0 + bs * 2] = A[2 + bs * 0];
      C[1 + bs * 2] = A[2 + bs * 1];
    }
  }
}


x86 assembly (clang, -O0):
<kernel_dgetr_3_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    112c <kernel_dgetr_3_lib4+0x2c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x4,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    114b <kernel_dgetr_3_lib4+0x4b>
jmp    1300 <kernel_dgetr_3_lib4+0x200>
cmpl   $0x0,-0xc(%rbp)
jle    11db <kernel_dgetr_3_lib4+0xdb>
jmp    115a <kernel_dgetr_3_lib4+0x5a>
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c0 <kernel_dgetr_3_lib4+0xc0>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115a <kernel_dgetr_3_lib4+0x5a>
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
shl    $0x2,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    11e0 <kernel_dgetr_3_lib4+0xe0>
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    12fb <kernel_dgetr_3_lib4+0x1fb>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x18(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x18(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
mov    -0x18(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
movsd  0x48(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x18(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x50(%rax)
mov    -0x18(%rbp),%rax
movsd  0x60(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x18(%rbp),%rax
movsd  0x68(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x18(%rbp),%rax
movsd  0x70(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x58(%rax)
mov    -0x24(%rbp),%ecx
shl    $0x2,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e0 <kernel_dgetr_3_lib4+0xe0>
jmp    1300 <kernel_dgetr_3_lib4+0x200>
jmp    1305 <kernel_dgetr_3_lib4+0x205>
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    136b <kernel_dgetr_3_lib4+0x26b>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1305 <kernel_dgetr_3_lib4+0x205>
cmpl   $0x1,-0x4(%rbp)
jne    1429 <kernel_dgetr_3_lib4+0x329>
mov    $0x4,%eax
sub    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    $0x4,%eax
sub    %edx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    13ee <kernel_dgetr_3_lib4+0x2ee>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x18(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1424 <kernel_dgetr_3_lib4+0x324>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x18(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
jmp    1429 <kernel_dgetr_3_lib4+0x329>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_dgetr_3_lib4>:
push   %r15
push   %r14
push   %rbx
xor    %r10d,%r10d
cmp    $0x1,%edi
sete   %r10b
add    %esi,%r10d
xor    %esi,%esi
cmp    %edx,%r10d
jl     1315 <kernel_dgetr_3_lib4+0x215>
test   %edx,%edx
jle    125f <kernel_dgetr_3_lib4+0x15f>
lea    -0x1(%rdx),%ebx
xor    %esi,%esi
cmp    $0x2,%ebx
jb     11bd <kernel_dgetr_3_lib4+0xbd>
mov    %rbx,%rax
shl    $0x5,%rax
add    %rcx,%rax
add    $0x18,%rax
cmp    %r8,%rax
jbe    1153 <kernel_dgetr_3_lib4+0x53>
lea    (%r8,%rbx,8),%rax
add    $0x48,%rax
cmp    %rcx,%rax
ja     11bd <kernel_dgetr_3_lib4+0xbd>
add    $0x1,%rbx
mov    %ebx,%eax
and    $0x1,%eax
test   %rax,%rax
mov    $0x2,%r11d
cmovne %rax,%r11
mov    %rbx,%rsi
sub    %r11,%rsi
lea    (%r8,%rsi,8),%r11
mov    %rsi,%rax
shl    $0x5,%rax
add    %rcx,%rax
xor    %ebx,%ebx
nop
movups (%rcx),%xmm0
movups 0x10(%rcx),%xmm1
movups 0x20(%rcx),%xmm2
movaps %xmm0,%xmm3
movlhps %xmm2,%xmm3
unpckhpd %xmm2,%xmm0
movhps 0x30(%rcx),%xmm1
movups %xmm3,(%r8,%rbx,8)
movups %xmm0,0x20(%r8,%rbx,8)
movups %xmm1,0x40(%r8,%rbx,8)
add    $0x2,%rbx
add    $0x40,%rcx
cmp    %rbx,%rsi
jne    1180 <kernel_dgetr_3_lib4+0x80>
mov    %r11,%r8
mov    %rax,%rcx
mov    %edx,%ebx
sub    %esi,%ebx
mov    %esi,%eax
not    %eax
test   $0x1,%bl
je     11f4 <kernel_dgetr_3_lib4+0xf4>
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
add    $0x8,%r8
add    $0x20,%rcx
add    $0x1,%esi
add    %edx,%eax
je     124d <kernel_dgetr_3_lib4+0x14d>
mov    %edx,%eax
sub    %esi,%eax
nopl   0x0(%rax)
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
movsd  0x20(%rcx),%xmm0
movsd  %xmm0,0x8(%r8)
movsd  0x28(%rcx),%xmm0
movsd  %xmm0,0x28(%r8)
movsd  0x30(%rcx),%xmm0
movsd  %xmm0,0x48(%r8)
add    $0x10,%r8
add    $0x40,%rcx
add    $0xfffffffe,%eax
jne    1200 <kernel_dgetr_3_lib4+0x100>
lea    -0x4(,%r9,4),%eax
ff
cltq
lea    (%r8,%rax,8),%r8
mov    %edx,%esi
jmp    1261 <kernel_dgetr_3_lib4+0x161>
xor    %esi,%esi
lea    -0x3(%r10),%r11d
cmp    %r11d,%esi
jge    1315 <kernel_dgetr_3_lib4+0x215>
lea    0x0(,%r9,4),%eax
cltq
shl    $0x3,%rax
nopl   0x0(%rax)
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
movsd  0x20(%rcx),%xmm0
movsd  %xmm0,0x8(%r8)
movsd  0x28(%rcx),%xmm0
movsd  %xmm0,0x28(%r8)
movsd  0x30(%rcx),%xmm0
movsd  %xmm0,0x48(%r8)
movsd  0x40(%rcx),%xmm0
movsd  %xmm0,0x10(%r8)
movsd  0x48(%rcx),%xmm0
movsd  %xmm0,0x30(%r8)
movsd  0x50(%rcx),%xmm0
movsd  %xmm0,0x50(%r8)
movsd  0x60(%rcx),%xmm0
movsd  %xmm0,0x18(%r8)
movsd  0x68(%rcx),%xmm0
movsd  %xmm0,0x38(%r8)
movsd  0x70(%rcx),%xmm0
movsd  %xmm0,0x58(%r8)
sub    $0xffffffffffffff80,%rcx
add    $0x4,%esi
add    %rax,%r8
cmp    %r11d,%esi
jl     1280 <kernel_dgetr_3_lib4+0x180>
cmp    %r10d,%esi
jge    144d <kernel_dgetr_3_lib4+0x34d>
mov    %esi,%r15d
not    %r15d
add    %r10d,%r15d
cmp    $0x2,%r15d
jb     13bd <kernel_dgetr_3_lib4+0x2bd>
mov    %r15,%rax
shl    $0x5,%rax
add    %rcx,%rax
add    $0x18,%rax
cmp    %rax,%r8
jae    1351 <kernel_dgetr_3_lib4+0x251>
lea    (%r8,%r15,8),%rax
add    $0x48,%rax
cmp    %rax,%rcx
jb     13bd <kernel_dgetr_3_lib4+0x2bd>
add    $0x1,%r15
mov    %r15d,%eax
and    $0x1,%eax
test   %rax,%rax
mov    $0x2,%ebx
cmovne %rax,%rbx
sub    %rbx,%r15
add    %r15d,%esi
lea    (%r8,%r15,8),%r11
mov    %r15,%r14
shl    $0x5,%r14
add    %rcx,%r14
xor    %ebx,%ebx
nopl   (%rax)
movups (%rcx),%xmm0
movups 0x10(%rcx),%xmm1
movups 0x20(%rcx),%xmm2
movaps %xmm0,%xmm3
movlhps %xmm2,%xmm3
unpckhpd %xmm2,%xmm0
movhps 0x30(%rcx),%xmm1
movups %xmm3,(%r8,%rbx,8)
movups %xmm0,0x20(%r8,%rbx,8)
movups %xmm1,0x40(%r8,%rbx,8)
add    $0x2,%rbx
add    $0x40,%rcx
cmp    %rbx,%r15
jne    1380 <kernel_dgetr_3_lib4+0x280>
mov    %r11,%r8
mov    %r14,%rcx
mov    %r10d,%ebx
sub    %esi,%ebx
lea    0x1(%rsi),%eax
test   $0x1,%bl
je     13f3 <kernel_dgetr_3_lib4+0x2f3>
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
add    $0x8,%r8
add    $0x20,%rcx
mov    %eax,%esi
cmp    %eax,%r10d
je     144d <kernel_dgetr_3_lib4+0x34d>
mov    %r10d,%eax
sub    %esi,%eax
nopl   (%rax)
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
movsd  0x20(%rcx),%xmm0
movsd  %xmm0,0x8(%r8)
movsd  0x28(%rcx),%xmm0
movsd  %xmm0,0x28(%r8)
movsd  0x30(%rcx),%xmm0
movsd  %xmm0,0x48(%r8)
add    $0x10,%r8
add    $0x40,%rcx
add    $0xfffffffe,%eax
jne    1400 <kernel_dgetr_3_lib4+0x300>
cmp    $0x1,%edi
jne    148f <kernel_dgetr_3_lib4+0x38f>
sub    %r10d,%edx
and    $0x3,%edx
cmp    $0x1,%edx
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x20(%r8)
movsd  0x10(%rcx),%xmm0
movsd  %xmm0,0x40(%r8)
movsd  0x30(%rcx),%xmm0
lea    0x5(,%r9,4),%eax
mov    $0x9,%ecx
cmove  %eax,%ecx
movslq %ecx,%rax
movsd  %xmm0,(%r8,%rax,8)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @kernel_dgetr_3_lib4(i32 %0, i32 %1, i32 %2, double* %3, double* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
store i32 %5, i32* %12
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %6
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 1
store i32 %19, i32* %8
br label %20
20: ; preds = %17, %6
store i32 4, i32* %13
store i32 0, i32* %14
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
br label %141
25: ; preds = %20
%26 = load i32, i32* %9
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %63
28: ; preds = %25
br label %29
29: ; preds = %53, %28
%30 = load i32, i32* %14
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %56
33: ; preds = %29
%34 = load double*, double** %10
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double*, double** %11
%38 = getelementptr inbounds double, double* %37, i64 0
store double %36, double* %38
%39 = load double*, double** %10
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = load double*, double** %11
%43 = getelementptr inbounds double, double* %42, i64 4
store double %41, double* %43
%44 = load double*, double** %10
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = load double*, double** %11
%48 = getelementptr inbounds double, double* %47, i64 8
store double %46, double* %48
%49 = load double*, double** %11
%50 = getelementptr inbounds double, double* %49, i64 1
store double* %50, double** %11
%51 = load double*, double** %10
%52 = getelementptr inbounds double, double* %51, i64 4
store double* %52, double** %10
br label %53
53: ; preds = %33
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 1
store i32 %55, i32* %14
br label %29
56: ; preds = %29
%57 = load i32, i32* %12
%58 = sub nsw i32 %57, 1
%59 = mul nsw i32 4, %58
%60 = load double*, double** %11
%61 = sext i32 %59 to i64
%62 = getelementptr inbounds double, double* %60, i64 %61
store double* %62, double** %11
br label %63
63: ; preds = %56, %25
br label %64
64: ; preds = %137, %63
%65 = load i32, i32* %14
%66 = load i32, i32* %8
%67 = sub nsw i32 %66, 3
%68 = icmp slt i32 %65, %67
br i1 %68, label %69, label %140
69: ; preds = %64
%70 = load double*, double** %10
%71 = getelementptr inbounds double, double* %70, i64 0
%72 = load double, double* %71
%73 = load double*, double** %11
%74 = getelementptr inbounds double, double* %73, i64 0
store double %72, double* %74
%75 = load double*, double** %10
%76 = getelementptr inbounds double, double* %75, i64 1
%77 = load double, double* %76
%78 = load double*, double** %11
%79 = getelementptr inbounds double, double* %78, i64 4
store double %77, double* %79
%80 = load double*, double** %10
%81 = getelementptr inbounds double, double* %80, i64 2
%82 = load double, double* %81
%83 = load double*, double** %11
%84 = getelementptr inbounds double, double* %83, i64 8
store double %82, double* %84
%85 = load double*, double** %10
%86 = getelementptr inbounds double, double* %85, i64 4
%87 = load double, double* %86
%88 = load double*, double** %11
%89 = getelementptr inbounds double, double* %88, i64 1
store double %87, double* %89
%90 = load double*, double** %10
%91 = getelementptr inbounds double, double* %90, i64 5
%92 = load double, double* %91
%93 = load double*, double** %11
%94 = getelementptr inbounds double, double* %93, i64 5
store double %92, double* %94
%95 = load double*, double** %10
%96 = getelementptr inbounds double, double* %95, i64 6
%97 = load double, double* %96
%98 = load double*, double** %11
%99 = getelementptr inbounds double, double* %98, i64 9
store double %97, double* %99
%100 = load double*, double** %10
%101 = getelementptr inbounds double, double* %100, i64 8
%102 = load double, double* %101
%103 = load double*, double** %11
%104 = getelementptr inbounds double, double* %103, i64 2
store double %102, double* %104
%105 = load double*, double** %10
%106 = getelementptr inbounds double, double* %105, i64 9
%107 = load double, double* %106
%108 = load double*, double** %11
%109 = getelementptr inbounds double, double* %108, i64 6
store double %107, double* %109
%110 = load double*, double** %10
%111 = getelementptr inbounds double, double* %110, i64 10
%112 = load double, double* %111
%113 = load double*, double** %11
%114 = getelementptr inbounds double, double* %113, i64 10
store double %112, double* %114
%115 = load double*, double** %10
%116 = getelementptr inbounds double, double* %115, i64 12
%117 = load double, double* %116
%118 = load double*, double** %11
%119 = getelementptr inbounds double, double* %118, i64 3
store double %117, double* %119
%120 = load double*, double** %10
%121 = getelementptr inbounds double, double* %120, i64 13
%122 = load double, double* %121
%123 = load double*, double** %11
%124 = getelementptr inbounds double, double* %123, i64 7
store double %122, double* %124
%125 = load double*, double** %10
%126 = getelementptr inbounds double, double* %125, i64 14
%127 = load double, double* %126
%128 = load double*, double** %11
%129 = getelementptr inbounds double, double* %128, i64 11
store double %127, double* %129
%130 = load i32, i32* %12
%131 = mul nsw i32 4, %130
%132 = load double*, double** %11
%133 = sext i32 %131 to i64
%134 = getelementptr inbounds double, double* %132, i64 %133
store double* %134, double** %11
%135 = load double*, double** %10
%136 = getelementptr inbounds double, double* %135, i64 16
store double* %136, double** %10
br label %137
137: ; preds = %69
%138 = load i32, i32* %14
%139 = add nsw i32 %138, 4
store i32 %139, i32* %14
br label %64
140: ; preds = %64
br label %141
141: ; preds = %140, %24
br label %142
142: ; preds = %166, %141
%143 = load i32, i32* %14
%144 = load i32, i32* %8
%145 = icmp slt i32 %143, %144
br i1 %145, label %146, label %169
146: ; preds = %142
%147 = load double*, double** %10
%148 = getelementptr inbounds double, double* %147, i64 0
%149 = load double, double* %148
%150 = load double*, double** %11
%151 = getelementptr inbounds double, double* %150, i64 0
store double %149, double* %151
%152 = load double*, double** %10
%153 = getelementptr inbounds double, double* %152, i64 1
%154 = load double, double* %153
%155 = load double*, double** %11
%156 = getelementptr inbounds double, double* %155, i64 4
store double %154, double* %156
%157 = load double*, double** %10
%158 = getelementptr inbounds double, double* %157, i64 2
%159 = load double, double* %158
%160 = load double*, double** %11
%161 = getelementptr inbounds double, double* %160, i64 8
store double %159, double* %161
%162 = load double*, double** %11
%163 = getelementptr inbounds double, double* %162, i64 1
store double* %163, double** %11
%164 = load double*, double** %10
%165 = getelementptr inbounds double, double* %164, i64 4
store double* %165, double** %10
br label %166
166: ; preds = %146
%167 = load i32, i32* %14
%168 = add nsw i32 %167, 1
store i32 %168, i32* %14
br label %142
169: ; preds = %142
%170 = load i32, i32* %7
%171 = icmp eq i32 %170, 1
br i1 %171, label %172, label %220
172: ; preds = %169
%173 = load i32, i32* %9
%174 = sub nsw i32 4, %173
%175 = load i32, i32* %8
%176 = add nsw i32 %174, %175
%177 = srem i32 %176, 4
%178 = sub nsw i32 4, %177
%179 = srem i32 %178, 4
store i32 %179, i32* %9
%180 = load i32, i32* %9
%181 = icmp eq i32 %180, 1
br i1 %181, label %182, label %203
182: ; preds = %172
%183 = load double*, double** %10
%184 = getelementptr inbounds double, double* %183, i64 1
%185 = load double, double* %184
%186 = load double*, double** %11
%187 = getelementptr inbounds double, double* %186, i64 4
store double %185, double* %187
%188 = load double*, double** %10
%189 = getelementptr inbounds double, double* %188, i64 2
%190 = load double, double* %189
%191 = load double*, double** %11
%192 = getelementptr inbounds double, double* %191, i64 8
store double %190, double* %192
%193 = load double*, double** %10
%194 = getelementptr inbounds double, double* %193, i64 6
%195 = load double, double* %194
%196 = load double*, double** %11
%197 = load i32, i32* %12
%198 = add nsw i32 %197, 1
%199 = mul nsw i32 4, %198
%200 = add nsw i32 1, %199
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds double, double* %196, i64 %201
store double %195, double* %202
br label %219
203: ; preds = %172
%204 = load double*, double** %10
%205 = getelementptr inbounds double, double* %204, i64 1
%206 = load double, double* %205
%207 = load double*, double** %11
%208 = getelementptr inbounds double, double* %207, i64 4
store double %206, double* %208
%209 = load double*, double** %10
%210 = getelementptr inbounds double, double* %209, i64 2
%211 = load double, double* %210
%212 = load double*, double** %11
%213 = getelementptr inbounds double, double* %212, i64 8
store double %211, double* %213
%214 = load double*, double** %10
%215 = getelementptr inbounds double, double* %214, i64 6
%216 = load double, double* %215
%217 = load double*, double** %11
%218 = getelementptr inbounds double, double* %217, i64 9
store double %216, double* %218
br label %219
219: ; preds = %203, %182
br label %220
220: ; preds = %219, %169
ret void
}

LLVM IR (-O2):
define void @kernel_dgetr_3_lib4(i32 %0, i32 %1, i32 %2, double* nocapture %3, double* nocapture writeonly %4, i32 %5) {
%7 = icmp eq i32 %0, 1
%8 = zext i1 %7 to i32
%9 = add i32 %8, %1
%10 = icmp slt i32 %9, %2
br i1 %10, label %164, label %11
11: ; preds = %6
%12 = icmp sgt i32 %2, 0
br i1 %12, label %13, label %113
13: ; preds = %11
%14 = add i32 %2, -1
%15 = zext i32 %14 to i64
%16 = add nuw nsw i64 %15, 1
%17 = icmp ult i32 %14, 2
br i1 %17, label %55, label %18
18: ; preds = %13
%19 = add i32 %2, -1
%20 = zext i32 %19 to i64
%21 = add nuw nsw i64 %20, 9
%22 = getelementptr double, double* %4, i64 %21
%23 = shl nuw nsw i64 %20, 2
%24 = or i64 %23, 3
%25 = getelementptr double, double* %3, i64 %24
%26 = icmp ugt double* %25, %4
%27 = icmp ugt double* %22, %3
%28 = and i1 %26, %27
br i1 %28, label %55, label %29
29: ; preds = %18
%30 = and i64 %16, 1
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i64 2, i64 %30
%33 = sub nsw i64 %16, %32
%34 = trunc i64 %33 to i32
%35 = getelementptr double, double* %4, i64 %33
%36 = shl nsw i64 %33, 2
%37 = getelementptr double, double* %3, i64 %36
br label %38
38: ; preds = %38, %29
%39 = phi i64 [ 0, %29 ], [ %53, %38 ]
%40 = getelementptr double, double* %4, i64 %39
%41 = shl i64 %39, 2
%42 = getelementptr double, double* %3, i64 %41
%43 = bitcast double* %42 to <8 x double>*
%44 = load <8 x double>, <8 x double>* %43
%45 = shufflevector <8 x double> %44, <8 x double> poison, <2 x i32> <i32 0, i32 4>
%46 = shufflevector <8 x double> %44, <8 x double> poison, <2 x i32> <i32 1, i32 5>
%47 = shufflevector <8 x double> %44, <8 x double> poison, <2 x i32> <i32 2, i32 6>
%48 = bitcast double* %40 to <2 x double>*
store <2 x double> %45, <2 x double>* %48
%49 = getelementptr inbounds double, double* %40, i64 4
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %46, <2 x double>* %50
%51 = getelementptr inbounds double, double* %40, i64 8
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %47, <2 x double>* %52
%53 = add nuw i64 %39, 2
%54 = icmp eq i64 %53, %33
br i1 %54, label %55, label %38
55: ; preds = %38, %18, %13
%56 = phi i32 [ 0, %18 ], [ 0, %13 ], [ %34, %38 ]
%57 = phi double* [ %4, %18 ], [ %4, %13 ], [ %35, %38 ]
%58 = phi double* [ %3, %18 ], [ %3, %13 ], [ %37, %38 ]
%59 = sub i32 %2, %56
%60 = xor i32 %56, -1
%61 = and i32 %59, 1
%62 = icmp eq i32 %61, 0
br i1 %62, label %74, label %63
63: ; preds = %55
%64 = load double, double* %58
store double %64, double* %57
%65 = getelementptr inbounds double, double* %58, i64 1
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %57, i64 4
store double %66, double* %67
%68 = getelementptr inbounds double, double* %58, i64 2
%69 = load double, double* %68
%70 = getelementptr inbounds double, double* %57, i64 8
store double %69, double* %70
%71 = getelementptr inbounds double, double* %57, i64 1
%72 = getelementptr inbounds double, double* %58, i64 4
%73 = add nuw nsw i32 %56, 1
br label %74
74: ; preds = %63, %55
%75 = phi double* [ undef, %55 ], [ %71, %63 ]
%76 = phi double* [ undef, %55 ], [ %72, %63 ]
%77 = phi i32 [ %56, %55 ], [ %73, %63 ]
%78 = phi double* [ %57, %55 ], [ %71, %63 ]
%79 = phi double* [ %58, %55 ], [ %72, %63 ]
%80 = sub i32 0, %2
%81 = icmp eq i32 %60, %80
br i1 %81, label %106, label %82
82: ; preds = %74, %82
%83 = phi i32 [ %104, %82 ], [ %77, %74 ]
%84 = phi double* [ %102, %82 ], [ %78, %74 ]
%85 = phi double* [ %103, %82 ], [ %79, %74 ]
%86 = load double, double* %85
store double %86, double* %84
%87 = getelementptr inbounds double, double* %85, i64 1
%88 = load double, double* %87
%89 = getelementptr inbounds double, double* %84, i64 4
store double %88, double* %89
%90 = getelementptr inbounds double, double* %85, i64 2
%91 = load double, double* %90
%92 = getelementptr inbounds double, double* %84, i64 8
store double %91, double* %92
%93 = getelementptr inbounds double, double* %84, i64 1
%94 = getelementptr inbounds double, double* %85, i64 4
%95 = load double, double* %94
store double %95, double* %93
%96 = getelementptr inbounds double, double* %85, i64 5
%97 = load double, double* %96
%98 = getelementptr inbounds double, double* %84, i64 5
store double %97, double* %98
%99 = getelementptr inbounds double, double* %85, i64 6
%100 = load double, double* %99
%101 = getelementptr inbounds double, double* %84, i64 9
store double %100, double* %101
%102 = getelementptr inbounds double, double* %84, i64 2
%103 = getelementptr inbounds double, double* %85, i64 8
%104 = add nuw nsw i32 %83, 2
%105 = icmp eq i32 %104, %2
br i1 %105, label %106, label %82
106: ; preds = %82, %74
%107 = phi double* [ %75, %74 ], [ %102, %82 ]
%108 = phi double* [ %76, %74 ], [ %103, %82 ]
%109 = shl i32 %5, 2
%110 = add i32 %109, -4
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %107, i64 %111
br label %113
113: ; preds = %106, %11
%114 = phi double* [ %108, %106 ], [ %3, %11 ]
%115 = phi double* [ %112, %106 ], [ %4, %11 ]
%116 = phi i32 [ %2, %106 ], [ 0, %11 ]
%117 = add nsw i32 %9, -3
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %164
119: ; preds = %113
%120 = shl nsw i32 %5, 2
%121 = sext i32 %120 to i64
br label %122
122: ; preds = %119, %122
%123 = phi i32 [ %116, %119 ], [ %162, %122 ]
%124 = phi double* [ %115, %119 ], [ %160, %122 ]
%125 = phi double* [ %114, %119 ], [ %161, %122 ]
%126 = load double, double* %125
store double %126, double* %124
%127 = getelementptr inbounds double, double* %125, i64 1
%128 = load double, double* %127
%129 = getelementptr inbounds double, double* %124, i64 4
store double %128, double* %129
%130 = getelementptr inbounds double, double* %125, i64 2
%131 = load double, double* %130
%132 = getelementptr inbounds double, double* %124, i64 8
store double %131, double* %132
%133 = getelementptr inbounds double, double* %125, i64 4
%134 = load double, double* %133
%135 = getelementptr inbounds double, double* %124, i64 1
store double %134, double* %135
%136 = getelementptr inbounds double, double* %125, i64 5
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %124, i64 5
store double %137, double* %138
%139 = getelementptr inbounds double, double* %125, i64 6
%140 = load double, double* %139
%141 = getelementptr inbounds double, double* %124, i64 9
store double %140, double* %141
%142 = getelementptr inbounds double, double* %125, i64 8
%143 = load double, double* %142
%144 = getelementptr inbounds double, double* %124, i64 2
store double %143, double* %144
%145 = getelementptr inbounds double, double* %125, i64 9
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %124, i64 6
store double %146, double* %147
%148 = getelementptr inbounds double, double* %125, i64 10
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %124, i64 10
store double %149, double* %150
%151 = getelementptr inbounds double, double* %125, i64 12
%152 = load double, double* %151
%153 = getelementptr inbounds double, double* %124, i64 3
store double %152, double* %153
%154 = getelementptr inbounds double, double* %125, i64 13
%155 = load double, double* %154
%156 = getelementptr inbounds double, double* %124, i64 7
store double %155, double* %156
%157 = getelementptr inbounds double, double* %125, i64 14
%158 = load double, double* %157
%159 = getelementptr inbounds double, double* %124, i64 11
store double %158, double* %159
%160 = getelementptr inbounds double, double* %124, i64 %121
%161 = getelementptr inbounds double, double* %125, i64 16
%162 = add nuw nsw i32 %123, 4
%163 = icmp slt i32 %162, %117
br i1 %163, label %122, label %164
164: ; preds = %122, %113, %6
%165 = phi double* [ %3, %6 ], [ %114, %113 ], [ %161, %122 ]
%166 = phi double* [ %4, %6 ], [ %115, %113 ], [ %160, %122 ]
%167 = phi i32 [ 0, %6 ], [ %116, %113 ], [ %162, %122 ]
%168 = icmp slt i32 %167, %9
br i1 %168, label %169, label %267
169: ; preds = %164
%170 = add i32 %8, %1
%171 = xor i32 %167, -1
%172 = add i32 %170, %171
%173 = zext i32 %172 to i64
%174 = add nuw nsw i64 %173, 1
%175 = icmp ult i32 %172, 2
br i1 %175, label %216, label %176
176: ; preds = %169
%177 = add i32 %8, %1
%178 = xor i32 %167, -1
%179 = add i32 %177, %178
%180 = zext i32 %179 to i64
%181 = add nuw nsw i64 %180, 9
%182 = getelementptr double, double* %166, i64 %181
%183 = shl nuw nsw i64 %180, 2
%184 = or i64 %183, 3
%185 = getelementptr double, double* %165, i64 %184
%186 = icmp ult double* %166, %185
%187 = icmp ult double* %165, %182
%188 = and i1 %186, %187
br i1 %188, label %216, label %189
189: ; preds = %176
%190 = and i64 %174, 1
%191 = icmp eq i64 %190, 0
%192 = select i1 %191, i64 2, i64 %190
%193 = sub nsw i64 %174, %192
%194 = trunc i64 %193 to i32
%195 = add i32 %167, %194
%196 = getelementptr double, double* %166, i64 %193
%197 = shl nsw i64 %193, 2
%198 = getelementptr double, double* %165, i64 %197
br label %199
199: ; preds = %199, %189
%200 = phi i64 [ 0, %189 ], [ %214, %199 ]
%201 = getelementptr double, double* %166, i64 %200
%202 = shl i64 %200, 2
%203 = getelementptr double, double* %165, i64 %202
%204 = bitcast double* %203 to <8 x double>*
%205 = load <8 x double>, <8 x double>* %204
%206 = shufflevector <8 x double> %205, <8 x double> poison, <2 x i32> <i32 0, i32 4>
%207 = shufflevector <8 x double> %205, <8 x double> poison, <2 x i32> <i32 1, i32 5>
%208 = shufflevector <8 x double> %205, <8 x double> poison, <2 x i32> <i32 2, i32 6>
%209 = bitcast double* %201 to <2 x double>*
store <2 x double> %206, <2 x double>* %209
%210 = getelementptr inbounds double, double* %201, i64 4
%211 = bitcast double* %210 to <2 x double>*
store <2 x double> %207, <2 x double>* %211
%212 = getelementptr inbounds double, double* %201, i64 8
%213 = bitcast double* %212 to <2 x double>*
store <2 x double> %208, <2 x double>* %213
%214 = add nuw i64 %200, 2
%215 = icmp eq i64 %214, %193
br i1 %215, label %216, label %199
216: ; preds = %199, %176, %169
%217 = phi i32 [ %167, %176 ], [ %167, %169 ], [ %195, %199 ]
%218 = phi double* [ %166, %176 ], [ %166, %169 ], [ %196, %199 ]
%219 = phi double* [ %165, %176 ], [ %165, %169 ], [ %198, %199 ]
%220 = add i32 %8, %1
%221 = sub i32 %220, %217
%222 = add i32 %217, 1
%223 = and i32 %221, 1
%224 = icmp eq i32 %223, 0
br i1 %224, label %236, label %225
225: ; preds = %216
%226 = load double, double* %219
store double %226, double* %218
%227 = getelementptr inbounds double, double* %219, i64 1
%228 = load double, double* %227
%229 = getelementptr inbounds double, double* %218, i64 4
store double %228, double* %229
%230 = getelementptr inbounds double, double* %219, i64 2
%231 = load double, double* %230
%232 = getelementptr inbounds double, double* %218, i64 8
store double %231, double* %232
%233 = getelementptr inbounds double, double* %218, i64 1
%234 = getelementptr inbounds double, double* %219, i64 4
%235 = add nsw i32 %217, 1
br label %236
236: ; preds = %225, %216
%237 = phi double* [ undef, %216 ], [ %233, %225 ]
%238 = phi double* [ undef, %216 ], [ %234, %225 ]
%239 = phi i32 [ %217, %216 ], [ %235, %225 ]
%240 = phi double* [ %218, %216 ], [ %233, %225 ]
%241 = phi double* [ %219, %216 ], [ %234, %225 ]
%242 = icmp eq i32 %220, %222
br i1 %242, label %267, label %243
243: ; preds = %236, %243
%244 = phi i32 [ %265, %243 ], [ %239, %236 ]
%245 = phi double* [ %263, %243 ], [ %240, %236 ]
%246 = phi double* [ %264, %243 ], [ %241, %236 ]
%247 = load double, double* %246
store double %247, double* %245
%248 = getelementptr inbounds double, double* %246, i64 1
%249 = load double, double* %248
%250 = getelementptr inbounds double, double* %245, i64 4
store double %249, double* %250
%251 = getelementptr inbounds double, double* %246, i64 2
%252 = load double, double* %251
%253 = getelementptr inbounds double, double* %245, i64 8
store double %252, double* %253
%254 = getelementptr inbounds double, double* %245, i64 1
%255 = getelementptr inbounds double, double* %246, i64 4
%256 = load double, double* %255
store double %256, double* %254
%257 = getelementptr inbounds double, double* %246, i64 5
%258 = load double, double* %257
%259 = getelementptr inbounds double, double* %245, i64 5
store double %258, double* %259
%260 = getelementptr inbounds double, double* %246, i64 6
%261 = load double, double* %260
%262 = getelementptr inbounds double, double* %245, i64 9
store double %261, double* %262
%263 = getelementptr inbounds double, double* %245, i64 2
%264 = getelementptr inbounds double, double* %246, i64 8
%265 = add nsw i32 %244, 2
%266 = icmp eq i32 %265, %9
br i1 %266, label %267, label %243
267: ; preds = %236, %243, %164
%268 = phi double* [ %165, %164 ], [ %238, %236 ], [ %264, %243 ]
%269 = phi double* [ %166, %164 ], [ %237, %236 ], [ %263, %243 ]
br i1 %7, label %270, label %287
270: ; preds = %267
%271 = sub i32 %2, %9
%272 = and i32 %271, 3
%273 = icmp eq i32 %272, 1
%274 = getelementptr inbounds double, double* %268, i64 1
%275 = load double, double* %274
%276 = getelementptr inbounds double, double* %269, i64 4
store double %275, double* %276
%277 = getelementptr inbounds double, double* %268, i64 2
%278 = load double, double* %277
%279 = getelementptr inbounds double, double* %269, i64 8
store double %278, double* %279
%280 = getelementptr inbounds double, double* %268, i64 6
%281 = load double, double* %280
%282 = shl i32 %5, 2
%283 = add i32 %282, 5
%284 = select i1 %273, i32 %283, i32 9
%285 = sext i32 %284 to i64
%286 = getelementptr inbounds double, double* %269, i64 %285
store double %281, double* %286
br label %287
287: ; preds = %270, %267
ret void
}