// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/./Eigen/src/LU/PartialPivLU.h
// Function: Eigen::internal::partial_lu_impl<std::complex<double>, 0, int>::unblocked_lu(Eigen::Block<Eigen::Map<Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1>, 0, Eigen::Stride<0, 0>>, -1, -1, false>&, int*, int&)
static Index unblocked_lu(MatrixType& lu, PivIndex* row_transpositions, PivIndex& nb_transpositions)
  {
    typedef scalar_score_coeff_op<Scalar> Scoring;
    typedef typename Scoring::result_type Score;
    const Index rows = lu.rows();
    const Index cols = lu.cols();
    const Index size = (std::min)(rows,cols);
    nb_transpositions = 0;
    Index first_zero_pivot = -1;
    for(Index k = 0; k < size; ++k)
    {
      Index rrows = rows-k-1;
      Index rcols = cols-k-1;

      Index row_of_biggest_in_col;
      Score biggest_in_corner
        = lu.col(k).tail(rows-k).unaryExpr(Scoring()).maxCoeff(&row_of_biggest_in_col);
      row_of_biggest_in_col += k;

      row_transpositions[k] = PivIndex(row_of_biggest_in_col);

      if(biggest_in_corner != Score(0))
      {
        if(k != row_of_biggest_in_col)
        {
          lu.row(k).swap(lu.row(row_of_biggest_in_col));
          ++nb_transpositions;
        }

        // FIXME shall we introduce a safe quotient expression in cas 1/lu.coeff(k,k)
        // overflow but not the actual quotient?
        lu.col(k).tail(rrows) /= lu.coeff(k,k);
      }
      else if(first_zero_pivot==-1)
      {
        // the pivot is exactly zero, we record the index of the first pivot which is exactly 0,
        // and continue the factorization such we still have A = PLU
        first_zero_pivot = k;
      }

      if(k<rows-1)
        lu.bottomRightCorner(rrows,rcols).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rcols);
    }
    return first_zero_pivot;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x498, %rsp            # imm = 0x498
movq %rsi, 0x38(%rsp)
movq %rdi, %r15
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %rax
cmpq %r14, %rax
movq %r14, %rcx
cmovlq %rax, %rcx
movq %rdx, 0x18(%rsp)
andl $0x0, (%rdx)
movl $0x80, %edx
leaq 0x100(%rsp), %rsi
addq %rdx, %rsi
movq %rsi, 0x28(%rsp)
leaq 0x50(%rsp), %rbp
addq %rbp, %rdx
movq %rdx, 0x30(%rsp)
leaq -0x1(%r14), %rdx
movq %rdx, 0x20(%rsp)
xorl %ebx, %ebx
testq %rcx, %rcx
cmovleq %rbx, %rcx
movq %rcx, 0x40(%rsp)
decq %rax
movq %rax, 0x10(%rsp)
pushq $-0x1
popq %rax
movq %rax, (%rsp)
cmpq %rbx, 0x40(%rsp)
je 0x12e54
leaq -0x1(%r14), %r13
leaq 0x268(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1311c
movq %rbp, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x13010
movups 0x50(%rsp), %xmm0
movaps %xmm0, 0x100(%rsp)
leaq 0x68(%rsp), %rdx
movups (%rdx), %xmm0
leaq 0x118(%rsp), %rcx
movups %xmm0, (%rcx)
movq 0x28(%rdx), %rax
movq %rax, 0x28(%rcx)
movups 0x18(%rdx), %xmm0
movups %xmm0, 0x18(%rcx)
movq 0x40(%rdx), %rax
movq %rax, 0x40(%rcx)
movups 0x30(%rdx), %xmm0
movups %xmm0, 0x30(%rcx)
movq 0x60(%rdx), %rax
movq %rax, 0x60(%rcx)
movups 0x50(%rdx), %xmm0
movups %xmm0, 0x50(%rcx)
movq 0x30(%rsp), %rcx
movq 0x10(%rcx), %rax
movq 0x28(%rsp), %rdx
movq %rax, 0x10(%rdx)
movupd (%rcx), %xmm0
movupd %xmm0, (%rdx)
movq 0xe8(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x1a8(%rsp)
leaq 0x100(%rsp), %r14
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x13028
movq 0x8(%rsp), %rax
leaq (%rbx,%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x38(%rsp), %rdx
movl %ecx, (%rdx,%rbx,4)
ucomisd 0xa6ef(%rip), %xmm0     # 0x1d3f8
jne 0x12d0d
jnp 0x12d87
testq %rax, %rax
je 0x12d42
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x134e8
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x134e8
movq %r14, %rdi
movq %rbp, %rsi
callq 0x13052
movq 0x18(%rsp), %rax
incl (%rax)
movq 0x48(%r15), %rax
imulq %rbx, %rax
shlq $0x4, %rax
addq (%r15), %rax
movq %r14, %r12
movq %rbx, %r14
shlq $0x4, %r14
addq %rax, %r14
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1311c
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x13010
movq %r12, %rdi
movq %r14, %rsi
callq 0x13088
jmp 0x12d97
movq (%rsp), %rax
cmpq $-0x1, %rax
cmoveq %rbx, %rax
movq %rax, (%rsp)
cmpq 0x20(%rsp), %rbx
movq 0x10(%rsp), %r14
jge 0x12e3c
leaq 0x418(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1311c
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x13010
leaq 0x398(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x134e8
leaq 0x268(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x130c4
leaq 0x100(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
movq %r12, %rdx
callq 0x1398e
leaq 0x318(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x130dc
movq %r12, 0x48(%rsp)
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0x130fe
incq %rbx
decq %r14
movq %r14, 0x10(%rsp)
movq %r13, %r14
leaq 0x50(%rsp), %rbp
jmp 0x12c19
movq (%rsp), %rax
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq