#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double fabs(int);
int /*<<< orphan*/ print_matrix(int, double **, double *);
int /*<<< orphan*/ printf(char *);
void solve_matrix(int n, double **a_s, double *b_s) {
  int DEBUG = 0;
  int i;
  if (DEBUG)
    print_matrix(n, a_s, b_s);
  for (i = 0; i < n - 1; i++) {
    int max = i;
    int i2;
    for (i2 = i + 1; i2 < n; i2++) {
      if (fabs(a_s[i2][i] > fabs(a_s[max][i])))
        max = i2;
    }
    {
      double *t, tt;
      t = a_s[i];
      a_s[i] = a_s[max];
      a_s[max] = t;
      tt = b_s[i];
      b_s[i] = b_s[max];
      b_s[max] = tt;
    }
    for (i2 = i + 1; i2 < n; i2++) {
      int j;
      double r = a_s[i2][i] / a_s[i][i];
      if (r == 0)
        continue;
      for (j = i; j < n; j++) {
        a_s[i2][j] -= a_s[i][j] * r;
      }
      b_s[i2] -= b_s[i] * r;
    }
  }
  if (DEBUG)
    print_matrix(n, a_s, b_s);
  for (i = n - 1; i >= 0; i--) {
    int j;
    double sum = 0;
    for (j = i + 1; j < n; j++) {
      sum += b_s[j] * a_s[i][j];
      a_s[i][j] = 0;
    }
    if (a_s[i][i] == 0) {
      if (b_s[i] == 0) {
        printf("Equations are underconstrained.\n");
        break;
      } else {
        printf("Equations are inconsistent.\n");
        break;
      }
    }
    b_s[i] = (b_s[i] - sum) / a_s[i][i];
    a_s[i][i] = 1;
  }
  if (DEBUG)
    print_matrix(n, a_s, b_s);
}


x86 assembly (clang, -O0):
<solve_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1164 <solve_matrix+0x34>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <print_matrix@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13c3 <solve_matrix+0x293>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1215 <solve_matrix+0xe5>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%edi
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <fabs@plt>
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11fc <solve_matrix+0xcc>
jp     11fc <solve_matrix+0xcc>
jmp    1202 <solve_matrix+0xd2>
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1207 <solve_matrix+0xd7>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    118b <solve_matrix+0x5b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13b0 <solve_matrix+0x280>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12ec <solve_matrix+0x1bc>
jp     12ec <solve_matrix+0x1bc>
jmp    13a2 <solve_matrix+0x272>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    135f <solve_matrix+0x22f>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12f2 <solve_matrix+0x1c2>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1294 <solve_matrix+0x164>
jmp    13b5 <solve_matrix+0x285>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <solve_matrix+0x3b>
cmpl   $0x0,-0x1c(%rbp)
je     13dd <solve_matrix+0x2ad>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <print_matrix@plt>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     1530 <solve_matrix+0x400>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1467 <solve_matrix+0x337>
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x4c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1401 <solve_matrix+0x2d1>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14d1 <solve_matrix+0x3a1>
jp     14d1 <solve_matrix+0x3a1>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    14c0 <solve_matrix+0x390>
jp     14c0 <solve_matrix+0x390>
lea    0xb52(%rip),%rdi
call   1030 <printf@plt>
jmp    1530 <solve_matrix+0x400>
lea    0xb62(%rip),%rdi
call   1030 <printf@plt>
jmp    1530 <solve_matrix+0x400>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  0xae3(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    13e6 <solve_matrix+0x2b6>
cmpl   $0x0,-0x1c(%rbp)
je     154a <solve_matrix+0x41a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <print_matrix@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r14
mov    %rsi,%r13
mov    %edi,%r12d
mov    %rdi,0x20(%rsp)
cmp    $0x2,%edi
jl     1423 <solve_matrix+0x303>
mov    0x20(%rsp),%rax
add    $0xffffffff,%eax
mov    %rax,0x38(%rsp)
mov    %r12,%rax
neg    %rax
mov    %rax,0x50(%rsp)
lea    -0x1(%r12),%rax
mov    %rax,0x28(%rsp)
mov    $0x1,%eax
mov    %rax,0x8(%rsp)
mov    $0x3,%eax
mov    %rax,0x10(%rsp)
xor    %r15d,%r15d
xorpd  %xmm6,%xmm6
jmp    11b5 <solve_matrix+0x95>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
addq   $0x1,0x8(%rsp)
addq   $0xffffffffffffffff,0x28(%rsp)
addq   $0x1,0x10(%rsp)
mov    0x30(%rsp),%r15
cmp    0x38(%rsp),%r15
mov    %r9,%r13
je     1423 <solve_matrix+0x303>
lea    0x1(%r15),%rax
cmp    %r12,%rax
mov    %rax,0x30(%rsp)
jae    1230 <solve_matrix+0x110>
mov    0x8(%rsp),%rbx
mov    %r15d,%ebp
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,8),%rax
movsd  (%rax,%r15,8),%xmm0
movsd  %xmm0,0x18(%rsp)
movslq %ebp,%rbp
mov    0x0(%r13,%rbp,8),%rax
cvttsd2si (%rax,%r15,8),%edi
call   1040 <fabs@plt>
xor    %edi,%edi
movsd  0x18(%rsp),%xmm1
ucomisd %xmm0,%xmm1
seta   %dil
call   1040 <fabs@plt>
xorpd  %xmm6,%xmm6
ucomisd %xmm6,%xmm0
cmovne %ebx,%ebp
cmovp  %ebx,%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <solve_matrix+0xb0>
jmp    1233 <solve_matrix+0x113>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%ebp
mov    0x0(%r13,%r15,8),%rax
movslq %ebp,%rcx
mov    0x0(%r13,%rcx,8),%rdx
mov    %rdx,0x0(%r13,%r15,8)
mov    %r13,%r9
mov    %rax,0x0(%r13,%rcx,8)
movsd  (%r14,%r15,8),%xmm0
movsd  (%r14,%rcx,8),%xmm1
movsd  %xmm1,(%r14,%r15,8)
movsd  %xmm0,(%r14,%rcx,8)
cmp    %r12,0x30(%rsp)
jae    1190 <solve_matrix+0x70>
mov    0x28(%rsp),%rax
and    $0xfffffffffffffffc,%rax
mov    %r15,%rcx
not    %rcx
add    %r12,%rcx
mov    (%r9,%r15,8),%rdx
mov    0x8(%rsp),%r13
lea    (%rdx,%r13,8),%rsi
mov    %rsi,0x48(%rsp)
lea    (%rdx,%r12,8),%rsi
mov    %rsi,0x18(%rsp)
lea    0x1(%r15),%rsi
mov    %rcx,%r11
and    $0xfffffffffffffffc,%r11
lea    (%r15,%r11,1),%rdi
add    $0x1,%rdi
mov    %rdi,0x40(%rsp)
mov    0x10(%rsp),%rdi
lea    (%rdx,%rdi,8),%rdi
jmp    12e3 <solve_matrix+0x1c3>
movsd  (%r14,%r13,8),%xmm1
mulsd  (%r14,%r15,8),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%r13,8)
add    $0x1,%r13
cmp    %r12,%r13
je     1190 <solve_matrix+0x70>
mov    (%r9,%r13,8),%r10
movsd  (%r10,%r15,8),%xmm1
movsd  (%rdx,%r15,8),%xmm2
movapd %xmm1,%xmm0
divsd  %xmm2,%xmm0
ucomisd %xmm6,%xmm0
jne    1303 <solve_matrix+0x1e3>
jnp    12d6 <solve_matrix+0x1b6>
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r10,%r15,8)
cmp    %r12,%rsi
je     12c0 <solve_matrix+0x1a0>
mov    %rsi,%rbp
cmp    $0x4,%rcx
jb     1398 <solve_matrix+0x278>
mov    0x8(%rsp),%rbp
lea    (%r10,%rbp,8),%rbx
cmp    0x18(%rsp),%rbx
jae    133d <solve_matrix+0x21d>
lea    (%r10,%r12,8),%rbx
mov    %rsi,%rbp
cmp    %rbx,0x48(%rsp)
jb     1398 <solve_matrix+0x278>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mov    0x10(%rsp),%rbp
lea    (%r10,%rbp,8),%rbx
xor    %ebp,%ebp
movupd -0x10(%rdi,%rbp,8),%xmm2
movupd (%rdi,%rbp,8),%xmm3
movupd -0x10(%rbx,%rbp,8),%xmm4
movupd (%rbx,%rbp,8),%xmm5
mulpd  %xmm1,%xmm2
subpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm3
subpd  %xmm3,%xmm5
movupd %xmm4,-0x10(%rbx,%rbp,8)
movupd %xmm5,(%rbx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%rax
jne    1350 <solve_matrix+0x230>
mov    0x40(%rsp),%rbp
cmp    %r11,%rcx
je     12c0 <solve_matrix+0x1a0>
mov    %r14,%r8
mov    %r12d,%r14d
sub    %ebp,%r14d
mov    %rbp,%rbx
test   $0x1,%r14b
je     13c7 <solve_matrix+0x2a7>
movsd  (%r10,%rbp,8),%xmm1
movsd  (%rdx,%rbp,8),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r10,%rbp,8)
lea    0x1(%rbp),%rbx
not    %rbp
cmp    0x50(%rsp),%rbp
mov    %r8,%r14
je     12c0 <solve_matrix+0x1a0>
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%rbx,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%r10,%rbx,8),%xmm2
subsd  %xmm1,%xmm2
movsd  0x8(%r10,%rbx,8),%xmm1
movsd  %xmm2,(%r10,%rbx,8)
movsd  0x8(%rdx,%rbx,8),%xmm2
mulsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%r10,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    13e0 <solve_matrix+0x2c0>
jmp    12c0 <solve_matrix+0x1a0>
cmpl   $0x0,0x20(%rsp)
jle    14ff <solve_matrix+0x3df>
xor    %eax,%eax
xorpd  %xmm0,%xmm0
movabs $0x3ff0000000000000,%rcx
mov    %r12,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rsi),%rbp
mov    -0x8(%r13,%rsi,8),%rdi
xorpd  %xmm1,%xmm1
cmp    %r12,%rsi
jge    14ca <solve_matrix+0x3aa>
xorpd  %xmm1,%xmm1
mov    %rsi,%rdx
test   $0x1,%al
je     1488 <solve_matrix+0x368>
movsd  (%r14,%rsi,8),%xmm1
mulsd  (%rdi,%rsi,8),%xmm1
addsd  %xmm0,%xmm1
movq   $0x0,(%rdi,%rsi,8)
lea    0x1(%rsi),%rdx
cmp    $0x1,%eax
je     14ca <solve_matrix+0x3aa>
nopl   (%rax)
movsd  (%r14,%rdx,8),%xmm2
mulsd  (%rdi,%rdx,8),%xmm2
addsd  %xmm1,%xmm2
movq   $0x0,(%rdi,%rdx,8)
movsd  0x8(%r14,%rdx,8),%xmm1
mulsd  0x8(%rdi,%rdx,8),%xmm1
addsd  %xmm2,%xmm1
movq   $0x0,0x8(%rdi,%rdx,8)
add    $0x2,%rdx
cmp    %edx,%r12d
jne    1490 <solve_matrix+0x370>
movsd  (%rdi,%rbp,8),%xmm3
ucomisd %xmm0,%xmm3
movsd  (%r14,%rbp,8),%xmm2
jne    14dd <solve_matrix+0x3bd>
jnp    150e <solve_matrix+0x3ee>
subsd  %xmm1,%xmm2
divsd  %xmm3,%xmm2
movsd  %xmm2,(%r14,%rbp,8)
mov    %rcx,(%rdi,%rbp,8)
add    $0x1,%eax
cmp    $0x1,%rsi
mov    %rbp,%rsi
jg     1450 <solve_matrix+0x330>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
lea    0xae3(%rip),%rax
lea    0xaf8(%rip),%rdi
cmovne %rax,%rdi
cmovp  %rax,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Equations are underconstrained.\0A\00"
@.str.1 = [29 x i8] c"Equations are inconsistent.\0A\00"
define void @solve_matrix(i32 %0, double** %1, double* %2) {
%4 = alloca i32
%5 = alloca double**
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%16 = alloca double
store i32 %0, i32* %4
store double** %1, double*** %5
store double* %2, double** %6
store i32 0, i32* %7
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %3
%20 = load i32, i32* %4
%21 = load double**, double*** %5
%22 = load double*, double** %6
%23 = call i32 @print_matrix(i32 %20, double** %21, double* %22)
br label %24
24: ; preds = %19, %3
store i32 0, i32* %8
br label %25
25: ; preds = %186, %24
%26 = load i32, i32* %8
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %189
30: ; preds = %25
%31 = load i32, i32* %8
store i32 %31, i32* %9
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %34
34: ; preds = %66, %30
%35 = load i32, i32* %10
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %69
38: ; preds = %34
%39 = load double**, double*** %5
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double*, double** %39, i64 %41
%43 = load double*, double** %42
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = load double**, double*** %5
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double*, double** %48, i64 %50
%52 = load double*, double** %51
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = fptosi double %56 to i32
%58 = call double @fabs(i32 %57)
%59 = fcmp ogt double %47, %58
%60 = zext i1 %59 to i32
%61 = call double @fabs(i32 %60)
%62 = fcmp une double %61, 0.000000e+00
br i1 %62, label %63, label %65
63: ; preds = %38
%64 = load i32, i32* %10
store i32 %64, i32* %9
br label %65
65: ; preds = %63, %38
br label %66
66: ; preds = %65
%67 = load i32, i32* %10
%68 = add nsw i32 %67, 1
store i32 %68, i32* %10
br label %34
69: ; preds = %34
%70 = load double**, double*** %5
%71 = load i32, i32* %8
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double*, double** %70, i64 %72
%74 = load double*, double** %73
store double* %74, double** %11
%75 = load double**, double*** %5
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double*, double** %75, i64 %77
%79 = load double*, double** %78
%80 = load double**, double*** %5
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double*, double** %80, i64 %82
store double* %79, double** %83
%84 = load double*, double** %11
%85 = load double**, double*** %5
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double*, double** %85, i64 %87
store double* %84, double** %88
%89 = load double*, double** %6
%90 = load i32, i32* %8
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
store double %93, double* %12
%94 = load double*, double** %6
%95 = load i32, i32* %9
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
%98 = load double, double* %97
%99 = load double*, double** %6
%100 = load i32, i32* %8
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %99, i64 %101
store double %98, double* %102
%103 = load double, double* %12
%104 = load double*, double** %6
%105 = load i32, i32* %9
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
store double %103, double* %107
%108 = load i32, i32* %8
%109 = add nsw i32 %108, 1
store i32 %109, i32* %10
br label %110
110: ; preds = %182, %69
%111 = load i32, i32* %10
%112 = load i32, i32* %4
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %185
114: ; preds = %110
%115 = load double**, double*** %5
%116 = load i32, i32* %10
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double*, double** %115, i64 %117
%119 = load double*, double** %118
%120 = load i32, i32* %8
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
%123 = load double, double* %122
%124 = load double**, double*** %5
%125 = load i32, i32* %8
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double*, double** %124, i64 %126
%128 = load double*, double** %127
%129 = load i32, i32* %8
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds double, double* %128, i64 %130
%132 = load double, double* %131
%133 = fdiv double %123, %132
store double %133, double* %14
%134 = load double, double* %14
%135 = fcmp oeq double %134, 0.000000e+00
br i1 %135, label %136, label %137
136: ; preds = %114
br label %182
137: ; preds = %114
%138 = load i32, i32* %8
store i32 %138, i32* %13
br label %139
139: ; preds = %165, %137
%140 = load i32, i32* %13
%141 = load i32, i32* %4
%142 = icmp slt i32 %140, %141
br i1 %142, label %143, label %168
143: ; preds = %139
%144 = load double**, double*** %5
%145 = load i32, i32* %8
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds double*, double** %144, i64 %146
%148 = load double*, double** %147
%149 = load i32, i32* %13
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %148, i64 %150
%152 = load double, double* %151
%153 = load double, double* %14
%154 = load double**, double*** %5
%155 = load i32, i32* %10
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds double*, double** %154, i64 %156
%158 = load double*, double** %157
%159 = load i32, i32* %13
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds double, double* %158, i64 %160
%162 = load double, double* %161
%163 = fneg double %152
%164 = call double @llvm.fmuladd.f64(double %163, double %153, double %162)
store double %164, double* %161
br label %165
165: ; preds = %143
%166 = load i32, i32* %13
%167 = add nsw i32 %166, 1
store i32 %167, i32* %13
br label %139
168: ; preds = %139
%169 = load double*, double** %6
%170 = load i32, i32* %8
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds double, double* %169, i64 %171
%173 = load double, double* %172
%174 = load double, double* %14
%175 = load double*, double** %6
%176 = load i32, i32* %10
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds double, double* %175, i64 %177
%179 = load double, double* %178
%180 = fneg double %173
%181 = call double @llvm.fmuladd.f64(double %180, double %174, double %179)
store double %181, double* %178
br label %182
182: ; preds = %168, %136
%183 = load i32, i32* %10
%184 = add nsw i32 %183, 1
store i32 %184, i32* %10
br label %110
185: ; preds = %110
br label %186
186: ; preds = %185
%187 = load i32, i32* %8
%188 = add nsw i32 %187, 1
store i32 %188, i32* %8
br label %25
189: ; preds = %25
%190 = load i32, i32* %7
%191 = icmp ne i32 %190, 0
br i1 %191, label %192, label %197
192: ; preds = %189
%193 = load i32, i32* %4
%194 = load double**, double*** %5
%195 = load double*, double** %6
%196 = call i32 @print_matrix(i32 %193, double** %194, double* %195)
br label %197
197: ; preds = %192, %189
%198 = load i32, i32* %4
%199 = sub nsw i32 %198, 1
store i32 %199, i32* %8
br label %200
200: ; preds = %290, %197
%201 = load i32, i32* %8
%202 = icmp sge i32 %201, 0
br i1 %202, label %203, label %293
203: ; preds = %200
store double 0.000000e+00, double* %16
%204 = load i32, i32* %8
%205 = add nsw i32 %204, 1
store i32 %205, i32* %15
br label %206
206: ; preds = %235, %203
%207 = load i32, i32* %15
%208 = load i32, i32* %4
%209 = icmp slt i32 %207, %208
br i1 %209, label %210, label %238
210: ; preds = %206
%211 = load double*, double** %6
%212 = load i32, i32* %15
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds double, double* %211, i64 %213
%215 = load double, double* %214
%216 = load double**, double*** %5
%217 = load i32, i32* %8
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds double*, double** %216, i64 %218
%220 = load double*, double** %219
%221 = load i32, i32* %15
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds double, double* %220, i64 %222
%224 = load double, double* %223
%225 = load double, double* %16
%226 = call double @llvm.fmuladd.f64(double %215, double %224, double %225)
store double %226, double* %16
%227 = load double**, double*** %5
%228 = load i32, i32* %8
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double*, double** %227, i64 %229
%231 = load double*, double** %230
%232 = load i32, i32* %15
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds double, double* %231, i64 %233
store double 0.000000e+00, double* %234
br label %235
235: ; preds = %210
%236 = load i32, i32* %15
%237 = add nsw i32 %236, 1
store i32 %237, i32* %15
br label %206
238: ; preds = %206
%239 = load double**, double*** %5
%240 = load i32, i32* %8
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds double*, double** %239, i64 %241
%243 = load double*, double** %242
%244 = load i32, i32* %8
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds double, double* %243, i64 %245
%247 = load double, double* %246
%248 = fcmp oeq double %247, 0.000000e+00
br i1 %248, label %249, label %260
249: ; preds = %238
%250 = load double*, double** %6
%251 = load i32, i32* %8
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds double, double* %250, i64 %252
%254 = load double, double* %253
%255 = fcmp oeq double %254, 0.000000e+00
br i1 %255, label %256, label %258
256: ; preds = %249
%257 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %293
258: ; preds = %249
%259 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %293
260: ; preds = %238
%261 = load double*, double** %6
%262 = load i32, i32* %8
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds double, double* %261, i64 %263
%265 = load double, double* %264
%266 = load double, double* %16
%267 = fsub double %265, %266
%268 = load double**, double*** %5
%269 = load i32, i32* %8
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds double*, double** %268, i64 %270
%272 = load double*, double** %271
%273 = load i32, i32* %8
%274 = sext i32 %273 to i64
%275 = getelementptr inbounds double, double* %272, i64 %274
%276 = load double, double* %275
%277 = fdiv double %267, %276
%278 = load double*, double** %6
%279 = load i32, i32* %8
%280 = sext i32 %279 to i64
%281 = getelementptr inbounds double, double* %278, i64 %280
store double %277, double* %281
%282 = load double**, double*** %5
%283 = load i32, i32* %8
%284 = sext i32 %283 to i64
%285 = getelementptr inbounds double*, double** %282, i64 %284
%286 = load double*, double** %285
%287 = load i32, i32* %8
%288 = sext i32 %287 to i64
%289 = getelementptr inbounds double, double* %286, i64 %288
store double 1.000000e+00, double* %289
br label %290
290: ; preds = %260
%291 = load i32, i32* %8
%292 = add nsw i32 %291, -1
store i32 %292, i32* %8
br label %200
293: ; preds = %258, %256, %200
%294 = load i32, i32* %7
%295 = icmp ne i32 %294, 0
br i1 %295, label %296, label %301
296: ; preds = %293
%297 = load i32, i32* %4
%298 = load double**, double*** %5
%299 = load double*, double** %6
%300 = call i32 @print_matrix(i32 %297, double** %298, double* %299)
br label %301
301: ; preds = %296, %293
ret void
}

