void dmat_init_2x2(double **a11, double **a12, double **a21, double **a22,
                   double alpha, int n) {
  int i;
  int j;
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      a11[i][j] = 0.;
      a12[i][j] = 0.;
      a21[i][j] = 0.;
      a22[i][j] = 0.;
    }
    a11[i][i] = alpha;
    a22[i][i] = alpha;
  }
}


x86 assembly (clang, -O0):
<dmat_init_2x2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11f3 <dmat_init_2x2+0xf3>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11b1 <dmat_init_2x2+0xb1>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1137 <dmat_init_2x2+0x37>
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1124 <dmat_init_2x2+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmat_init_2x2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r8d,%r8d
jle    141e <dmat_init_2x2+0x31e>
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
xorps  %xmm1,%xmm1
mov    %r8d,-0x3c(%rsp)
mov    %rcx,-0x48(%rsp)
mov    %rdx,-0x30(%rsp)
mov    %rsi,-0x38(%rsp)
mov    %rdi,-0x50(%rsp)
jmp    1199 <dmat_init_2x2+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rbx,%r12,8)
movsd  %xmm0,(%rax,%r12,8)
add    $0x1,%r12
cmp    %r13,%r12
je     141e <dmat_init_2x2+0x31e>
mov    (%rdi,%r12,8),%rbx
mov    (%rsi,%r12,8),%r11
mov    (%rdx,%r12,8),%r14
mov    (%rcx,%r12,8),%rax
cmp    $0x4,%r8d
jae    1250 <dmat_init_2x2+0x150>
xor    %r9d,%r9d
mov    %r9,%r10
test   $0x1,%r13b
je     11e6 <dmat_init_2x2+0xe6>
movq   $0x0,(%rbx,%r9,8)
movq   $0x0,(%r11,%r9,8)
movq   $0x0,(%r14,%r9,8)
movq   $0x0,(%rax,%r9,8)
mov    %r9,%r10
or     $0x1,%r10
not    %r9
cmp    -0x8(%rsp),%r9
je     1180 <dmat_init_2x2+0x80>
movq   $0x0,(%rbx,%r10,8)
movq   $0x0,(%r11,%r10,8)
movq   $0x0,(%r14,%r10,8)
movq   $0x0,(%rax,%r10,8)
movq   $0x0,0x8(%rbx,%r10,8)
movq   $0x0,0x8(%r11,%r10,8)
movq   $0x0,0x8(%r14,%r10,8)
movq   $0x0,0x8(%rax,%r10,8)
add    $0x2,%r10
cmp    %r10,%r13
jne    11f0 <dmat_init_2x2+0xf0>
jmp    1180 <dmat_init_2x2+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rbx,%r13,8),%rcx
lea    (%r11,%r13,8),%rdi
lea    (%r14,%r13,8),%r8
lea    (%rax,%r13,8),%rdx
cmp    %rdi,%rbx
setb   -0x51(%rsp)
cmp    %rcx,%r11
setb   %sil
cmp    %r8,%rbx
setb   %r9b
cmp    %rcx,%r14
setb   -0x52(%rsp)
cmp    %rdx,%rbx
setb   %bpl
cmp    %rcx,%rax
setb   -0x53(%rsp)
cmp    %r8,%r11
setb   %r15b
cmp    %rdi,%r14
setb   -0x54(%rsp)
cmp    %rdx,%r11
setb   %cl
cmp    %rdi,%rax
setb   -0x55(%rsp)
cmp    %rdx,%r14
setb   %r10b
cmp    %r8,%rax
setb   %dil
test   %sil,-0x51(%rsp)
jne    13fd <dmat_init_2x2+0x2fd>
and    -0x52(%rsp),%r9b
mov    -0x3c(%rsp),%r8d
mov    -0x30(%rsp),%rdx
mov    -0x38(%rsp),%rsi
jne    13df <dmat_init_2x2+0x2df>
and    -0x53(%rsp),%bpl
jne    13df <dmat_init_2x2+0x2df>
and    -0x54(%rsp),%r15b
jne    13df <dmat_init_2x2+0x2df>
and    -0x55(%rsp),%cl
jne    13df <dmat_init_2x2+0x2df>
mov    $0x0,%r9d
and    %dil,%r10b
mov    -0x48(%rsp),%rcx
mov    -0x50(%rsp),%rdi
jne    11b6 <dmat_init_2x2+0xb6>
cmpq   $0x0,-0x18(%rsp)
je     13f1 <dmat_init_2x2+0x2f1>
mov    -0x28(%rsp),%rbp
xor    %r10d,%r10d
nopw   0x0(%rax,%rax,1)
movups %xmm1,(%rbx,%r10,8)
movups %xmm1,0x10(%rbx,%r10,8)
movups %xmm1,(%r11,%r10,8)
movups %xmm1,0x10(%r11,%r10,8)
movups %xmm1,(%r14,%r10,8)
movups %xmm1,0x10(%r14,%r10,8)
movups %xmm1,(%rax,%r10,8)
movups %xmm1,0x10(%rax,%r10,8)
movups %xmm1,0x20(%rbx,%r10,8)
movups %xmm1,0x30(%rbx,%r10,8)
movups %xmm1,0x20(%r11,%r10,8)
movups %xmm1,0x30(%r11,%r10,8)
movups %xmm1,0x20(%r14,%r10,8)
movups %xmm1,0x30(%r14,%r10,8)
movups %xmm1,0x20(%rax,%r10,8)
movups %xmm1,0x30(%rax,%r10,8)
add    $0x8,%r10
add    $0xfffffffffffffffe,%rbp
jne    1330 <dmat_init_2x2+0x230>
testb  $0x1,-0x20(%rsp)
je     13c9 <dmat_init_2x2+0x2c9>
movups %xmm1,(%rbx,%r10,8)
movups %xmm1,0x10(%rbx,%r10,8)
movups %xmm1,(%r11,%r10,8)
movups %xmm1,0x10(%r11,%r10,8)
movups %xmm1,(%r14,%r10,8)
movups %xmm1,0x10(%r14,%r10,8)
movups %xmm1,(%rax,%r10,8)
movups %xmm1,0x10(%rax,%r10,8)
mov    -0x10(%rsp),%rbp
mov    %rbp,%r9
cmp    %r13,%rbp
je     1180 <dmat_init_2x2+0x80>
jmp    11b6 <dmat_init_2x2+0xb6>
xor    %r9d,%r9d
mov    -0x48(%rsp),%rcx
mov    -0x50(%rsp),%rdi
jmp    11b6 <dmat_init_2x2+0xb6>
xor    %r10d,%r10d
testb  $0x1,-0x20(%rsp)
jne    139d <dmat_init_2x2+0x29d>
jmp    13c9 <dmat_init_2x2+0x2c9>
xor    %r9d,%r9d
mov    -0x3c(%rsp),%r8d
mov    -0x48(%rsp),%rcx
mov    -0x30(%rsp),%rdx
mov    -0x38(%rsp),%rsi
mov    -0x50(%rsp),%rdi
jmp    11b6 <dmat_init_2x2+0xb6>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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