// File: /workspace/github_cpp_makefile_star2_O3/IlanPrice[P]Linear-Algebra-Library-in-Cplusplus/Matrix.cpp
// Function: MINRES(Matrix const&, Vector const&)
Vector MINRES(const Matrix& A, const Vector& b)
{
	std::ofstream MINRESres;
	MINRESres.open("MINRESres.txt");
	int n = length(b);
	Vector x(n);
	Vector temp1 = A*x;
	Vector r = b - temp1;
	double norm_r = norm(r);
	MINRESres << std::setprecision(15) << norm_r << "\n";
	double norm_r0 = norm_r;
	Vector v = r/norm_r;
	Matrix V(length(v),n);
	Matrix H(n+1,n);
	Vector r_e1(n+1);
	r_e1(1) = norm_r0;
	Matrix G = eye(n+1);
	V.setElements(1,n,1,1,v);
	double Tol = 1e-15;
	int k=0;
	double gamma = 0;
	while (norm_r > Tol)
		{
			k = k+1;
			Vector v_k = V.getElements(1,n,k,k,"Vector");
			Vector w = A*v_k;
			double delta = v_k*w;
			H(k,k) = delta;
			if (k>1)
			{
				H(k-1,k) = gamma;
				w = w - delta*v_k - gamma*V.getElements(1,n,k-1,k-1,"Vector");
			}
			else
			{
					w = w - delta*v_k;
			}
			gamma = norm(w);
			H(k+1,k) = gamma;
			if (gamma<1e-13)
			{ break;}
			else
			{
				Vector v_kplus1 = w/gamma;
				V.setElements(1,n,k+1,k+1,v_kplus1);
				Matrix Hhat = H.getElements(1,(k+1),1,k);
				Hhat = G.getElements(1,k+1,1,k+1)*Hhat;
				std::pair<double,double> g = givens(Hhat(k,k),Hhat(k+1,k));
				double gcos = g.first; double gsin = g.second;
				G.applygivens(k,k+1,gcos,gsin);
				norm_r = std::abs(norm_r*gsin);
				MINRESres << std::setprecision(15) << norm_r << "\n";
			}

		}

		r_e1.setValues(1,k+1,G.getElements(1,k+1,1,k+1)*r_e1.getValues(1,k+1));
		H.setElements(1,k+1,1,k, G.getElements(1,k+1,1,k+1)*H.getElements(1,(k+1),1,k));
		Vector y = backsubst(H.getElements(1,k,1,k),r_e1.getValues(1,k), 3);
		Vector xfinal = temp1 + V.getElements(1,n,1,k)*y;
		MINRESres.close();
		return xfinal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdx, %rbx
movq %rsi, 0xb0(%rsp)
movq %rdi, %r15
leaq 0x1b8(%rsp), %r14
movq %r14, %rdi
callq 0x2170
leaq 0x4652(%rip), %rsi      # 0xc5ed
movq %r14, %rdi
movl $0x10, %edx
callq 0x2040
movq %rbx, %rdi
callq 0x3461
movl %eax, %r14d
leaq 0x148(%rsp), %rdi
movl %eax, %esi
callq 0x28b8
leaq 0xf0(%rsp), %rdi
leaq 0x148(%rsp), %rdx
movq 0xb0(%rsp), %rsi
callq 0x5071
leaq 0xe0(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %rbx, %rsi
callq 0x2af8
leaq 0xe0(%rsp), %rdi
movl $0x2, %esi
callq 0x33e7
movsd %xmm0, 0x50(%rsp)
leaq 0x1b8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq $0xf, 0x1c0(%rsp,%rax)
callq 0x2160
leaq 0x42be(%rip), %rsi      # 0xc2f4
movl $0x1, %edx
movq %rax, %rdi
callq 0x2110
leaq 0x50(%rsp), %rdx
movsd (%rdx), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2e28
leaq 0xd0(%rsp), %rdi
callq 0x3461
leaq 0x90(%rsp), %rdi
movl %eax, %esi
movl %r14d, %edx
callq 0x3dd4
leal 0x1(%r14), %ebx
leaq 0x70(%rsp), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x3dd4
leaq 0xa0(%rsp), %rdi
movl %ebx, %esi
callq 0x28b8
leaq 0xa0(%rsp), %rdi
movl $0x1, %esi
callq 0x3330
movsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x80(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x3dd4
testl %r14d, %r14d
js 0x8100
movq 0x80(%rsp), %rax
movl %ebx, %ecx
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq (%rax,%rdx,8), %rdi
movq %rsi, (%rdi,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x80f0
leaq 0x138(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x28fa
movq %r15, 0x100(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x138(%rsp), %r9
movl $0x1, %esi
movq %r14, 0x68(%rsp)
movl %r14d, %edx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x49d8
leaq 0x138(%rsp), %rdi
callq 0x294e
movq $0x0, 0x48(%rsp)
movsd 0x50(%rsp), %xmm0
xorl %r12d, %r12d
ucomisd 0x418f(%rip), %xmm0     # 0xc300
jbe 0x864e
leaq 0x198(%rsp), %rbp
movq $0x0, 0x18(%rsp)
leaq 0x20(%rsp), %rbx
movq %rbp, 0x188(%rsp)
leaq 0x188(%rsp), %rdi
leaq 0x4442(%rip), %rsi      # 0xc5e6
leaq 0x4441(%rip), %rdx      # 0xc5ec
callq 0x3c44
movq 0x18(%rsp), %rax
leaq 0x1(%rax), %r12
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
movl $0x1, %edx
movq 0x68(%rsp), %rcx
movl %r12d, %r8d
movl %r12d, %r9d
callq 0x4398
movq 0x188(%rsp), %rdi
cmpq %rbp, %rdi
je 0x81eb
callq 0x2100
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq 0xb0(%rsp), %rsi
movq %rbx, %rdx
callq 0x5071
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2c95
movsd %xmm0, 0xb8(%rsp)
leaq 0x70(%rsp), %rdi
movl %r12d, %esi
movl %r12d, %edx
movsd %xmm0, 0x30(%rsp)
callq 0x5202
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rsi
testq %rsi, %rsi
je 0x8377
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
leaq 0x70(%rsp), %rdi
movl %r12d, %edx
callq 0x5202
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x128(%rsp), %r14
movq %r14, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x2da1
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2af8
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x432d(%rip), %rsi      # 0xc5e6
leaq 0x432c(%rip), %rdx      # 0xc5ec
callq 0x3c44
leaq 0x178(%rsp), %r14
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movl $0x1, %edx
movq 0x68(%rsp), %rcx
movq 0x18(%rsp), %r8
movl %r8d, %r9d
callq 0x4398
leaq 0xc0(%rsp), %r13
movq %r13, %rdi
leaq 0x48(%rsp), %rsi
movq %r14, %rdx
callq 0x2da1
leaq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x2af8
movq %rbx, %rdi
movq %r15, %rsi
callq 0x300a
movq %r15, %rdi
callq 0x294e
leaq 0xc0(%rsp), %rdi
callq 0x294e
leaq 0x178(%rsp), %rdi
callq 0x294e
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x8363
callq 0x2100
leaq 0x58(%rsp), %rdi
callq 0x294e
leaq 0x128(%rsp), %rdi
jmp 0x83c1
leaq 0x58(%rsp), %r15
movq %r15, %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x2da1
leaq 0x38(%rsp), %r13
movq %r13, %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2af8
movq %rbx, %rdi
movq %r13, %rsi
callq 0x300a
movq %r13, %rdi
callq 0x294e
leaq 0x58(%rsp), %rdi
callq 0x294e
movq %rbx, %rdi
movl $0x2, %esi
callq 0x33e7
movsd %xmm0, 0x48(%rsp)
movq 0x18(%rsp), %rax
leal 0x2(%rax), %ebx
leaq 0x70(%rsp), %rdi
movl %ebx, %esi
movl %r12d, %edx
movsd %xmm0, 0x30(%rsp)
callq 0x5202
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x3f08(%rip), %xmm0     # 0xc310
ucomisd 0x48(%rsp), %xmm0
ja 0x863a
leaq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x2e28
leaq 0x1a8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x28fa
movq 0x18(%rsp), %rax
leaq 0x2(%rax), %r15
leaq 0x90(%rsp), %rdi
movl $0x1, %esi
movq 0x68(%rsp), %rdx
movl %r15d, %ecx
movl %r15d, %r8d
movq %r13, %r9
callq 0x49d8
movq %r13, %rdi
callq 0x294e
leaq 0x58(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl %r12d, %r9d
callq 0x412c
leaq 0xc0(%rsp), %r13
movq %r13, %rdi
leaq 0x80(%rsp), %rsi
movl $0x1, %edx
movl %r15d, %ecx
movl $0x1, %r8d
movl %r15d, %r9d
callq 0x412c
leaq 0x128(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
leaq 0x58(%rsp), %r15
movq %r15, %rdx
callq 0x4ef7
movq %r15, %rdi
movq %r14, %rsi
callq 0x681a
movq %r14, %rdi
callq 0x3fe2
movq %r13, %rdi
callq 0x3fe2
movq %r15, %rdi
movl %r12d, %esi
movl %r12d, %edx
callq 0x5202
movsd (%rax), %xmm0
movsd %xmm0, 0x30(%rsp)
movq %r15, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0x5202
movsd (%rax), %xmm0
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd 0x30(%rsp), %xmm5
movapd %xmm5, %xmm2
mulsd %xmm5, %xmm2
addsd %xmm1, %xmm2
xorps %xmm1, %xmm1
sqrtsd %xmm2, %xmm1
xorpd 0x3b01(%rip), %xmm0     # 0xc040
divsd %xmm1, %xmm0
movl 0x8c(%rsp), %eax
testl %eax, %eax
jle 0x85a7
divsd %xmm1, %xmm5
movq 0x80(%rsp), %rdx
movq -0x8(%rdx,%r12,8), %rcx
movq 0x18(%rsp), %rsi
movq 0x8(%rdx,%rsi,8), %rdx
xorl %esi, %esi
movsd (%rcx,%rsi,8), %xmm1
movsd (%rdx,%rsi,8), %xmm2
movapd %xmm0, %xmm3
mulsd %xmm2, %xmm3
movapd %xmm5, %xmm4
mulsd %xmm1, %xmm4
subsd %xmm3, %xmm4
mulsd %xmm5, %xmm2
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movsd %xmm4, (%rcx,%rsi,8)
movsd %xmm1, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rax
jne 0x856b
mulsd 0x50(%rsp), %xmm0
andpd 0x3a9b(%rip), %xmm0     # 0xc050
movlpd %xmm0, 0x50(%rsp)
movq 0x1b8(%rsp), %rax
movq -0x18(%rax), %rax
movq $0xf, 0x1c0(%rsp,%rax)
leaq 0x1b8(%rsp), %rdi
callq 0x2160
leaq 0x20(%rsp), %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3d00(%rip), %rsi      # 0xc2f4
callq 0x2110
leaq 0x58(%rsp), %rdi
callq 0x3fe2
leaq 0x38(%rsp), %rdi
callq 0x294e
leaq 0x8(%rsp), %rdi
callq 0x294e
movq %rbx, %rdi
callq 0x294e
movsd 0x50(%rsp), %xmm0
ucomisd 0x3cd3(%rip), %xmm0     # 0xc300
movq %r12, 0x18(%rsp)
ja 0x818d
jmp 0x864e
leaq 0x8(%rsp), %rdi
callq 0x294e
leaq 0x20(%rsp), %rdi
callq 0x294e
leal 0x1(%r12), %ebx
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl %ebx, %r9d
callq 0x412c
leaq 0x8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
callq 0x3802
leaq 0x118(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x5071
leaq 0xa0(%rsp), %rdi
leaq 0x118(%rsp), %rcx
movl $0x1, %esi
movl %ebx, %edx
callq 0x3882
leaq 0x118(%rsp), %rdi
callq 0x294e
leaq 0x8(%rsp), %rdi
callq 0x294e
leaq 0x20(%rsp), %rdi
callq 0x3fe2
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl %ebx, %r9d
callq 0x412c
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
movl %ebx, %ecx
movl $0x1, %r8d
movl %r12d, %r9d
callq 0x412c
leaq 0x108(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x4ef7
leaq 0x70(%rsp), %rdi
leaq 0x108(%rsp), %r9
movl $0x1, %esi
movl %ebx, %edx
movl $0x1, %ecx
movl %r12d, %r8d
callq 0x475c
leaq 0x108(%rsp), %rdi
callq 0x3fe2
leaq 0x8(%rsp), %rdi
callq 0x3fe2
leaq 0x20(%rsp), %rdi
callq 0x3fe2
leaq 0x8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
movl %r12d, %ecx
movl $0x1, %r8d
movl %r12d, %r9d
callq 0x412c
leaq 0x38(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl $0x1, %edx
movl %r12d, %ecx
callq 0x3802
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movl $0x3, %ecx
callq 0x620e
leaq 0x38(%rsp), %rdi
callq 0x294e
leaq 0x8(%rsp), %rdi
callq 0x3fe2
leaq 0x38(%rsp), %rdi
leaq 0x90(%rsp), %rsi
movl $0x1, %edx
movq 0x68(%rsp), %rcx
movl $0x1, %r8d
movl %r12d, %r9d
callq 0x412c
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x5071
movq 0x100(%rsp), %r14
leaq 0xf0(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x295b
leaq 0x8(%rsp), %rdi
callq 0x294e
leaq 0x38(%rsp), %rdi
callq 0x3fe2
leaq 0x1b8(%rsp), %rdi
callq 0x2130
leaq 0x1c0(%rsp), %rbx
leaq 0x20(%rsp), %rdi
callq 0x294e
leaq 0x80(%rsp), %rdi
callq 0x3fe2
leaq 0xa0(%rsp), %rdi
callq 0x294e
leaq 0x70(%rsp), %rdi
callq 0x3fe2
leaq 0x90(%rsp), %rdi
callq 0x3fe2
leaq 0xd0(%rsp), %rdi
callq 0x294e
leaq 0xe0(%rsp), %rdi
callq 0x294e
leaq 0xf0(%rsp), %rdi
callq 0x294e
leaq 0x148(%rsp), %rdi
callq 0x294e
movq 0x76f0(%rip), %rax      # 0xffc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
movq %rcx, -0x8(%rbx)
movq -0x18(%rcx), %rcx
movq %rax, 0x1b8(%rsp,%rcx)
movq %rbx, %rdi
callq 0x20e0
leaq 0x2b0(%rsp), %rdi
callq 0x2060
movq %r14, %rax
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
jmp 0x8b2c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x294e
jmp 0x8936
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3fe2
jmp 0x8b31
jmp 0x8aff
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x294e
jmp 0x895c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x89b9
jmp 0x8b04
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x3fe2
jmp 0x897d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3fe2
jmp 0x89b4
jmp 0x89b1
jmp 0x8b04
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x294e
jmp 0x89a5
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x294e
jmp 0x89b4
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3fe2
jmp 0x8b3b
jmp 0x8b04
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x8b36
jmp 0x8b04
jmp 0x89df
movq %rax, %rbx
jmp 0x8b48
movq %rax, %rbx
jmp 0x8b55
movq %rax, %rbx
jmp 0x8b5f
jmp 0x8a1d
movq %rax, %rbx
jmp 0x8b86
movq %rax, %rbx
jmp 0x8b93
jmp 0x8a0d
jmp 0x8a0d
movq %rax, %rbx
jmp 0x8ba0
movq %rax, %rbx
jmp 0x8b6c
movq %rax, %rbx
jmp 0x8b79
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x294e
jmp 0x8a37
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x8b1d
jmp 0x8b24
movq %rax, %rbx
jmp 0x8aa5
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x294e
jmp 0x8a62
movq %rax, %rbx
jmp 0x8aaf
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x294e
jmp 0x8a79
jmp 0x8b24
movq %rax, %rbx
leaq 0x178(%rsp), %rdi
callq 0x294e
jmp 0x8a8b
movq %rax, %rbx
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x8aa5
callq 0x2100
leaq 0x58(%rsp), %rdi
callq 0x294e
leaq 0x128(%rsp), %rdi
jmp 0x8b1d
jmp 0x8b0b
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3fe2
jmp 0x8b0e
jmp 0x8b24
jmp 0x8ae3
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x294e
jmp 0x8b18
movq %rax, %rbx
jmp 0x8b18
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %rbp, %rdi
je 0x8b3b
callq 0x2100
jmp 0x8b3b
movq %rax, %rbx
jmp 0x8b31
movq %rax, %rbx
jmp 0x8b3b
jmp 0x8b0b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3fe2
leaq 0x38(%rsp), %rdi
callq 0x294e
jmp 0x8b27
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x294e
leaq 0x20(%rsp), %rdi
callq 0x294e
leaq 0x80(%rsp), %rdi
callq 0x3fe2
leaq 0xa0(%rsp), %rdi
callq 0x294e
leaq 0x70(%rsp), %rdi
callq 0x3fe2
leaq 0x90(%rsp), %rdi
callq 0x3fe2
leaq 0xd0(%rsp), %rdi
callq 0x294e
leaq 0xe0(%rsp), %rdi
callq 0x294e
leaq 0xf0(%rsp), %rdi
callq 0x294e
leaq 0x148(%rsp), %rdi
callq 0x294e
leaq 0x1b8(%rsp), %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x21b0