void multiply_array_array(double *out, double *a, double *b, int ncol,
                          int nlns) {
  int i, j;
  double *ptr_a, *ptr_b, *ptr_out;
  for (i = 0; i < ncol; i++) {
    ptr_out = (&(out[(i) * (nlns) + (0)]));
    ptr_a = (&(a[(i) * (nlns) + (0)]));
    ptr_b = (&(b[(i) * (nlns) + (0)]));
    for (j = 0; j < nlns; j++)
      ptr_out[j] = ptr_a[j] * ptr_b[j];
  }
}


x86 assembly (clang, -O0):
<multiply_array_array>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d9 <multiply_array_array+0xd9>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x20(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11c6 <multiply_array_array+0xc6>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1185 <multiply_array_array+0x85>
jmp    11cb <multiply_array_array+0xcb>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111e <multiply_array_array+0x1e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiply_array_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,-0x48(%rsp)
mov    %rsi,-0x50(%rsp)
mov    %rdi,-0x58(%rsp)
test   %ecx,%ecx
jle    1421 <multiply_array_array+0x321>
movslq %r8d,%rax
mov    %ecx,%r9d
mov    %eax,%r15d
mov    %r15d,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,-0x28(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x30(%rsp)
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %rdx,%rcx
mov    %rdx,-0x38(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,-0x40(%rsp)
mov    %r15d,%r10d
and    $0x3,%r10d
mov    -0x50(%rsp),%rsi
lea    0x30(%rsi),%rcx
mov    %rax,-0x20(%rsp)
lea    0x0(,%rax,8),%r13
mov    -0x48(%rsp),%rdx
lea    0x30(%rdx),%rbp
mov    -0x58(%rsp),%rdi
lea    0x30(%rdi),%r14
xor    %r11d,%r11d
mov    %r9,-0x60(%rsp)
mov    %r10,-0x68(%rsp)
mov    %r8d,-0x74(%rsp)
mov    %r13,-0x70(%rsp)
jmp    11cf <multiply_array_array+0xcf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r11
add    %r13,%rcx
add    %r13,%rbp
add    %r13,%r14
add    %r13,%rdi
add    %r13,%rdx
add    %r13,%rsi
cmp    %r9,%r11
je     1421 <multiply_array_array+0x321>
test   %r8d,%r8d
jle    11b0 <multiply_array_array+0xb0>
cmp    $0x4,%r8d
jae    11f0 <multiply_array_array+0xf0>
xor    %r12d,%r12d
jmp    1360 <multiply_array_array+0x260>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r11,%rax
imul   -0x20(%rsp),%rax
lea    (%rax,%r15,1),%rbx
mov    -0x58(%rsp),%r8
lea    (%r8,%rax,8),%r9
lea    (%r8,%rbx,8),%r12
mov    -0x50(%rsp),%r8
lea    (%r8,%rax,8),%r13
lea    (%r8,%rbx,8),%r8
mov    -0x48(%rsp),%r10
lea    (%r10,%rax,8),%rax
lea    (%r10,%rbx,8),%rbx
cmp    %r8,%r9
setb   %r8b
mov    %r13,-0x18(%rsp)
cmp    %r12,%r13
setb   %r10b
mov    %r9,-0x8(%rsp)
cmp    %rbx,%r9
setb   %bl
mov    %rax,-0x10(%rsp)
cmp    %r12,%rax
setb   %al
test   %r10b,%r8b
jne    1346 <multiply_array_array+0x246>
mov    $0x0,%r12d
and    %al,%bl
mov    -0x74(%rsp),%r8d
mov    -0x60(%rsp),%r9
mov    -0x68(%rsp),%r10
mov    -0x70(%rsp),%r13
jne    1360 <multiply_array_array+0x260>
cmpq   $0x0,-0x30(%rsp)
je     140f <multiply_array_array+0x30f>
mov    -0x40(%rsp),%rax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movupd -0x30(%rcx,%rbx,8),%xmm0
movupd -0x20(%rcx,%rbx,8),%xmm1
movupd -0x30(%rbp,%rbx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd -0x20(%rbp,%rbx,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,-0x30(%r14,%rbx,8)
movupd %xmm0,-0x20(%r14,%rbx,8)
movupd -0x10(%rcx,%rbx,8),%xmm0
movupd (%rcx,%rbx,8),%xmm1
movupd -0x10(%rbp,%rbx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x0(%rbp,%rbx,8),%xmm0
mulpd  %xmm1,%xmm0
movupd %xmm2,-0x10(%r14,%rbx,8)
movupd %xmm0,(%r14,%rbx,8)
add    $0x8,%rbx
add    $0xfffffffffffffffe,%rax
jne    1290 <multiply_array_array+0x190>
testb  $0x1,-0x38(%rsp)
je     1333 <multiply_array_array+0x233>
mov    -0x18(%rsp),%rax
movupd (%rax,%rbx,8),%xmm0
movupd 0x10(%rax,%rbx,8),%xmm1
mov    -0x10(%rsp),%rax
movupd (%rax,%rbx,8),%xmm2
mulpd  %xmm0,%xmm2
movupd 0x10(%rax,%rbx,8),%xmm0
mulpd  %xmm1,%xmm0
mov    -0x8(%rsp),%rax
movupd %xmm2,(%rax,%rbx,8)
movupd %xmm0,0x10(%rax,%rbx,8)
mov    -0x28(%rsp),%rax
mov    %rax,%r12
cmp    %r15,%rax
je     11b0 <multiply_array_array+0xb0>
jmp    1360 <multiply_array_array+0x260>
xor    %r12d,%r12d
mov    -0x74(%rsp),%r8d
mov    -0x60(%rsp),%r9
mov    -0x68(%rsp),%r10
mov    -0x70(%rsp),%r13
nopl   (%rax)
mov    %r12,%rax
not    %rax
add    %r15,%rax
test   %r10,%r10
je     139c <multiply_array_array+0x29c>
mov    %r10,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi,%r12,8),%xmm0
mulsd  (%rdx,%r12,8),%xmm0
movsd  %xmm0,(%rdi,%r12,8)
add    $0x1,%r12
add    $0xffffffffffffffff,%rbx
jne    1380 <multiply_array_array+0x280>
cmp    $0x3,%rax
jb     11b0 <multiply_array_array+0xb0>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rsi,%r12,8),%xmm0
mulsd  (%rdx,%r12,8),%xmm0
movsd  %xmm0,(%rdi,%r12,8)
movsd  0x8(%rsi,%r12,8),%xmm0
mulsd  0x8(%rdx,%r12,8),%xmm0
movsd  %xmm0,0x8(%rdi,%r12,8)
movsd  0x10(%rsi,%r12,8),%xmm0
mulsd  0x10(%rdx,%r12,8),%xmm0
movsd  %xmm0,0x10(%rdi,%r12,8)
movsd  0x18(%rsi,%r12,8),%xmm0
mulsd  0x18(%rdx,%r12,8),%xmm0
movsd  %xmm0,0x18(%rdi,%r12,8)
add    $0x4,%r12
cmp    %r12,%r15
jne    13b0 <multiply_array_array+0x2b0>
jmp    11b0 <multiply_array_array+0xb0>
xor    %ebx,%ebx
testb  $0x1,-0x38(%rsp)
jne    12fb <multiply_array_array+0x1fb>
jmp    1333 <multiply_array_array+0x233>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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