void test_system(int n, double **A, double *b) {
  int i, j;
  for (i = 0; i < n; i++) {
    b[i] = 2.0 * n;
    for (j = 0; j < n; j++)
      A[i][j] = 1.0;
    A[i][i] = n + 1.0;
  }
}


x86 assembly (clang, -O0):
<test_system>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b2 <test_system+0xb2>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xed1(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117e <test_system+0x7e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1147 <test_system+0x47>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <test_system+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_system>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    1272 <test_system+0x172>
cvtsi2sd %edi,%xmm0
movapd %xmm0,%xmm1
addsd  0xedf(%rip),%xmm0
addsd  %xmm1,%xmm1
mov    %edi,%r13d
mov    %r13d,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%r8
mov    %r8,%r9
shr    $0x2,%r9
add    $0x1,%r9
mov    %r9d,%r10d
and    $0x7,%r10d
and    $0xfffffffffffffff8,%r9
mov    %r10,%r15
shl    $0x5,%r15
xor    %r14d,%r14d
movabs $0x3ff0000000000000,%r12
movaps 0xeac(%rip),%xmm2
jmp    1183 <test_system+0x83>
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,(%rcx,%r14,8)
add    $0x1,%r14
cmp    %r13,%r14
je     1272 <test_system+0x172>
movsd  %xmm1,(%rdx,%r14,8)
mov    (%rsi,%r14,8),%rcx
cmp    $0x4,%edi
jae    11a0 <test_system+0xa0>
xor    %eax,%eax
jmp    1260 <test_system+0x160>
nopl   0x0(%rax)
cmp    $0x1c,%r8
jae    11b0 <test_system+0xb0>
xor    %ebx,%ebx
jmp    1231 <test_system+0x131>
nopl   (%rax)
mov    %r9,%rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movups %xmm2,(%rcx,%rbx,8)
movups %xmm2,0x10(%rcx,%rbx,8)
movups %xmm2,0x20(%rcx,%rbx,8)
movups %xmm2,0x30(%rcx,%rbx,8)
movups %xmm2,0x40(%rcx,%rbx,8)
movups %xmm2,0x50(%rcx,%rbx,8)
movups %xmm2,0x60(%rcx,%rbx,8)
movups %xmm2,0x70(%rcx,%rbx,8)
movups %xmm2,0x80(%rcx,%rbx,8)
movups %xmm2,0x90(%rcx,%rbx,8)
movups %xmm2,0xa0(%rcx,%rbx,8)
movups %xmm2,0xb0(%rcx,%rbx,8)
movups %xmm2,0xc0(%rcx,%rbx,8)
movups %xmm2,0xd0(%rcx,%rbx,8)
movups %xmm2,0xe0(%rcx,%rbx,8)
movups %xmm2,0xf0(%rcx,%rbx,8)
add    $0x20,%rbx
add    $0xfffffffffffffff8,%rax
jne    11c0 <test_system+0xc0>
test   %r10,%r10
je     1252 <test_system+0x152>
lea    (%rcx,%rbx,8),%rax
add    $0x10,%rax
xor    %ebx,%ebx
movups %xmm2,-0x10(%rax,%rbx,1)
movups %xmm2,(%rax,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%r15
jne    1240 <test_system+0x140>
mov    %r11,%rax
cmp    %r13,%r11
je     1170 <test_system+0x70>
xchg   %ax,%ax
mov    %r12,(%rcx,%rax,8)
add    $0x1,%rax
cmp    %rax,%r13
jne    1260 <test_system+0x160>
jmp    1170 <test_system+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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