// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %r15d
xorl %r12d, %r12d
pushq $0x26
popq %rsi
xorl %edi, %edi
callq 0xb0f8
xorl %edi, %edi
movq %rbx, %rsi
callq 0x12bc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13ab
testl %r15d, %r15d
movl $0x0, %eax
cmovgl %r15d, %eax
movq %rax, 0x8(%rsp)
pushq $0x1
popq %rbp
movapd 0xb21e(%rip), %xmm4     # 0xd020
movapd 0xb206(%rip), %xmm5     # 0xd010
movq %rbp, %r9
xorl %edi, %edi
cmpq 0x8(%rsp), %rdi
je 0x1f8e
movq 0x8(%rbx), %rax
movq (%rax,%rdi,8), %rcx
movsd (%rcx,%rdi,8), %xmm0
movq %rdi, %rsi
movl %edi, %edx
cmpq %rsi, %r15
je 0x1e68
movapd %xmm0, %xmm1
andpd %xmm5, %xmm1
movq (%rax,%rsi,8), %r8
movsd (%r8,%rdi,8), %xmm2
movapd %xmm2, %xmm3
andpd %xmm5, %xmm3
ucomisd %xmm1, %xmm3
cmovael %esi, %edx
cmpnlesd %xmm3, %xmm1
andpd %xmm1, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm1, %xmm0
incq %rsi
jmp 0x1e2c
movl %edx, %esi
cmpq %rsi, %rdi
jne 0x1e75
movq 0x8(%r14), %rdx
jmp 0x1eb7
movslq %edx, %rsi
movq %rdi, %rdx
cmpq %rdx, %r15
je 0x1e9f
movq (%rax,%rsi,8), %r8
movsd (%r8,%rdx,8), %xmm1
movsd (%rcx,%rdx,8), %xmm2
movsd %xmm2, (%r8,%rdx,8)
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
jmp 0x1e7b
movq 0x8(%r14), %rdx
movsd (%rdx,%rsi,8), %xmm1
movsd (%rdx,%rdi,8), %xmm2
movsd %xmm2, (%rdx,%rsi,8)
movsd %xmm1, (%rdx,%rdi,8)
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rcx,%rdi,8)
movsd (%rdx,%rdi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rdi,8)
addq %r12, %rcx
movq %rbp, %rsi
leal (%rdi,%rsi), %r8d
cmpl %r8d, %r15d
jle 0x1ef5
movsd (%rcx,%rsi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rsi,8)
incq %rsi
jmp 0x1ed9
movq %r9, 0x10(%rsp)
movq %r9, %rsi
cmpl %esi, %r15d
jle 0x1f5b
movq (%rax,%rsi,8), %r8
movsd (%r8,%rdi,8), %xmm1
andq $0x0, (%r8,%rdi,8)
movsd (%rdx,%rsi,8), %xmm2
movapd %xmm1, %xmm0
xorpd %xmm4, %xmm0
mulsd (%rdx,%rdi,8), %xmm1
subsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%rsi,8)
addq %r12, %r8
movq %rbp, %r9
leal (%rdi,%r9), %r10d
cmpl %r10d, %r15d
jle 0x1f56
movsd (%rcx,%r9,8), %xmm1
mulsd %xmm0, %xmm1
addsd (%r8,%r9,8), %xmm1
movsd %xmm1, (%r8,%r9,8)
incq %r9
jmp 0x1f32
incq %rsi
jmp 0x1efd
leaq 0x1(%rdi), %r13
addl $0x2, %edi
movq %rbx, %rsi
callq 0x12bc
movapd 0xb09e(%rip), %xmm5     # 0xd010
movapd 0xb0a6(%rip), %xmm4     # 0xd020
movq 0x10(%rsp), %r9
incq %r9
addq $0x8, %r12
movq %r13, %rdi
jmp 0x1e0f
leal -0x2(%r15), %eax
decl %r15d
testl %eax, %eax
js 0x1fd3
movl %eax, %ecx
movl %r15d, %edx
cmpl %eax, %edx
jle 0x1fcf
movq 0x8(%r14), %rsi
movq 0x8(%rbx), %rdi
movq (%rdi,%rcx,8), %rdi
movl %edx, %r8d
movsd (%rdi,%r8,8), %xmm0
mulsd (%rsi,%r8,8), %xmm0
movsd (%rsi,%rcx,8), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, (%rsi,%rcx,8)
decl %edx
jmp 0x1f9e
decl %eax
jmp 0x1f95
pushq $-0x1
popq %rdi
movq %rbx, %rsi
callq 0x12bc
pushq $0x22
popq %rsi
xorl %edi, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb0f8
nop