// File: /workspace/github_cpp_makefile_star2_O3/IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: LU(Matrix const&)
boost::tuple< Matrix, Matrix, Matrix> LU(const Matrix& A)
	{
		Vector dim = size(A);
		int m = dim(1);
		int n = dim(2);
		Matrix U(A);
		Matrix pivot(m,m);
		Matrix P = eye(m);
		Matrix L = eye(m);

		for (int k=1;k<m;k++)
		{
			// partial pivoting
			double max = U(k,k);
			int index = k;
			pivot = eye(m);
			for (int i = k; i<=m; i++)
			{
				if (std::abs(U(i,k)) > std::abs(max))
				{
					index = i;
					max = U(i,k);
				}
			}
			if (index != k)
			{

				Vector temp = U.getElements(k,k,1,n,"vector");
				U.setElements(k,k,1,n,U.getElements(index,index,1,n,"Vector"));
				U.setElements(index,index,1,n,temp);
				Vector temp2 = L.getElements(k,k,1,m,"vector");

				L.setElements(k,k,1,m,L.getElements(index,index,1,m,"Vector"));
				L.setElements(index,index,1,m,temp2);
				pivot(index,index)=0; pivot(k,k) = 0;
				pivot(index,k) = 1; pivot(k,index) = 1;
				P = pivot*P;
			}
			// variant of Gaussian elimination
			Matrix Lk = eye(m);
			for (int i = k+1; i<=m;i++)
			{
				Lk(i,k) = U(i,k)/U(k,k);
				for (int j=k+1;j<=n;j++)
				{
					U(i,j) = U(i,j) - Lk(i,k)*U(k,j);
				}
				U(i,k) = 0;
			}
			L = L*pivot*Lk;
		}
		boost::tuple<Matrix,Matrix,Matrix> LUP = boost::make_tuple(L, U, P);
		return LUP;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %rbx
movq %rdi, 0x70(%rsp)
leaq 0xe8(%rsp), %r14
movq %r14, %rdi
callq 0x6cbd
movq %r14, %rdi
movl $0x1, %esi
callq 0x3330
cvttsd2si (%rax), %r13d
leaq 0xe8(%rsp), %rdi
movl $0x2, %esi
callq 0x3330
cvttsd2si (%rax), %ebp
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3f2a
movq 0x70(%rsp), %r14
leaq 0xb8(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3dd4
leaq 0xa8(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3dd4
movl %r13d, %esi
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
testl %r13d, %r13d
jle 0x574b
movq 0xa8(%rsp), %rax
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
movq %rdi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x573b
movq %rsi, 0x50(%rsp)
movl %ebp, 0x34(%rsp)
leaq 0x40(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3dd4
testl %r13d, %r13d
jle 0x5d68
movq 0x40(%rsp), %rax
xorl %ecx, %ecx
movq 0x50(%rsp), %rsi
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
movq (%rax,%rcx,8), %rdx
movq %rdi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x5783
cmpl $0x1, %r13d
je 0x5d68
movl %r13d, %eax
negl %eax
movq %rax, 0xd8(%rsp)
movl 0x34(%rsp), %eax
movl %eax, %ebp
negl %ebp
movl $0x1, %ebx
leaq 0xc8(%rsp), %r15
leaq 0x98(%rsp), %r12
movl %r13d, 0x30(%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movapd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x3dd4
movq 0x98(%rsp), %rax
xorl %ecx, %ecx
movq 0x50(%rsp), %rsi
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
movq (%rax,%rcx,8), %rdx
movq %rdi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x5809
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0x681a
movq %r12, %rdi
callq 0x3fe2
movl %ebx, %r14d
movl %ebx, %r13d
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movapd 0x6800(%rip), %xmm2     # 0xc050
andpd %xmm2, %xmm0
movapd 0x60(%rsp), %xmm1
andpd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x587e
movq %r15, %rdi
movl %r14d, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movapd %xmm0, 0x60(%rsp)
movl %r14d, %r13d
movq 0xd8(%rsp), %rax
addl %r14d, %eax
incl %eax
movl %r14d, %ecx
incl %ecx
movl %ecx, %r14d
cmpl $0x1, %eax
jne 0x5837
cmpl %ebx, %r13d
je 0x5bac
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x6ac9(%rip), %rsi      # 0xc389
leaq 0x6ac8(%rip), %rdx      # 0xc38f
callq 0x3c44
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl 0x34(%rsp), %r9d
callq 0x4398
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x5900
callq 0x2100
leaq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x6cc7(%rip), %rsi      # 0xc5e6
leaq 0x6cc6(%rip), %rdx      # 0xc5ec
callq 0x3c44
leaq 0x198(%rsp), %rdi
movq %r15, %rsi
movl %r13d, %edx
movl %r13d, %ecx
movl $0x1, %r8d
movl 0x34(%rsp), %r14d
movl %r14d, %r9d
callq 0x4398
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl $0x1, %ecx
movl %r14d, %r8d
leaq 0x198(%rsp), %r14
movq %r14, %r9
callq 0x49d8
movq %r14, %rdi
callq 0x294e
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x5990
callq 0x2100
leaq 0x1a8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x28fa
movq %r15, %rdi
movl %r13d, %esi
movl %r13d, %edx
movl $0x1, %ecx
movl 0x34(%rsp), %r8d
movq %r14, %r9
callq 0x49d8
movq %r14, %rdi
callq 0x294e
leaq 0x128(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0x118(%rsp), %rdi
leaq 0x69a4(%rip), %rsi      # 0xc389
leaq 0x69a3(%rip), %rdx      # 0xc38f
callq 0x3c44
leaq 0x88(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl %ebx, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl 0x30(%rsp), %r9d
callq 0x4398
leaq 0x188(%rsp), %r14
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x5a34
callq 0x2100
leaq 0x108(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0x6b93(%rip), %rsi      # 0xc5e6
leaq 0x6b92(%rip), %rdx      # 0xc5ec
callq 0x3c44
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
movl %r13d, %edx
movl %r13d, %ecx
movl $0x1, %r8d
movl 0x30(%rsp), %r14d
movl %r14d, %r9d
callq 0x4398
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
movl $0x1, %ecx
movl %r14d, %r8d
leaq 0x188(%rsp), %r14
movq %r14, %r9
callq 0x49d8
movq %r14, %rdi
callq 0x294e
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x5ac3
callq 0x2100
leaq 0x178(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x28fa
leaq 0x40(%rsp), %rdi
movl %r13d, %esi
movl %r13d, %edx
movl $0x1, %ecx
movl 0x30(%rsp), %r8d
leaq 0x178(%rsp), %r14
movq %r14, %r9
callq 0x49d8
movq %r14, %rdi
callq 0x294e
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x5202
movq $0x0, (%rax)
movq %r14, %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x5202
movq $0x0, (%rax)
movq %r14, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x5202
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq %r14, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x5202
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0xa8(%rsp), %r14
movq %r14, %rdx
callq 0x4ef7
movq %r14, %rdi
movq %r13, %rsi
callq 0x681a
movq %r13, %rdi
callq 0x3fe2
leaq 0x88(%rsp), %rdi
callq 0x294e
movq %r12, %rdi
callq 0x294e
movq %r12, %rdi
movl 0x30(%rsp), %edx
movl %edx, %esi
callq 0x3dd4
movq 0x98(%rsp), %rax
xorl %ecx, %ecx
movq 0x50(%rsp), %rsi
movabsq $0x3ff0000000000000, %rdi # imm = 0x3FF0000000000000
movq (%rax,%rcx,8), %rdx
movq %rdi, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x5bd3
leal 0x1(%rbx), %eax
movl %eax, 0x3c(%rsp)
movl %eax, %r13d
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x5202
movsd 0x60(%rsp), %xmm0
divsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x3c(%rsp), %eax
movl %eax, %r14d
cmpl 0x34(%rsp), %ebx
jge 0x5cd3
movq %r15, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0xe0(%rsp)
movq %r15, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0x5202
movsd 0x58(%rsp), %xmm1
mulsd 0xe0(%rsp), %xmm1
movsd 0x60(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
leal (%r14,%rbp), %eax
incl %eax
movl %r14d, %ecx
incl %ecx
movl %ecx, %r14d
cmpl $0x1, %eax
jne 0x5c48
movq %r15, %rdi
movl %r13d, %esi
movl %ebx, %edx
callq 0x5202
movq 0x70(%rsp), %r14
movq $0x0, (%rax)
leal 0x1(%r13), %eax
cmpl 0x30(%rsp), %r13d
movl %eax, %r13d
jne 0x5bed
leaq 0x78(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x4ef7
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
movq %r12, %rdx
callq 0x4ef7
movl 0x30(%rsp), %r13d
leaq 0x40(%rsp), %rdi
movq %rbx, %rsi
callq 0x681a
movq %rbx, %rdi
callq 0x3fe2
leaq 0x78(%rsp), %rdi
callq 0x3fe2
movq %r12, %rdi
callq 0x3fe2
movl 0x3c(%rsp), %eax
movl %eax, %ebx
cmpl %r13d, %eax
jne 0x57cc
leaq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x39(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x3a(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x3b(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, (%rsp)
leaq 0x40(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
leaq 0x98(%rsp), %r8
leaq 0x88(%rsp), %r9
movq %r14, %rdi
callq 0xb156
leaq 0x40(%rsp), %rdi
callq 0x3fe2
leaq 0xa8(%rsp), %rdi
callq 0x3fe2
leaq 0xb8(%rsp), %rdi
callq 0x3fe2
leaq 0xc8(%rsp), %rdi
callq 0x3fe2
leaq 0xe8(%rsp), %rdi
callq 0x294e
movq %r14, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f52
movq %rax, %rbx
jmp 0x5f73
movq %rax, %rbx
jmp 0x5f80
movq %rax, %rbx
jmp 0x5f8d
jmp 0x5e3a
jmp 0x5e3a
movq %rax, %rbx
jmp 0x5f9a
jmp 0x5e55
jmp 0x5e55
jmp 0x5f52
jmp 0x5f33
jmp 0x5f33
movq %rax, %rbx
jmp 0x5f43
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x294e
jmp 0x5ecf
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
callq 0x294e
jmp 0x5eee
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
jmp 0x5f3e
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
jmp 0x5efe
movq %rax, %rbx
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x5f69
callq 0x2100
jmp 0x5f69
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x5f36
callq 0x2100
jmp 0x5f36
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x5f43
callq 0x2100
jmp 0x5f43
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x294e
jmp 0x5f36
jmp 0x5f59
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3fe2
jmp 0x5f5c
jmp 0x5f52
jmp 0x5f52
jmp 0x5f52
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x294e
leaq 0x98(%rsp), %rdi
callq 0x294e
jmp 0x5f69
movq %rax, %rbx
jmp 0x5f69
jmp 0x5f59
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3fe2
leaq 0x40(%rsp), %rdi
callq 0x3fe2
leaq 0xa8(%rsp), %rdi
callq 0x3fe2
leaq 0xb8(%rsp), %rdi
callq 0x3fe2
leaq 0xc8(%rsp), %rdi
callq 0x3fe2
leaq 0xe8(%rsp), %rdi
callq 0x294e
movq %rbx, %rdi
callq 0x21b0