// File: manikandan5[P]Image-Matching-Stitching-Warping/./CImg.h
// Function: cimg_library::CImg<double>& cimg_library::CImg<double>::solve<double>(cimg_library::CImg<double> const&)
CImg<T>& solve(const CImg<t>& A) {
      if (_width!=1 || _depth!=1 || _spectrum!=1 || _height!=A._height || A._depth!=1 || A._spectrum!=1)
        throw CImgArgumentException(_cimg_instance
                                    "solve(): Instance and specified matrix (%u,%u,%u,%u,%p) have "
                                    "incompatible dimensions.",
                                    cimg_instance,
                                    A._width,A._height,A._depth,A._spectrum,A._data);
      typedef _cimg_Ttfloat Ttfloat;
      if (A._width==A._height) {
#ifdef cimg_use_lapack
        char TRANS = 'N';
        int INFO, N = _height, LWORK = 4*N, *const IPIV = new int[N];
        Ttfloat
          *const lapA = new Ttfloat[N*N],
          *const lapB = new Ttfloat[N],
          *const WORK = new Ttfloat[LWORK];
        cimg_forXY(A,k,l) lapA[k*N+l] = (Ttfloat)(A(k,l));
        cimg_forY(*this,i) lapB[i] = (Ttfloat)((*this)(i));
        cimg::getrf(N,lapA,IPIV,INFO);
        if (INFO)
          cimg::warn(_cimg_instance
                     "solve(): LAPACK library function dgetrf_() returned error code %d.",
                     cimg_instance,
                     INFO);

        if (!INFO) {
          cimg::getrs(TRANS,N,lapA,IPIV,lapB,INFO);
          if (INFO)
            cimg::warn(_cimg_instance
                       "solve(): LAPACK library function dgetrs_() returned error code %d.",
                       cimg_instance,
                       INFO);
        }
        if (!INFO) cimg_forY(*this,i) (*this)(i) = (T)(lapB[i]); else fill(0);
        delete[] IPIV; delete[] lapA; delete[] lapB; delete[] WORK;
#else
        CImg<Ttfloat> lu(A,false);
        CImg<Ttfloat> indx;
        bool d;
        lu._LU(indx,d);
        _solve(lu,indx);
#endif
      } else { // Least-square solution for non-square systems.
#ifdef cimg_use_lapack
        char TRANS = 'N';
        int INFO, N = A._width, M = A._height, LWORK = -1, LDA = M, LDB = M, NRHS = _width;
        Ttfloat WORK_QUERY;
        Ttfloat
          * const lapA = new Ttfloat[M*N],
          * const lapB = new Ttfloat[M*NRHS];
        cimg::sgels(TRANS, M, N, NRHS, lapA, LDA, lapB, LDB, &WORK_QUERY, LWORK, INFO);
        LWORK = (int) WORK_QUERY;
        Ttfloat *const WORK = new Ttfloat[LWORK];
        cimg_forXY(A,k,l) lapA[k*M+l] = (Ttfloat)(A(k,l));
        cimg_forXY(*this,k,l) lapB[k*M+l] = (Ttfloat)((*this)(k,l));
        cimg::sgels(TRANS, M, N, NRHS, lapA, LDA, lapB, LDB, WORK, LWORK, INFO);
        if (INFO != 0)
          cimg::warn(_cimg_instance
                     "solve(): LAPACK library function sgels() returned error code %d.",
                     cimg_instance,
                     INFO);
        assign(NRHS, N);
        if (!INFO != 0)
          cimg_forXY(*this,k,l) (*this)(k,l) = (T)lapB[k*M+l];
        else
          assign(A.get_pseudoinvert()*(*this));
        delete[] lapA; delete[] lapB; delete[] WORK;
#else
        assign(A.get_pseudoinvert()*(*this));
#endif
      }
      return *this;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x80(%rsp)
cmpl $0x1, (%rax)
jne 0xaad8
movq 0x80(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0xaad8
movq 0x80(%rsp), %rax
cmpl $0x1, 0xc(%rax)
jne 0xaad8
movq 0x80(%rsp), %rax
movl 0x4(%rax), %eax
movq 0x120(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xaad8
movq 0x120(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0xaad8
movq 0x120(%rsp), %rax
cmpl $0x1, 0xc(%rax)
je 0xabee
movl $0x4008, %edi           # imm = 0x4008
callq 0x5240
movq %rax, %rcx
movq 0x80(%rsp), %rax
movq %rcx, 0x50(%rsp)
movl (%rax), %ecx
movl %ecx, 0x58(%rsp)
movl 0x4(%rax), %ecx
movl %ecx, 0x5c(%rsp)
movl 0x8(%rax), %ecx
movl %ecx, 0x60(%rsp)
movl 0xc(%rax), %ecx
movl %ecx, 0x64(%rsp)
movq 0x18(%rax), %rcx
movq %rcx, 0x68(%rsp)
movb 0x10(%rax), %dl
leaq 0xddeb2(%rip), %rcx     # 0xe89d2
leaq 0xbefba(%rip), %rax     # 0xc9ae1
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0x70(%rsp)
callq 0x118f0
movq %rax, 0x78(%rsp)
jmp 0xab3f
movl 0x64(%rsp), %r9d
movl 0x60(%rsp), %r8d
movl 0x5c(%rsp), %ecx
movl 0x58(%rsp), %edx
movq 0x50(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %r10
movq 0x78(%rsp), %r11
movq 0x120(%rsp), %rax
movl (%rax), %ebx
movl 0x4(%rax), %ebp
movl 0x8(%rax), %r14d
movl 0xc(%rax), %r15d
movq 0x18(%rax), %r12
movq %rsp, %rax
movq %rax, 0x48(%rsp)
movq %r12, 0x38(%rax)
movl %r15d, 0x30(%rax)
movl %r14d, 0x28(%rax)
movl %ebp, 0x20(%rax)
movl %ebx, 0x18(%rax)
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movq %rsi, (%rax)
leaq 0xe2733(%rip), %rsi     # 0xed2dd
xorl %eax, %eax
callq 0x12220
jmp 0xabb3
movq 0x50(%rsp), %rdi
leaq 0xf4fa1(%rip), %rsi     # 0xffb60
leaq 0x789a(%rip), %rdx      # 0x12460
callq 0x5920
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
callq 0x53a0
jmp 0xad9a
movq 0x120(%rsp), %rax
movl (%rax), %eax
movq 0x120(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jne 0xacd3
movq 0x120(%rsp), %rsi
leaq 0xf0(%rsp), %rdi
xorl %edx, %edx
callq 0x5dc40
leaq 0xd0(%rsp), %rdi
callq 0xb6c0
jmp 0xac2f
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xcf(%rsp), %rdx
callq 0xb65c0
jmp 0xac4e
movq 0x80(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
callq 0xb6ea0
leaq 0xd0(%rsp), %rdi
callq 0xa540
leaq 0xf0(%rsp), %rdi
callq 0xa540
jmp 0xad82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xacc1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xa540
leaq 0xf0(%rsp), %rdi
callq 0xa540
jmp 0xad9a
movq 0x120(%rsp), %rsi
leaq 0x88(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0xbfb00
movq 0x40(%rsp), %rsi
movq 0x80(%rsp), %rdx
leaq 0xa8(%rsp), %rdi
callq 0xba2b0
jmp 0xad09
movq 0x80(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x5e300
jmp 0xad20
leaq 0xa8(%rsp), %rdi
callq 0xa540
leaq 0x88(%rsp), %rdi
callq 0xa540
jmp 0xad82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xad73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xa540
leaq 0x88(%rsp), %rdi
callq 0xa540
jmp 0xad9a
movq 0x80(%rsp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x118(%rsp), %rdi
callq 0x5970
nopw (%rax,%rax)