void dmat_copy_1x2(double **b11, double **b12, double **a11, double **a12,
                   int n) {
  int i;
  int j;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      b11[i][j] = a11[i][j];
      b12[i][j] = a12[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<dmat_copy_1x2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b3 <dmat_copy_1x2+0xb3>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11a0 <dmat_copy_1x2+0xa0>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1132 <dmat_copy_1x2+0x32>
jmp    11a5 <dmat_copy_1x2+0xa5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    111f <dmat_copy_1x2+0x1f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmat_copy_1x2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r8d,%r8d
jle    13c6 <dmat_copy_1x2+0x2c6>
mov    %r8d,%r13d
mov    %r13d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x10(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x18(%rsp)
mov    %rax,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
mov    %rbp,%rax
mov    %rbp,-0x20(%rsp)
and    $0xfffffffffffffffe,%rbp
mov    %rbp,-0x28(%rsp)
mov    %r13,%rax
neg    %rax
mov    %rax,-0x8(%rsp)
xor    %r12d,%r12d
mov    %r8d,-0x4c(%rsp)
mov    %rcx,-0x30(%rsp)
mov    %rdx,-0x38(%rsp)
mov    %rsi,-0x40(%rsp)
mov    %rdi,-0x48(%rsp)
jmp    117d <dmat_copy_1x2+0x7d>
nop
add    $0x1,%r12
cmp    %r13,%r12
je     13c6 <dmat_copy_1x2+0x2c6>
mov    (%rdx,%r12,8),%r11
mov    (%rdi,%r12,8),%rax
mov    (%rcx,%r12,8),%rbp
mov    (%rsi,%r12,8),%r14
cmp    $0x4,%r8d
jae    11a0 <dmat_copy_1x2+0xa0>
xor    %r9d,%r9d
jmp    1330 <dmat_copy_1x2+0x230>
nopl   0x0(%rax,%rax,1)
lea    (%rax,%r13,8),%rcx
lea    (%r14,%r13,8),%rdi
lea    (%r11,%r13,8),%rsi
lea    0x0(,%r13,8),%rdx
add    %rbp,%rdx
cmp    %rdi,%rax
setb   -0x4d(%rsp)
cmp    %rcx,%r14
setb   %r8b
cmp    %rsi,%rax
setb   %bl
cmp    %rcx,%r11
setb   -0x4e(%rsp)
cmp    %rdx,%rax
setb   %r9b
cmp    %rcx,%rbp
setb   %cl
cmp    %rsi,%r14
setb   %r15b
cmp    %rdi,%r11
setb   %sil
cmp    %rdx,%r14
setb   %r10b
cmp    %rdi,%rbp
setb   %dil
test   %r8b,-0x4d(%rsp)
jne    130e <dmat_copy_1x2+0x20e>
and    -0x4e(%rsp),%bl
jne    130e <dmat_copy_1x2+0x20e>
and    %cl,%r9b
jne    130e <dmat_copy_1x2+0x20e>
and    %sil,%r15b
jne    130e <dmat_copy_1x2+0x20e>
mov    $0x0,%r9d
and    %dil,%r10b
mov    -0x4c(%rsp),%r8d
mov    -0x30(%rsp),%rcx
mov    -0x38(%rsp),%rdx
mov    -0x40(%rsp),%rsi
mov    -0x48(%rsp),%rdi
jne    1330 <dmat_copy_1x2+0x230>
cmpq   $0x0,-0x18(%rsp)
je     13b3 <dmat_copy_1x2+0x2b3>
mov    -0x28(%rsp),%rbx
xor    %r10d,%r10d
movups (%r11,%r10,8),%xmm0
movups 0x10(%r11,%r10,8),%xmm1
movups %xmm0,(%rax,%r10,8)
movups %xmm1,0x10(%rax,%r10,8)
movups 0x0(%rbp,%r10,8),%xmm0
movups 0x10(%rbp,%r10,8),%xmm1
movups %xmm0,(%r14,%r10,8)
movups %xmm1,0x10(%r14,%r10,8)
movups 0x20(%r11,%r10,8),%xmm0
movups 0x30(%r11,%r10,8),%xmm1
movups %xmm0,0x20(%rax,%r10,8)
movups %xmm1,0x30(%rax,%r10,8)
movups 0x20(%rbp,%r10,8),%xmm0
movups 0x30(%rbp,%r10,8),%xmm1
movups %xmm0,0x20(%r14,%r10,8)
movups %xmm1,0x30(%r14,%r10,8)
add    $0x8,%r10
add    $0xfffffffffffffffe,%rbx
jne    1260 <dmat_copy_1x2+0x160>
testb  $0x1,-0x20(%rsp)
je     12fb <dmat_copy_1x2+0x1fb>
movups (%r11,%r10,8),%xmm0
movups 0x10(%r11,%r10,8),%xmm1
movups %xmm0,(%rax,%r10,8)
movups %xmm1,0x10(%rax,%r10,8)
movups 0x0(%rbp,%r10,8),%xmm0
movups 0x10(%rbp,%r10,8),%xmm1
movups %xmm0,(%r14,%r10,8)
movups %xmm1,0x10(%r14,%r10,8)
mov    -0x10(%rsp),%rbx
mov    %rbx,%r9
cmp    %r13,%rbx
je     1170 <dmat_copy_1x2+0x70>
jmp    1330 <dmat_copy_1x2+0x230>
xor    %r9d,%r9d
mov    -0x4c(%rsp),%r8d
mov    -0x30(%rsp),%rcx
mov    -0x38(%rsp),%rdx
mov    -0x40(%rsp),%rsi
mov    -0x48(%rsp),%rdi
nopw   0x0(%rax,%rax,1)
mov    %r9,%r10
test   $0x1,%r13b
je     1359 <dmat_copy_1x2+0x259>
movsd  (%r11,%r9,8),%xmm0
movsd  %xmm0,(%rax,%r9,8)
movsd  0x0(%rbp,%r9,8),%xmm0
movsd  %xmm0,(%r14,%r9,8)
mov    %r9,%r10
or     $0x1,%r10
not    %r9
cmp    -0x8(%rsp),%r9
je     1170 <dmat_copy_1x2+0x70>
nopw   0x0(%rax,%rax,1)
movsd  (%r11,%r10,8),%xmm0
movsd  %xmm0,(%rax,%r10,8)
movsd  0x0(%rbp,%r10,8),%xmm0
movsd  %xmm0,(%r14,%r10,8)
movsd  0x8(%r11,%r10,8),%xmm0
movsd  %xmm0,0x8(%rax,%r10,8)
movsd  0x8(%rbp,%r10,8),%xmm0
movsd  %xmm0,0x8(%r14,%r10,8)
add    $0x2,%r10
cmp    %r10,%r13
jne    1370 <dmat_copy_1x2+0x270>
jmp    1170 <dmat_copy_1x2+0x70>
xor    %r10d,%r10d
testb  $0x1,-0x20(%rsp)
jne    12ce <dmat_copy_1x2+0x1ce>
jmp    12fb <dmat_copy_1x2+0x1fb>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @dmat_copy_1x2(double** nocapture %0, double** nocapture %1, double** nocapture %2, double** nocapture %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %163
7: ; preds = %5
%8 = zext i32 %4 to i64
%9 = and i64 %8, 4294967292
%10 = add nsw i64 %9, -4
%11 = lshr exact i64 %10, 2
%12 = add nuw nsw i64 %11, 1
%13 = icmp ult i32 %4, 4
%14 = and i64 %8, 4294967292
%15 = and i64 %12, 1
%16 = icmp eq i64 %10, 0
%17 = and i64 %12, 9223372036854775806
%18 = icmp eq i64 %15, 0
%19 = icmp eq i64 %14, %8
%20 = and i64 %8, 1
%21 = icmp eq i64 %20, 0
%22 = sub nsw i64 0, %8
br label %23
23: ; preds = %160, %7
%24 = phi i64 [ 0, %7 ], [ %161, %160 ]
%25 = getelementptr inbounds double*, double** %2, i64 %24
%26 = load double*, double** %25
%27 = getelementptr inbounds double*, double** %0, i64 %24
%28 = load double*, double** %27
%29 = getelementptr inbounds double*, double** %3, i64 %24
%30 = load double*, double** %29
%31 = getelementptr inbounds double*, double** %1, i64 %24
%32 = load double*, double** %31
br i1 %13, label %129, label %33
33: ; preds = %23
%34 = getelementptr double, double* %28, i64 %8
%35 = getelementptr double, double* %32, i64 %8
%36 = getelementptr double, double* %26, i64 %8
%37 = getelementptr double, double* %30, i64 %8
%38 = icmp ult double* %28, %35
%39 = icmp ult double* %32, %34
%40 = and i1 %38, %39
%41 = icmp ult double* %28, %36
%42 = icmp ult double* %26, %34
%43 = and i1 %41, %42
%44 = or i1 %40, %43
%45 = icmp ult double* %28, %37
%46 = icmp ult double* %30, %34
%47 = and i1 %45, %46
%48 = or i1 %44, %47
%49 = icmp ult double* %32, %36
%50 = icmp ult double* %26, %35
%51 = and i1 %49, %50
%52 = or i1 %48, %51
%53 = icmp ult double* %32, %37
%54 = icmp ult double* %30, %35
%55 = and i1 %53, %54
%56 = or i1 %52, %55
br i1 %56, label %129, label %57
57: ; preds = %33
br i1 %16, label %105, label %58
58: ; preds = %57, %58
%59 = phi i64 [ %102, %58 ], [ 0, %57 ]
%60 = phi i64 [ %103, %58 ], [ 0, %57 ]
%61 = getelementptr inbounds double, double* %26, i64 %59
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = getelementptr inbounds double, double* %61, i64 2
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = getelementptr inbounds double, double* %28, i64 %59
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %63, <2 x double>* %68
%69 = getelementptr inbounds double, double* %67, i64 2
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %66, <2 x double>* %70
%71 = getelementptr inbounds double, double* %30, i64 %59
%72 = bitcast double* %71 to <2 x double>*
%73 = load <2 x double>, <2 x double>* %72
%74 = getelementptr inbounds double, double* %71, i64 2
%75 = bitcast double* %74 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = getelementptr inbounds double, double* %32, i64 %59
%78 = bitcast double* %77 to <2 x double>*
store <2 x double> %73, <2 x double>* %78
%79 = getelementptr inbounds double, double* %77, i64 2
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %76, <2 x double>* %80
%81 = or i64 %59, 4
%82 = getelementptr inbounds double, double* %26, i64 %81
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %82, i64 2
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = getelementptr inbounds double, double* %28, i64 %81
%89 = bitcast double* %88 to <2 x double>*
store <2 x double> %84, <2 x double>* %89
%90 = getelementptr inbounds double, double* %88, i64 2
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> %87, <2 x double>* %91
%92 = getelementptr inbounds double, double* %30, i64 %81
%93 = bitcast double* %92 to <2 x double>*
%94 = load <2 x double>, <2 x double>* %93
%95 = getelementptr inbounds double, double* %92, i64 2
%96 = bitcast double* %95 to <2 x double>*
%97 = load <2 x double>, <2 x double>* %96
%98 = getelementptr inbounds double, double* %32, i64 %81
%99 = bitcast double* %98 to <2 x double>*
store <2 x double> %94, <2 x double>* %99
%100 = getelementptr inbounds double, double* %98, i64 2
%101 = bitcast double* %100 to <2 x double>*
store <2 x double> %97, <2 x double>* %101
%102 = add nuw i64 %59, 8
%103 = add i64 %60, 2
%104 = icmp eq i64 %103, %17
br i1 %104, label %105, label %58
105: ; preds = %58, %57
%106 = phi i64 [ 0, %57 ], [ %102, %58 ]
br i1 %18, label %128, label %107
107: ; preds = %105
%108 = getelementptr inbounds double, double* %26, i64 %106
%109 = bitcast double* %108 to <2 x double>*
%110 = load <2 x double>, <2 x double>* %109
%111 = getelementptr inbounds double, double* %108, i64 2
%112 = bitcast double* %111 to <2 x double>*
%113 = load <2 x double>, <2 x double>* %112
%114 = getelementptr inbounds double, double* %28, i64 %106
%115 = bitcast double* %114 to <2 x double>*
store <2 x double> %110, <2 x double>* %115
%116 = getelementptr inbounds double, double* %114, i64 2
%117 = bitcast double* %116 to <2 x double>*
store <2 x double> %113, <2 x double>* %117
%118 = getelementptr inbounds double, double* %30, i64 %106
%119 = bitcast double* %118 to <2 x double>*
%120 = load <2 x double>, <2 x double>* %119
%121 = getelementptr inbounds double, double* %118, i64 2
%122 = bitcast double* %121 to <2 x double>*
%123 = load <2 x double>, <2 x double>* %122
%124 = getelementptr inbounds double, double* %32, i64 %106
%125 = bitcast double* %124 to <2 x double>*
store <2 x double> %120, <2 x double>* %125
%126 = getelementptr inbounds double, double* %124, i64 2
%127 = bitcast double* %126 to <2 x double>*
store <2 x double> %123, <2 x double>* %127
br label %128
128: ; preds = %105, %107
br i1 %19, label %160, label %129
129: ; preds = %33, %23, %128
%130 = phi i64 [ 0, %33 ], [ 0, %23 ], [ %14, %128 ]
%131 = xor i64 %130, -1
br i1 %21, label %140, label %132
132: ; preds = %129
%133 = getelementptr inbounds double, double* %26, i64 %130
%134 = load double, double* %133
%135 = getelementptr inbounds double, double* %28, i64 %130
store double %134, double* %135
%136 = getelementptr inbounds double, double* %30, i64 %130
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %32, i64 %130
store double %137, double* %138
%139 = or i64 %130, 1
br label %140
140: ; preds = %132, %129
%141 = phi i64 [ %130, %129 ], [ %139, %132 ]
%142 = icmp eq i64 %131, %22
br i1 %142, label %160, label %143
143: ; preds = %140, %143
%144 = phi i64 [ %158, %143 ], [ %141, %140 ]
%145 = getelementptr inbounds double, double* %26, i64 %144
%146 = load double, double* %145
%147 = getelementptr inbounds double, double* %28, i64 %144
store double %146, double* %147
%148 = getelementptr inbounds double, double* %30, i64 %144
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %32, i64 %144
store double %149, double* %150
%151 = add nuw nsw i64 %144, 1
%152 = getelementptr inbounds double, double* %26, i64 %151
%153 = load double, double* %152
%154 = getelementptr inbounds double, double* %28, i64 %151
store double %153, double* %154
%155 = getelementptr inbounds double, double* %30, i64 %151
%156 = load double, double* %155
%157 = getelementptr inbounds double, double* %32, i64 %151
store double %156, double* %157
%158 = add nuw nsw i64 %144, 2
%159 = icmp eq i64 %158, %8
br i1 %159, label %160, label %143
160: ; preds = %140, %143, %128
%161 = add nuw nsw i64 %24, 1
%162 = icmp eq i64 %161, %8
br i1 %162, label %163, label %23
163: ; preds = %160, %5
ret void
}