// File: 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
movq %rsp, %rbp
subq $0x8a0, %rsp            # imm = 0x8A0
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x880(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x878(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x870(%rbp)
leaq -0x5a(%rbp), %rdi
callq 0x4a2d0
movq -0x880(%rbp), %rsi
movq -0x878(%rbp), %rdx
movq -0x870(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x5a(%rbp), %r8
callq 0x4a310
movq -0x10(%rbp), %r8
movq -0x18(%rbp), %r9
leaq -0xb0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4a370
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3e940
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x10, -0xb8(%rbp)
jg 0x49cf0
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4a460
movq %rax, -0x8(%rbp)
jmp 0x4a1ac
movq -0xb8(%rbp), %rax
movl $0x8, %ecx
cqto
idivq %rcx
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
shlq $0x4, %rax
movq %rax, -0xc0(%rbp)
movq $0x8, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3e980
movq %rax, %rdi
leaq 0x10(%rbp), %rsi
callq 0x3e940
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq $-0x1, -0xd0(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x4a1a1
movq -0xb8(%rbp), %rax
subq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3e940
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
subq -0xd8(%rbp), %rax
subq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xb8(%rbp), %rax
subq -0xd8(%rbp), %rax
subq -0xe0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %r8
movq -0xd8(%rbp), %r9
leaq -0x178(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x4a730
movq -0xd8(%rbp), %rcx
addq -0xe0(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0xf8(%rbp), %r9
leaq -0x1f8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4a730
movq -0xd8(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0xe0(%rbp), %r8
movq -0xe0(%rbp), %r9
leaq -0x278(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4a730
movq -0xd8(%rbp), %rdx
movq -0xd8(%rbp), %rcx
addq -0xe0(%rbp), %rcx
movq -0xe0(%rbp), %r8
movq -0xf8(%rbp), %r9
leaq -0x2f8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4a730
movq -0xd8(%rbp), %rdx
addq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0xf0(%rbp), %r8
movq -0xe0(%rbp), %r9
leaq -0x378(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4a730
movq -0xd8(%rbp), %rdx
addq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
addq -0xe0(%rbp), %rcx
movq -0xf0(%rbp), %r8
movq -0xf8(%rbp), %r9
leaq -0x3f8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4a730
movq -0xf0(%rbp), %rax
addq -0xe0(%rbp), %rax
movq %rax, -0x890(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x888(%rbp)
movq -0xd8(%rbp), %rsi
movq -0xd8(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4a820
movq -0x890(%rbp), %rdi
movq -0x888(%rbp), %rsi
movq %rax, %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0xd8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %r8
leaq -0x3fc(%rbp), %r9
movq $0x10, (%rsp)
callq 0x49c20
movq %rax, -0x408(%rbp)
cmpq $0x0, -0x408(%rbp)
jl 0x49fc8
cmpq $-0x1, -0xd0(%rbp)
jne 0x49fc8
movq -0xd8(%rbp), %rax
addq -0x408(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl -0x3fc(%rbp), %ecx
movq -0x38(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0xd8(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x410(%rbp), %rax
movq -0xd8(%rbp), %rcx
addq -0xe0(%rbp), %rcx
cmpq %rcx, %rax
jge 0x4a086
leaq -0xd8(%rbp), %rdi
callq 0x4a8a0
movq -0x30(%rbp), %rcx
movq -0x410(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, (%rcx,%rdx,4)
cltq
movq %rax, -0x418(%rbp)
movq -0x410(%rbp), %rdx
leaq -0x4c8(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x4a8c0
movq -0x418(%rbp), %rdx
leaq -0x578(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x4a8c0
leaq -0x4c8(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x4a910
movq -0x410(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x410(%rbp)
jmp 0x49fe4
cmpq $0x0, -0xf0(%rbp)
je 0x4a185
movq -0xd8(%rbp), %rax
movq %rax, -0x580(%rbp)
movq -0x580(%rbp), %rax
movq -0xd8(%rbp), %rcx
addq -0xe0(%rbp), %rcx
cmpq %rcx, %rax
jge 0x4a11f
movq -0x580(%rbp), %rdx
leaq -0x630(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x4a8c0
movq -0x30(%rbp), %rax
movq -0x580(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
leaq -0x6e0(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x4a8c0
leaq -0x630(%rbp), %rdi
leaq -0x6e0(%rbp), %rsi
callq 0x4a910
movq -0x580(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x580(%rbp)
jmp 0x4a0a2
leaq -0x760(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x4a9e0
leaq -0x760(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x4aa20
leaq -0x860(%rbp), %rdi
leaq -0x378(%rbp), %rsi
leaq -0x2f8(%rbp), %rdx
callq 0x4aa50
leaq -0x3f8(%rbp), %rdi
callq 0x4aaa0
movq %rax, -0x868(%rbp)
leaq -0x868(%rbp), %rdi
leaq -0x860(%rbp), %rsi
callq 0x4aad0
jmp 0x4a187
movq -0xc0(%rbp), %rax
addq -0xd8(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x49d78
movq -0xd0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x8a0, %rsp            # imm = 0x8A0
popq %rbp
retq
nopl (%rax)