// 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>::blocked_lu(long, long, std::complex<double>*, long, int*, int&, long)
static Index blocked_lu(Index rows, Index cols, Scalar* lu_data, Index luStride, PivIndex* row_transpositions, PivIndex& nb_transpositions, Index maxBlockSize=256)
  {
    MapLU lu1(lu_data,StorageOrder==RowMajor?rows:luStride,StorageOrder==RowMajor?luStride:cols);
    MatrixType lu(lu1,0,0,rows,cols);

    const Index size = (std::min)(rows,cols);

    // if the matrix is too small, no blocking:
    if(size<=16)
    {
      return unblocked_lu(lu, row_transpositions, nb_transpositions);
    }

    // automatically adjust the number of subdivisions to the size
    // of the matrix so that there is enough sub blocks:
    Index blockSize;
    {
      blockSize = size/8;
      blockSize = (blockSize/16)*16;
      blockSize = (std::min)((std::max)(blockSize,Index(8)), maxBlockSize);
    }

    nb_transpositions = 0;
    Index first_zero_pivot = -1;
    for(Index k = 0; k < size; k+=blockSize)
    {
      Index bs = (std::min)(size-k,blockSize); // actual size of the block
      Index trows = rows - k - bs; // trailing rows
      Index tsize = size - k - bs; // trailing size

      // partition the matrix:
      //                          A00 | A01 | A02
      // lu  = A_0 | A_1 | A_2 =  A10 | A11 | A12
      //                          A20 | A21 | A22
      BlockType A_0(lu,0,0,rows,k);
      BlockType A_2(lu,0,k+bs,rows,tsize);
      BlockType A11(lu,k,k,bs,bs);
      BlockType A12(lu,k,k+bs,bs,tsize);
      BlockType A21(lu,k+bs,k,trows,bs);
      BlockType A22(lu,k+bs,k+bs,trows,tsize);

      PivIndex nb_transpositions_in_panel;
      // recursively call the blocked LU algorithm on [A11^T A21^T]^T
      // with a very small blocking size:
      Index ret = blocked_lu(trows+bs, bs, &lu.coeffRef(k,k), luStride,
                   row_transpositions+k, nb_transpositions_in_panel, 16);
      if(ret>=0 && first_zero_pivot==-1)
        first_zero_pivot = k+ret;

      nb_transpositions += nb_transpositions_in_panel;
      // update permutations and apply them to A_0
      for(Index i=k; i<k+bs; ++i)
      {
        Index piv = (row_transpositions[i] += internal::convert_index<PivIndex>(k));
        A_0.row(i).swap(A_0.row(piv));
      }

      if(trows)
      {
        // apply permutations to A_2
        for(Index i=k;i<k+bs; ++i)
          A_2.row(i).swap(A_2.row(row_transpositions[i]));

        // A12 = A11^-1 A12
        A11.template triangularView<UnitLower>().solveInPlace(A12);

        A22.noalias() -= A21 * A12;
      }
    }
    return first_zero_pivot;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5a8, %rsp            # imm = 0x5A8
movq %r9, 0x18(%rsp)
movq %r8, %rbp
movq %rsi, %r14
movq %rdi, %r12
leaq 0x150(%rsp), %rbx
movq %rbx, %rdi
movq %rdx, %rsi
movq %rcx, 0x68(%rsp)
movq %rcx, %rdx
movq %r14, %rcx
callq 0x12f2c
leaq 0x80(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
movq %r14, %r9
callq 0x12b30
cmpq %r12, %r14
movq %r12, 0x60(%rsp)
cmovgeq %r12, %r14
cmpq $0x10, %r14
jg 0x127a9
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rdx
callq 0x12b9e
jmp 0x12b1d
movq %r14, %rax
shrq $0x3, %rax
movabsq $0xffffffffffffff0, %rcx # imm = 0xFFFFFFFFFFFFFF0
andq %rax, %rcx
pushq $0x8
popq %rdx
cmovneq %rcx, %rdx
movq 0x5e0(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
movq 0x18(%rsp), %rax
andl $0x0, (%rax)
pushq $-0x1
popq %rax
movq %rax, 0x28(%rsp)
xorl %ebx, %ebx
leaq 0x4a8(%rsp), %r12
movq %r14, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rbp, 0x30(%rsp)
movq %r14, %rax
subq %rbx, %rax
jle 0x12b18
cmpq %rax, %rdx
cmovlq %rdx, %rax
movq 0x60(%rsp), %r15
movq %r15, %rcx
subq %rbx, %rcx
movq %rcx, 0x40(%rsp)
subq %rax, %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rbx), %r13
subq %r13, %r14
movq %r14, 0x20(%rsp)
leaq 0x528(%rsp), %rdi
movq %r12, %rbp
leaq 0x80(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rax, %r14
movq %r15, %r8
movq %rbx, %r9
callq 0x12e6a
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r13, %rcx
movq %r15, %r8
movq 0x20(%rsp), %rbp
movq %rbp, %r9
callq 0x12e6a
leaq 0xd0(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %rbx, %rcx
movq %r14, %r8
movq %r14, %r9
callq 0x12e6a
leaq 0x428(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movq %r14, %r8
movq %rbp, %r9
callq 0x12e6a
leaq 0x3a8(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
movq 0x10(%rsp), %r15
movq %r15, %r8
movq %r14, %r9
callq 0x12e6a
leaq 0x328(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r13, 0x48(%rsp)
movq %r13, %rcx
movq %r15, %r8
movq %rbp, %r9
callq 0x12e6a
movq 0xc8(%rsp), %rax
imulq %rbx, %rax
shlq $0x4, %rax
addq 0x80(%rsp), %rax
movq %rbx, %rdx
shlq $0x4, %rdx
addq %rax, %rdx
movq 0x30(%rsp), %rax
leaq (%rax,%rbx,4), %r8
movq $0x10, (%rsp)
movq 0x40(%rsp), %rdi
movq %r14, 0x20(%rsp)
movq %r14, %rsi
movq 0x68(%rsp), %rcx
leaq 0x3c(%rsp), %r9
callq 0x12726
movl 0x3c(%rsp), %ecx
movq 0x18(%rsp), %rdx
addl %ecx, (%rdx)
movq %rax, 0x70(%rsp)
addq %rbx, %rax
movq %rax, 0x78(%rsp)
movslq %ebx, %rbp
movq %rbx, 0x10(%rsp)
cmpq 0x48(%rsp), %rbx
jge 0x129ba
movq 0x30(%rsp), %rax
movslq (%rax,%rbx,4), %r15
addq %rbp, %r15
movl %r15d, (%rax,%rbx,4)
leaq 0x170(%rsp), %r14
movq %r14, %rdi
leaq 0x528(%rsp), %r12
movq %r12, %rsi
movq %rbx, %rdx
callq 0x14298
leaq 0x278(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x14298
movq %r14, %rdi
movq %r13, %rsi
callq 0x12ed8
incq %rbx
jmp 0x1295f
movq 0x28(%rsp), %rax
cmpq $-0x1, %rax
movq 0x78(%rsp), %rcx
cmovneq %rax, %rcx
cmpq $0x0, 0x70(%rsp)
cmovnsq %rcx, %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rbx
movq 0x40(%rsp), %rax
cmpq 0x20(%rsp), %rax
movq 0x58(%rsp), %r15
leaq 0x4a8(%rsp), %r12
movq 0x30(%rsp), %rbp
je 0x12b03
cmpq 0x48(%rsp), %rbx
jge 0x12a47
leaq 0x170(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x14298
movslq (%rbp,%rbx,4), %rdx
leaq 0x278(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x14298
movq %r14, %rdi
movq %r13, %rsi
callq 0x12ed8
incq %rbx
jmp 0x12a02
movq 0xe0(%rsp), %rax
movq %rax, 0x180(%rsp)
movups 0xd0(%rsp), %xmm0
movaps %xmm0, 0x170(%rsp)
leaq 0xe8(%rsp), %rdx
movq 0x10(%rdx), %rax
leaq 0x188(%rsp), %rcx
movq %rax, 0x10(%rcx)
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
movq 0x28(%rdx), %rax
movq %rax, 0x28(%rcx)
movups 0x18(%rdx), %xmm0
movups %xmm0, 0x18(%rcx)
movq 0x48(%rdx), %rax
movq %rax, 0x48(%rcx)
movups 0x38(%rdx), %xmm0
movups %xmm0, 0x38(%rcx)
movq 0x60(%rdx), %rax
movq %rax, 0x60(%rcx)
movups 0x50(%rdx), %xmm0
movups %xmm0, 0x50(%rcx)
leaq 0x170(%rsp), %r14
movq %r14, %rdi
leaq 0x428(%rsp), %rbx
movq %rbx, %rsi
callq 0x144fe
movq %r14, %rdi
leaq 0x3a8(%rsp), %rsi
movq %rbx, %rdx
callq 0x164f4
leaq 0x328(%rsp), %rax
movq %rax, 0x278(%rsp)
leaq 0x278(%rsp), %rdi
movq %r14, %rsi
callq 0x12f0e
movq 0x50(%rsp), %rdx
movq 0x10(%rsp), %rbx
addq %rdx, %rbx
movq %r15, %r14
jmp 0x127fc
movq 0x28(%rsp), %rax
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop