// File: /workspace/github_c_makefile_star2_O3/markpeerdeman[P]mbemm/src/emath/solve.c
// Function: solve_gauss
void solve_gauss(const matrix A,const vector F )
{ int i,j,k,l,m,n = F->rows;
  double c,tmp;
  double fabsc, fabsM;
  evaluate_level(GREEN,38);
  tijdvalkje(0,A);
  check_dimensions(A, F);
  for (k=0; k<n; k++)
  { /* divide row by diagonal coefficient: */
    c = M(A,k,k); l=k;
    /* find largest coefficient for elimination: */
    for (m=k; m<n; m++)
    { fabsc=fabs(c);
	  fabsM=fabs(M(A,m,k));
	  /* if (fabs(M(A,m,k))>=fabs(c)) */
	  if (fabsM>=fabsc)
      { c = M(A,m,k);
	    l = m;
      }
    }
    /* if (fabs(c)<=TOL) 
      evaluate_level(RED,33); */
	/* change rows if nescessary: */
    if (k!=l)
    { 
      for (m=k; m<n; m++)
      { tmp = M(A,l,m);
	    M(A,l,m) = M(A,k,m);
	    M(A,k,m) = tmp;
      }
      tmp = V(F,l);
      V(F,l) = V(F,k);
      V(F,k) = tmp;
    }

    /* divide current row by diagonal coefficient: */
	M(A,k,k)=1.0;
	V(F,k) = V(F,k) / c;
    for (i=k+1; i<n; i++)
      {  M(A,k,i) = M(A,k,i) / c;
      }

    /* divide remaining rows by diagonal coefficient and eliminate: */
    for (j=k+1; j<n; j++)
    { c = M(A,j,k);
	  M(A,j,k)=0.0;
	  V(F,j)=V(F,j)-c*V(F,k);
      for (i=k+1; i<n; i++)
	  { M(A,j,i)=M(A,j,i)-c*M(A,k,i);
	  }
    }
	tijdvalkje(k+2,A);
  }

  /* apply backsubstitution to compute the remaining unknowns: */
  for (j=n-2; j>=0; j--)
  {
	for (i=n-1; i>j; i--)
	  { V(F,j) = V(F,j) - M(A,j,i) * V(F,i);
	  }
  }

  tijdvalkje(-1,A);

  evaluate_level(GREEN,34);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movslq (%rsi), %r15
pushq $0x26
popq %rsi
xorl %edi, %edi
callq 0xb980
xorl %edi, %edi
movq %r14, %rsi
callq 0x368c
movq %r14, 0x10(%rsp)
movq %r14, %rdi
movq %rbx, 0x8(%rsp)
movq %rbx, %rsi
callq 0x11e0
testq %r15, %r15
jle 0x1e5a
movq %r15, 0x18(%rsp)
movl %r15d, %r15d
pushq $0x1
popq %r11
xorl %ebp, %ebp
movapd 0xc3c0(%rip), %xmm4     # 0xe010
movapd 0xc3c8(%rip), %xmm5     # 0xe020
movq %r15, %r12
movq %r11, %r13
xorl %edi, %edi
movq 0x10(%rsp), %rbx
movq 0x8(%rbx), %rax
movq (%rax,%rdi,8), %rcx
movsd (%rcx,%rdi,8), %xmm0
movq %rdi, %r9
movl %edi, %edx
movapd %xmm0, %xmm1
andpd %xmm4, %xmm1
movq (%rax,%r9,8), %r8
movsd (%r8,%rdi,8), %xmm2
movapd %xmm2, %xmm3
andpd %xmm4, %xmm3
ucomisd %xmm1, %xmm3
cmovael %r9d, %edx
cmpnlesd %xmm3, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm1, %xmm0
incq %r9
cmpq %r9, %r15
jne 0x1c77
movl %edx, %r8d
cmpq %r8, %rdi
jne 0x1cc5
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rdx
jmp 0x1d0e
movslq %edx, %r9
movq (%rax,%r9,8), %rdx
movq %rdi, %r8
movsd (%rdx,%r8,8), %xmm1
movsd (%rcx,%r8,8), %xmm2
movsd %xmm2, (%rdx,%r8,8)
movsd %xmm1, (%rcx,%r8,8)
incq %r8
cmpq %r8, %r15
jne 0x1ccf
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rdx
movsd (%rdx,%r9,8), %xmm1
movsd (%rdx,%rdi,8), %xmm2
movsd %xmm2, (%rdx,%r9,8)
movsd %xmm1, (%rdx,%rdi,8)
movabsq $0x3ff0000000000000, %r8 # imm = 0x3FF0000000000000
movq %r8, (%rcx,%rdi,8)
movsd (%rdx,%rdi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rdi,8)
leaq 0x1(%rdi), %r14
cmpq %r15, %r14
jae 0x1db1
addq %rbp, %rcx
movq %r11, %r8
movsd (%rcx,%r8,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%r8,8)
incq %r8
cmpq %r8, %r12
jne 0x1d39
cmpq %r15, %r14
jae 0x1db1
movq %r13, %r10
movq (%rax,%r10,8), %r8
movsd (%r8,%rdi,8), %xmm1
andq $0x0, (%r8,%rdi,8)
movsd (%rdx,%r10,8), %xmm2
movapd %xmm1, %xmm0
xorpd %xmm5, %xmm0
mulsd (%rdx,%rdi,8), %xmm1
subsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%r10,8)
addq %rbp, %r8
movq %r11, %r9
movsd (%rcx,%r9,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%r8,%r9,8), %xmm1
movsd %xmm1, (%r8,%r9,8)
incq %r9
cmpq %r9, %r12
jne 0x1d8b
incq %r10
cmpq %r15, %r10
jne 0x1d59
addl $0x2, %edi
movq %rbx, %rsi
movq %r14, 0x20(%rsp)
movq %r13, %r14
movq %r11, %r13
callq 0x368c
movapd 0xc251(%rip), %xmm5     # 0xe020
movq %r13, %r11
movq %r14, %r13
movq 0x20(%rsp), %rdi
incq %r13
addq $0x8, %rbp
decq %r12
cmpq %r15, %rdi
movapd 0xc221(%rip), %xmm4     # 0xe010
jne 0x1c65
cmpl $0x1, %r15d
movq 0x18(%rsp), %r8
je 0x1e5a
leal -0x2(%r8), %eax
decl %r15d
decq %r8
cmpq %r15, %rax
jge 0x1e4e
movq 0x8(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq 0x10(%rsp), %rdx
movq 0x8(%rdx), %rdx
movq (%rdx,%rax,8), %rdx
movsd (%rcx,%rax,8), %xmm0
movq %r8, %rsi
movl %esi, %edi
shlq $0x3, %rdi
movsd (%rdx,%rdi), %xmm1
mulsd (%rcx,%rdi), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rax,8)
decq %rsi
cmpq %rsi, %rax
jl 0x1e2d
leaq -0x1(%rax), %rcx
testq %rax, %rax
movq %rcx, %rax
jg 0x1e0a
movq 0x13197(%rip), %rax     # 0x14ff8
movq (%rax), %rcx
leaq 0xc1df(%rip), %rdi      # 0xe04a
pushq $0x44
popq %rsi
pushq $0x1
popq %rdx
callq 0x11a0
pushq $0x22
popq %rsi
xorl %edi, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb980