void sGenXtrue(int n, int nrhs, double *x, int ldx) {
  int i, j;
  for (j = 0; j < nrhs; ++j)
    for (i = 0; i < n; ++i) {
      x[i + j * ldx] = 1.0;
    }
}


x86 assembly (clang, -O0):
<sGenXtrue>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1178 <sGenXtrue+0x78>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1165 <sGenXtrue+0x65>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112b <sGenXtrue+0x2b>
jmp    116a <sGenXtrue+0x6a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1118 <sGenXtrue+0x18>
pop    %rbp
ret

x86 assembly (clang, -O2):
<sGenXtrue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
jle    1232 <sGenXtrue+0x132>
movslq %ecx,%r15
mov    %esi,%r14d
mov    %edi,%esi
mov    %esi,%r8d
and    $0xfffffffc,%r8d
lea    -0x4(%r8),%rax
mov    %rax,-0x8(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r11d
and    $0x3,%r11d
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rsp)
lea    0x70(%rdx),%rbx
shl    $0x3,%r15
lea    0x10(%rdx),%r12
mov    %r11,%r13
shl    $0x5,%r13
xor    %r9d,%r9d
movabs $0x3ff0000000000000,%rax
movaps 0xe97(%rip),%xmm0
jmp    1186 <sGenXtrue+0x86>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r9
add    %r15,%rbx
add    %r15,%r12
add    %r15,%rdx
cmp    %r14,%r9
je     1232 <sGenXtrue+0x132>
test   %edi,%edi
jle    1170 <sGenXtrue+0x70>
cmp    $0x4,%edi
jae    11a0 <sGenXtrue+0xa0>
xor    %ebp,%ebp
jmp    1220 <sGenXtrue+0x120>
cs nopw 0x0(%rax,%rax,1)
cmpq   $0xc,-0x8(%rsp)
jae    11ac <sGenXtrue+0xac>
xor    %ebp,%ebp
jmp    11f1 <sGenXtrue+0xf1>
mov    -0x10(%rsp),%r10
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups %xmm0,-0x70(%rbx,%rbp,8)
movups %xmm0,-0x60(%rbx,%rbp,8)
movups %xmm0,-0x50(%rbx,%rbp,8)
movups %xmm0,-0x40(%rbx,%rbp,8)
movups %xmm0,-0x30(%rbx,%rbp,8)
movups %xmm0,-0x20(%rbx,%rbp,8)
movups %xmm0,-0x10(%rbx,%rbp,8)
movups %xmm0,(%rbx,%rbp,8)
add    $0x10,%rbp
add    $0xfffffffffffffffc,%r10
jne    11c0 <sGenXtrue+0xc0>
test   %r11,%r11
je     1213 <sGenXtrue+0x113>
lea    (%r12,%rbp,8),%rbp
xor    %ecx,%ecx
nopl   0x0(%rax)
movups %xmm0,-0x10(%rbp,%rcx,1)
movups %xmm0,0x0(%rbp,%rcx,1)
add    $0x20,%rcx
cmp    %rcx,%r13
jne    1200 <sGenXtrue+0x100>
mov    %r8,%rbp
cmp    %rsi,%r8
je     1170 <sGenXtrue+0x70>
nop
mov    %rax,(%rdx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rsi
jne    1220 <sGenXtrue+0x120>
jmp    1170 <sGenXtrue+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sGenXtrue(i32 %0, i32 %1, double* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %10
br label %11
11: ; preds = %33, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %36
15: ; preds = %11
store i32 0, i32* %9
br label %16
16: ; preds = %29, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load double*, double** %7
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = load i32, i32* %8
%25 = mul nsw i32 %23, %24
%26 = add nsw i32 %22, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %21, i64 %27
store double 1.000000e+00, double* %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %16
32: ; preds = %16
br label %33
33: ; preds = %32
%34 = load i32, i32* %10
%35 = add nsw i32 %34, 1
store i32 %35, i32* %10
br label %11
36: ; preds = %11
ret void
}

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