void m_set1(double *m, int rows, int cols) {
  int i;
  for (i = rows * cols; i > 0; i--)
    *m++ = 1;
}


x86 assembly (clang, -O0):
<m_set1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    114b <m_set1+0x4b>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
movsd  0xec7(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1118 <m_set1+0x18>
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_set1>:
imul   %edx,%esi
test   %esi,%esi
jle    122f <m_set1+0x12f>
lea    -0x1(%rsi),%r9d
cmp    $0x3,%r9d
jb     120e <m_set1+0x10e>
add    $0x1,%r9
mov    %r9,%r8
and    $0xfffffffffffffffc,%r8
lea    -0x4(%r8),%rax
mov    %rax,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%ecx
and    $0x7,%ecx
cmp    $0x1c,%rax
jae    1145 <m_set1+0x45>
xor    %eax,%eax
jmp    11d1 <m_set1+0xd1>
and    $0xfffffffffffffff8,%rdx
xor    %eax,%eax
movaps 0xeae(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups %xmm0,(%rdi,%rax,8)
movups %xmm0,0x10(%rdi,%rax,8)
movups %xmm0,0x20(%rdi,%rax,8)
movups %xmm0,0x30(%rdi,%rax,8)
movups %xmm0,0x40(%rdi,%rax,8)
movups %xmm0,0x50(%rdi,%rax,8)
movups %xmm0,0x60(%rdi,%rax,8)
movups %xmm0,0x70(%rdi,%rax,8)
movups %xmm0,0x80(%rdi,%rax,8)
movups %xmm0,0x90(%rdi,%rax,8)
movups %xmm0,0xa0(%rdi,%rax,8)
movups %xmm0,0xb0(%rdi,%rax,8)
movups %xmm0,0xc0(%rdi,%rax,8)
movups %xmm0,0xd0(%rdi,%rax,8)
movups %xmm0,0xe0(%rdi,%rax,8)
movups %xmm0,0xf0(%rdi,%rax,8)
add    $0x20,%rax
add    $0xfffffffffffffff8,%rdx
jne    1160 <m_set1+0x60>
test   %rcx,%rcx
je     1202 <m_set1+0x102>
lea    (%rdi,%rax,8),%rax
add    $0x10,%rax
shl    $0x5,%rcx
xor    %edx,%edx
movaps 0xe15(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movups %xmm0,-0x10(%rax,%rdx,1)
movups %xmm0,(%rax,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rcx
jne    11f0 <m_set1+0xf0>
cmp    %r8,%r9
je     122f <m_set1+0x12f>
sub    %r8d,%esi
lea    (%rdi,%r8,8),%rdi
add    $0x1,%esi
movabs $0x3ff0000000000000,%rax
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rdi)
add    $0x8,%rdi
add    $0xffffffff,%esi
cmp    $0x1,%esi
ja     1220 <m_set1+0x120>
ret

LLVM IR (-O0):
define void @m_set1(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = mul nsw i32 %8, %9
store i32 %10, i32* %7
br label %11
11: ; preds = %17, %3
%12 = load i32, i32* %7
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i32 1
store double* %16, double** %4
store double 1.000000e+00, double* %15
br label %17
17: ; preds = %14
%18 = load i32, i32* %7
%19 = add nsw i32 %18, -1
store i32 %19, i32* %7
br label %11
20: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @m_set1(double* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = mul i32 %2, %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %92
6: ; preds = %3
%7 = add i32 %4, -1
%8 = zext i32 %7 to i64
%9 = add nuw nsw i64 %8, 1
%10 = icmp ult i32 %7, 3
br i1 %10, label %83, label %11
11: ; preds = %6
%12 = and i64 %9, 8589934588
%13 = trunc i64 %12 to i32
%14 = sub i32 %4, %13
%15 = getelementptr double, double* %0, i64 %12
%16 = add nsw i64 %12, -4
%17 = lshr exact i64 %16, 2
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 7
%20 = icmp ult i64 %16, 28
br i1 %20, label %68, label %21
21: ; preds = %11
%22 = and i64 %18, 9223372036854775800
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %65, %23 ]
%25 = phi i64 [ 0, %21 ], [ %66, %23 ]
%26 = getelementptr double, double* %0, i64 %24
%27 = bitcast double* %26 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %27
%28 = getelementptr double, double* %26, i64 2
%29 = bitcast double* %28 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %29
%30 = or i64 %24, 4
%31 = getelementptr double, double* %0, i64 %30
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %32
%33 = getelementptr double, double* %31, i64 2
%34 = bitcast double* %33 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %34
%35 = or i64 %24, 8
%36 = getelementptr double, double* %0, i64 %35
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %37
%38 = getelementptr double, double* %36, i64 2
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %39
%40 = or i64 %24, 12
%41 = getelementptr double, double* %0, i64 %40
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %42
%43 = getelementptr double, double* %41, i64 2
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %44
%45 = or i64 %24, 16
%46 = getelementptr double, double* %0, i64 %45
%47 = bitcast double* %46 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %47
%48 = getelementptr double, double* %46, i64 2
%49 = bitcast double* %48 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %49
%50 = or i64 %24, 20
%51 = getelementptr double, double* %0, i64 %50
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %52
%53 = getelementptr double, double* %51, i64 2
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %54
%55 = or i64 %24, 24
%56 = getelementptr double, double* %0, i64 %55
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %57
%58 = getelementptr double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %59
%60 = or i64 %24, 28
%61 = getelementptr double, double* %0, i64 %60
%62 = bitcast double* %61 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %62
%63 = getelementptr double, double* %61, i64 2
%64 = bitcast double* %63 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %64
%65 = add nuw i64 %24, 32
%66 = add i64 %25, 8
%67 = icmp eq i64 %66, %22
br i1 %67, label %68, label %23
68: ; preds = %23, %11
%69 = phi i64 [ 0, %11 ], [ %65, %23 ]
%70 = icmp eq i64 %19, 0
br i1 %70, label %81, label %71
71: ; preds = %68, %71
%72 = phi i64 [ %78, %71 ], [ %69, %68 ]
%73 = phi i64 [ %79, %71 ], [ 0, %68 ]
%74 = getelementptr double, double* %0, i64 %72
%75 = bitcast double* %74 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %75
%76 = getelementptr double, double* %74, i64 2
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %77
%78 = add nuw i64 %72, 4
%79 = add i64 %73, 1
%80 = icmp eq i64 %79, %19
br i1 %80, label %81, label %71
81: ; preds = %71, %68
%82 = icmp eq i64 %9, %12
br i1 %82, label %92, label %83
83: ; preds = %6, %81
%84 = phi i32 [ %4, %6 ], [ %14, %81 ]
%85 = phi double* [ %0, %6 ], [ %15, %81 ]
br label %86
86: ; preds = %83, %86
%87 = phi i32 [ %90, %86 ], [ %84, %83 ]
%88 = phi double* [ %89, %86 ], [ %85, %83 ]
%89 = getelementptr inbounds double, double* %88, i64 1
store double 1.000000e+00, double* %88
%90 = add nsw i32 %87, -1
%91 = icmp ugt i32 %87, 1
br i1 %91, label %86, label %92
92: ; preds = %86, %81, %3
ret void
}