LLVM IR (-O2):
@str = [28 x i8] c"Equations are inconsistent.\00"
@str.2 = [32 x i8] c"Equations are underconstrained.\00"
define void @solve_matrix(i32 %0, double** nocapture %1, double* nocapture %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = add nsw i32 %0, -1
%7 = zext i32 %0 to i64
%8 = zext i32 %6 to i64
%9 = zext i32 %0 to i64
%10 = zext i32 %0 to i64
%11 = sub nsw i64 0, %9
br label %19
12: ; preds = %163, %49
%13 = add nuw nsw i64 %21, 1
%14 = icmp eq i64 %24, %8
br i1 %14, label %15, label %19
15: ; preds = %12, %3
%16 = icmp sgt i32 %0, 0
br i1 %16, label %17, label %223
17: ; preds = %15
%18 = zext i32 %0 to i64
br label %166
19: ; preds = %5, %12
%20 = phi i64 [ 0, %5 ], [ %24, %12 ]
%21 = phi i64 [ 1, %5 ], [ %13, %12 ]
%22 = xor i64 %20, -1
%23 = add nsw i64 %22, %9
%24 = add nuw nsw i64 %20, 1
%25 = icmp ult i64 %24, %7
%26 = trunc i64 %20 to i32
br i1 %25, label %27, label %49
27: ; preds = %19, %27
%28 = phi i64 [ %47, %27 ], [ %21, %19 ]
%29 = phi i32 [ %46, %27 ], [ %26, %19 ]
%30 = getelementptr inbounds double*, double** %1, i64 %28
%31 = load double*, double** %30
%32 = getelementptr inbounds double, double* %31, i64 %20
%33 = load double, double* %32
%34 = sext i32 %29 to i64
%35 = getelementptr inbounds double*, double** %1, i64 %34
%36 = load double*, double** %35
%37 = getelementptr inbounds double, double* %36, i64 %20
%38 = load double, double* %37
%39 = fptosi double %38 to i32
%40 = tail call double @fabs(i32 %39)
%41 = fcmp ogt double %33, %40
%42 = zext i1 %41 to i32
%43 = tail call double @fabs(i32 %42)
%44 = fcmp une double %43, 0.000000e+00
%45 = trunc i64 %28 to i32
%46 = select i1 %44, i32 %45, i32 %29
%47 = add nuw nsw i64 %28, 1
%48 = icmp eq i64 %47, %9
br i1 %48, label %49, label %27
49: ; preds = %27, %19
%50 = phi i32 [ %26, %19 ], [ %46, %27 ]
%51 = getelementptr inbounds double*, double** %1, i64 %20
%52 = load double*, double** %51
%53 = sext i32 %50 to i64
%54 = getelementptr inbounds double*, double** %1, i64 %53
%55 = load double*, double** %54
store double* %55, double** %51
store double* %52, double** %54
%56 = getelementptr inbounds double, double* %2, i64 %20
%57 = load double, double* %56
%58 = getelementptr inbounds double, double* %2, i64 %53
%59 = load double, double* %58
store double %59, double* %56
store double %57, double* %58
br i1 %25, label %60, label %12
60: ; preds = %49
%61 = load double*, double** %51
%62 = getelementptr inbounds double, double* %61, i64 %20
%63 = getelementptr double, double* %61, i64 %21
%64 = getelementptr double, double* %61, i64 %9
%65 = add nuw nsw i64 %20, 1
%66 = icmp eq i64 %65, %10
%67 = icmp ult i64 %23, 4
%68 = and i64 %23, -4
%69 = add i64 %65, %68
%70 = icmp eq i64 %23, %68
br label %71
71: ; preds = %60, %163
%72 = phi i64 [ %21, %60 ], [ %164, %163 ]
%73 = getelementptr inbounds double*, double** %1, i64 %72
%74 = load double*, double** %73
%75 = getelementptr inbounds double, double* %74, i64 %20
%76 = load double, double* %75
%77 = load double, double* %62
%78 = fdiv double %76, %77
%79 = fcmp oeq double %78, 0.000000e+00
br i1 %79, label %163, label %80
80: ; preds = %71
%81 = getelementptr inbounds double, double* %74, i64 %20
%82 = fneg double %77
%83 = tail call double @llvm.fmuladd.f64(double %82, double %78, double %76)
store double %83, double* %81
br i1 %66, label %157, label %84
84: ; preds = %80
br i1 %67, label %120, label %85
85: ; preds = %84
%86 = getelementptr double, double* %74, i64 %21
%87 = getelementptr double, double* %74, i64 %9
%88 = icmp ult double* %86, %64
%89 = icmp ult double* %63, %87
%90 = and i1 %88, %89
br i1 %90, label %120, label %91
91: ; preds = %85
%92 = insertelement <2 x double> poison, double %78, i64 0
%93 = shufflevector <2 x double> %92, <2 x double> poison, <2 x i32> zeroinitializer
%94 = insertelement <2 x double> poison, double %78, i64 0
%95 = shufflevector <2 x double> %94, <2 x double> poison, <2 x i32> zeroinitializer
br label %96
96: ; preds = %96, %91
%97 = phi i64 [ 0, %91 ], [ %117, %96 ]
%98 = add i64 %65, %97
%99 = getelementptr inbounds double, double* %61, i64 %98
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = getelementptr inbounds double, double* %99, i64 2
%103 = bitcast double* %102 to <2 x double>*
%104 = load <2 x double>, <2 x double>* %103
%105 = getelementptr inbounds double, double* %74, i64 %98
%106 = bitcast double* %105 to <2 x double>*
%107 = load <2 x double>, <2 x double>* %106
%108 = getelementptr inbounds double, double* %105, i64 2
%109 = bitcast double* %108 to <2 x double>*
%110 = load <2 x double>, <2 x double>* %109
%111 = fneg <2 x double> %101
%112 = fneg <2 x double> %104
%113 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %111, <2 x double> %93, <2 x double> %107)
%114 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %112, <2 x double> %95, <2 x double> %110)
%115 = bitcast double* %105 to <2 x double>*
store <2 x double> %113, <2 x double>* %115
%116 = bitcast double* %108 to <2 x double>*
store <2 x double> %114, <2 x double>* %116
%117 = add nuw i64 %97, 4
%118 = icmp eq i64 %117, %68
br i1 %118, label %119, label %96
119: ; preds = %96
br i1 %70, label %157, label %120
120: ; preds = %85, %84, %119
%121 = phi i64 [ %65, %85 ], [ %65, %84 ], [ %69, %119 ]
%122 = sub i64 %9, %121
%123 = xor i64 %121, -1
%124 = and i64 %122, 1
%125 = icmp eq i64 %124, 0
br i1 %125, label %135, label %126
126: ; preds = %120
%127 = getelementptr inbounds double, double* %61, i64 %121
%128 = load double, double* %127
%129 = getelementptr inbounds double, double* %74, i64 %121
%130 = load double, double* %129
%131 = getelementptr inbounds double, double* %74, i64 %121
%132 = fneg double %128
%133 = tail call double @llvm.fmuladd.f64(double %132, double %78, double %130)
store double %133, double* %131
%134 = add nuw nsw i64 %121, 1
br label %135
135: ; preds = %126, %120
%136 = phi i64 [ %121, %120 ], [ %134, %126 ]
%137 = icmp eq i64 %123, %11
br i1 %137, label %157, label %138
138: ; preds = %135, %138
%139 = phi i64 [ %155, %138 ], [ %136, %135 ]
%140 = getelementptr inbounds double, double* %61, i64 %139
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %74, i64 %139
%143 = load double, double* %142
%144 = getelementptr inbounds double, double* %74, i64 %139
%145 = fneg double %141
%146 = tail call double @llvm.fmuladd.f64(double %145, double %78, double %143)
store double %146, double* %144
%147 = add nuw nsw i64 %139, 1
%148 = getelementptr inbounds double, double* %61, i64 %147
%149 = load double, double* %148
%150 = getelementptr inbounds double, double* %74, i64 %147
%151 = load double, double* %150
%152 = getelementptr inbounds double, double* %74, i64 %147
%153 = fneg double %149
%154 = tail call double @llvm.fmuladd.f64(double %153, double %78, double %151)
store double %154, double* %152
%155 = add nuw nsw i64 %139, 2
%156 = icmp eq i64 %155, %10
br i1 %156, label %157, label %138
157: ; preds = %135, %138, %119, %80
%158 = load double, double* %56
%159 = getelementptr inbounds double, double* %2, i64 %72
%160 = load double, double* %159
%161 = fneg double %158
%162 = tail call double @llvm.fmuladd.f64(double %161, double %78, double %160)
store double %162, double* %159
br label %163
163: ; preds = %71, %157
%164 = add nuw nsw i64 %72, 1
%165 = icmp eq i64 %164, %10
br i1 %165, label %12, label %71
166: ; preds = %17, %217
%167 = phi i32 [ 0, %17 ], [ %222, %217 ]
%168 = phi i64 [ %18, %17 ], [ %170, %217 ]
%169 = phi i64 [ %18, %17 ], [ %221, %217 ]
%170 = add nsw i64 %168, -1
%171 = icmp slt i64 %168, %18
%172 = getelementptr inbounds double*, double** %1, i64 %170
%173 = load double*, double** %172
br i1 %171, label %174, label %206
174: ; preds = %166
%175 = and i32 %167, 1
%176 = icmp eq i32 %175, 0
br i1 %176, label %184, label %177
177: ; preds = %174
%178 = getelementptr inbounds double, double* %2, i64 %169
%179 = load double, double* %178
%180 = getelementptr inbounds double, double* %173, i64 %169
%181 = load double, double* %180
%182 = tail call double @llvm.fmuladd.f64(double %179, double %181, double 0.000000e+00)
store double 0.000000e+00, double* %180
%183 = add nsw i64 %169, 1
br label %184
184: ; preds = %177, %174
%185 = phi double [ undef, %174 ], [ %182, %177 ]
%186 = phi i64 [ %169, %174 ], [ %183, %177 ]
%187 = phi double [ 0.000000e+00, %174 ], [ %182, %177 ]
%188 = icmp eq i32 %167, 1
br i1 %188, label %206, label %189
189: ; preds = %184, %189
%190 = phi i64 [ %203, %189 ], [ %186, %184 ]
%191 = phi double [ %202, %189 ], [ %187, %184 ]
%192 = getelementptr inbounds double, double* %2, i64 %190
%193 = load double, double* %192
%194 = getelementptr inbounds double, double* %173, i64 %190
%195 = load double, double* %194
%196 = tail call double @llvm.fmuladd.f64(double %193, double %195, double %191)
store double 0.000000e+00, double* %194
%197 = add nsw i64 %190, 1
%198 = getelementptr inbounds double, double* %2, i64 %197
%199 = load double, double* %198
%200 = getelementptr inbounds double, double* %173, i64 %197
%201 = load double, double* %200
%202 = tail call double @llvm.fmuladd.f64(double %199, double %201, double %196)
store double 0.000000e+00, double* %200
%203 = add nsw i64 %190, 2
%204 = trunc i64 %203 to i32
%205 = icmp eq i32 %204, %0
br i1 %205, label %206, label %189
206: ; preds = %184, %189, %166
%207 = phi double [ 0.000000e+00, %166 ], [ %185, %184 ], [ %202, %189 ]
%208 = getelementptr inbounds double, double* %173, i64 %170
%209 = load double, double* %208
%210 = fcmp oeq double %209, 0.000000e+00
%211 = getelementptr inbounds double, double* %2, i64 %170
%212 = load double, double* %211
br i1 %210, label %213, label %217
213: ; preds = %206
%214 = fcmp oeq double %212, 0.000000e+00
%215 = select i1 %214, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0)
%216 = tail call i32 @puts(i8* dereferenceable(1) %215)
br label %223
217: ; preds = %206
%218 = fsub double %212, %207
%219 = fdiv double %218, %209
store double %219, double* %211
store double 1.000000e+00, double* %208
%220 = icmp sgt i64 %168, 1
%221 = add nsw i64 %169, -1
%222 = add i32 %167, 1
br i1 %220, label %166, label %223
223: ; preds = %217, %213, %15
ret void
}