// File: /workspace/github_cpp_makefile_star2_O3/yukimasano[P]cpp_matrix/Matrix.cpp
// Function: QRsolve2(Matrix&, Vector&)
Vector QRsolve2(Matrix& A, Vector& bb){
	assert(nrows(A) == ncols(A));
	int m = ncols(A);
  Matrix A2 = A;
  Vector b=bb;
	Matrix V(m-1,m-1);
	for (int k=0; k<m ;k++){
		Vector xx(m-k);
    //std::cout<<k<<xx<<std::flush<<std::endl;
		for (int j=1;j<=m-k; j++){
			xx.set_val(j, A(j+k,k+1));
		}
		//std::cout<<xx<<std::endl<<std::flush;
		Vector vk(m-k);

		double len =xx.norm();
		vk.set_val(1,len);
    //std::cout<<k<<vk<<std::endl<<std::flush;
    //std::cout<<k<<xx.norm()<<std::endl<<std::flush;


		vk = vk+ xx;
    if (vk.norm()!=0){
		    vk = vk / vk.norm();
    }
		Matrix A_sub(m-k,m-k);
    	for (int i = k; i<m; i++){
    		for (int h = k; h<m; h++){
    			A_sub.set_val(i-k+1,h-k+1, A(i+1,h+1));
    		}
    	}
    //std::cout<<k<<A<<std::endl<<std::flush;
    	//std::cout<<A_sub<<std::endl<<std::flush;
		Matrix vk2(m-k,1);
		for (int jj=1 ; jj<=m-k;jj++){
			vk2.set_val(jj,1, vk(jj));
		}
		Matrix vk2T= vk2.T();
		Matrix vk3 = vk2T*A_sub;
		//std::cout<<vk2<<std::endl<<std::flush;
		Matrix A_sub2 = vk2*vk3;


		A_sub2 = 2*A_sub2;
		A_sub2 = A_sub - A_sub2;
		//std::cout<<A<<std::endl<<std::flush;

		for (int j = k; j<m; j++){
			for (int h=k; h<m; h++){
				A2.set_val(j+1,h+1,A_sub2(j+1-k, h+1-k) );
			}
		}
		Vector bk2(m-k);
		for (int jj=k ; jj<m;jj++){
			bk2.set_val(jj+1-k,b(jj+1));
		}
		Vector bk3  =  vk;
		double temp = (vk*bk2);
		//std::cout<<temp<<std::endl<<std::flush;
		bk3 = temp*vk;
		bk3 = 2*bk3;
		bk3 = bk2 - bk3;
		for (int jj=k ; jj<m;jj++){
			b.set_val(jj+1, bk3(jj-k+1));
		}
		for (int j=1; j<=m-k-1; j++){
			V.set_val(j,k+1,vk(j));
		}
	}
	//std::cout<<b<<std::endl<<std::flush;
	Vector x(m);
	/// BACKSOLving////////
	for (int k=m-1; k>=0; k--){
		x.set_val(k+1, b(k+1));
		for (int j = k+1; j<m; j++){
			x.set_val(k+1, x(k+1)- A2(k+1,j+1)*x(j+1));
			}
		x.set_val(k+1, x(k+1)/A2(k+1,k+1));
		}
	return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x10(%rsp)
movl 0x8(%rsi), %r14d
cmpl 0xc(%rsi), %r14d
jne 0x5dc1
movq %rdx, %r15
movq %rsi, %r12
leaq 0xb0(%rsp), %rdi
callq 0x3d86
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x822a
leal -0x1(%r14), %ebx
leaq 0x118(%rsp), %rdi
movl %ebx, %esi
movl %ebx, %edx
callq 0x2e94
testl %r14d, %r14d
movq %rbx, 0xc0(%rsp)
jle 0x5c8b
leal 0x1(%r14), %r15d
movl %r14d, %eax
negl %eax
movq %rax, 0xd8(%rsp)
movq %r14, %rax
negq %rax
movq %rax, 0x28(%rsp)
movl $0x1, 0x34(%rsp)
xorl %ebx, %ebx
leaq 0x90(%rsp), %r13
movl %r14d, %eax
movq %rax, 0x20(%rsp)
movq %r14, 0x58(%rsp)
movq %r12, 0xc8(%rsp)
cmpl %ebx, %r14d
movl %ebx, %eax
cmovgl %r14d, %eax
movl %eax, 0x8(%rsp)
movq %r14, %rbp
subq %rbx, %rbp
movq %r13, %rdi
movl %ebp, %esi
callq 0x81e8
movq %rbp, 0x18(%rsp)
testq %rbp, %rbp
jle 0x57b8
leal 0x1(%rbx), %ebp
movl $0x1, %r13d
leal (%rbx,%r13), %esi
movq %r12, %rdi
movl %ebp, %edx
callq 0x2f5c
movsd (%rax), %xmm0
leaq 0x90(%rsp), %rdi
movl %r13d, %esi
callq 0x8e60
movq 0x28(%rsp), %rax
addl %r13d, %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x577f
leaq 0x48(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x81e8
leaq 0x90(%rsp), %rdi
movl $0x2, %esi
callq 0x8d68
leaq 0x48(%rsp), %rdi
movl $0x1, %esi
callq 0x8e60
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
leaq 0x90(%rsp), %rdx
callq 0x828b
movq %r13, %rdi
movq %rbp, %rsi
callq 0x893a
movq %rbp, %rdi
callq 0x827e
movq %r13, %rdi
movl $0x2, %esi
callq 0x8d68
ucomisd 0x3853(%rip), %xmm0     # 0x9080
jne 0x5831
jnp 0x5871
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movl $0x2, %esi
callq 0x8d68
leaq 0x38(%rsp), %rbp
movsd %xmm0, 0x60(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x60(%rsp), %rdx
callq 0x8758
movq %r13, %rdi
movq %rbp, %rsi
callq 0x893a
movq %rbp, %rdi
callq 0x827e
leaq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rdx
movl %edx, %esi
callq 0x2e94
movq 0x20(%rsp), %rax
movl %eax, %eax
movq %rax, 0x20(%rsp)
movl %ebx, %eax
subl 0x8(%rsp), %eax
movq %rax, 0xe0(%rsp)
movl %r15d, %r15d
movq 0x38(%rsp), %r13
movq %rbx, 0x8(%rsp)
movq %rbx, %rbp
movq %rbp, %rbx
incq %rbp
subq 0x8(%rsp), %rbx
movl $0x1, %r14d
movq 0x8(%rsp), %rax
leal (%rax,%r14), %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x2f5c
movsd (%rax), %xmm0
movq (%r13,%rbx,8), %rax
movsd %xmm0, -0x8(%rax,%r14,8)
movq 0x28(%rsp), %rax
addq %r14, %rax
incq %rax
incq %r14
cmpq $0x1, %rax
jne 0x58bd
movq 0x58(%rsp), %r14
cmpq %r14, %rbp
jne 0x58ac
leaq 0x60(%rsp), %rdi
movq 0x18(%rsp), %rbx
movl %ebx, %esi
movl $0x1, %edx
callq 0x2e94
testq %rbx, %rbx
jle 0x5946
movl $0x1, %r13d
movq 0x60(%rsp), %rbx
leaq 0x48(%rsp), %rdi
movl %r13d, %esi
callq 0x8abc
movsd (%rax), %xmm0
movq -0x8(%rbx,%r13,8), %rax
movsd %xmm0, (%rax)
incq %r13
cmpq %r13, %r15
jne 0x5924
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
callq 0x3114
leaq 0x128(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x38(%rsp), %rdx
callq 0x37a8
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
movq %r14, %rdx
callq 0x37a8
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x70(%rsp)
leaq 0x80(%rsp), %r14
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
movq %rbx, %rdx
callq 0x3ace
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3574
movq %r14, %rdi
callq 0x2f1c
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
movq %rbx, %rdx
callq 0x3454
movq %r15, 0xd0(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3574
movq %r14, %rdi
callq 0x2f1c
movq 0xb0(%rsp), %rbx
movq 0x8(%rsp), %r15
leaq 0x1(%r15), %r14
movl %r14d, %ebp
movq 0x8(%rsp), %r12
subl %r12d, %ebp
movl $0x1, %r13d
leaq 0x108(%rsp), %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x2f5c
movsd (%rax), %xmm0
movq (%rbx,%r15,8), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
incl %r13d
cmpq %r12, 0x58(%rsp)
jne 0x5a12
movq %r14, %r15
movq 0x58(%rsp), %rax
cmpq %rax, %r14
jne 0x59fd
movq %rax, %r14
leaq 0x80(%rsp), %r12
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x81e8
movl $0x1, %ebp
movl 0x34(%rsp), %eax
movl %eax, %r13d
movq 0xd0(%rsp), %r15
movq 0x8(%rsp), %rbx
movq 0xd8(%rsp), %rax
addl %r13d, %eax
cmpl $0x1, %eax
je 0x5aba
leaq 0xa0(%rsp), %rdi
movl %r13d, %esi
callq 0x8abc
movsd (%rax), %xmm0
incl %r13d
leal 0x1(%rbp), %ebx
movq %r12, %rdi
movl %ebp, %esi
callq 0x8e60
movl %ebx, %ebp
movq 0x8(%rsp), %rbx
jmp 0x5a7d
leaq 0x70(%rsp), %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
callq 0x822a
movq %r13, %rdi
movq %r12, %rsi
callq 0x85c5
movq 0xc8(%rsp), %r12
movsd %xmm0, 0x100(%rsp)
leaq 0xf0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x100(%rsp), %rsi
movq %r13, %rdx
callq 0x86d1
leaq 0x70(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x893a
movq %rbp, %rdi
callq 0x827e
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xe8(%rsp)
movq %rbp, %rdi
leaq 0xe8(%rsp), %rsi
movq %r13, %rdx
callq 0x86d1
movq %r13, %rdi
movq %rbp, %rsi
callq 0x893a
movq %rbp, %rdi
callq 0x827e
movq %rbp, %rdi
leaq 0x80(%rsp), %rsi
movq %r13, %rdx
callq 0x8428
movq %r13, %rdi
movq %rbp, %rsi
callq 0x893a
movq %rbp, %rdi
callq 0x827e
movl $0x1, %r13d
movq 0xe0(%rsp), %rax
addl %r13d, %eax
cmpl $0x1, %eax
je 0x5bb6
leaq 0x70(%rsp), %rdi
movl %r13d, %esi
callq 0x8abc
leal (%rbx,%r13), %esi
movsd (%rax), %xmm0
incl %r13d
leaq 0xa0(%rsp), %rdi
callq 0x8e60
jmp 0x5b7f
cmpq $0x2, 0x18(%rsp)
jl 0x5bf6
movl $0x1, %r13d
movq 0x118(%rsp), %rbx
leaq 0x48(%rsp), %rdi
movl %r13d, %esi
callq 0x8abc
movsd (%rax), %xmm0
movq -0x8(%rbx,%r13,8), %rax
movq 0x8(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
incq %r13
cmpq %r13, 0x20(%rsp)
jne 0x5bcc
leaq 0x70(%rsp), %rdi
callq 0x827e
leaq 0x80(%rsp), %rdi
callq 0x827e
leaq 0x108(%rsp), %rdi
callq 0x2f1c
leaq 0x128(%rsp), %rdi
callq 0x2f1c
leaq 0x138(%rsp), %rdi
callq 0x2f1c
leaq 0x60(%rsp), %rdi
callq 0x2f1c
leaq 0x38(%rsp), %rdi
callq 0x2f1c
leaq 0x48(%rsp), %rdi
callq 0x827e
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x827e
movq 0x8(%rsp), %rbx
incq %rbx
decl %r15d
movq 0x20(%rsp), %rax
decl %eax
movq %rax, 0x20(%rsp)
incq 0x28(%rsp)
incl 0x34(%rsp)
cmpq %r14, %rbx
jne 0x574f
movq 0x10(%rsp), %rdi
movl %r14d, %esi
callq 0x81e8
testl %r14d, %r14d
movq 0xc0(%rsp), %rax
jle 0x5d83
leaq 0xa0(%rsp), %r15
leaq 0xb0(%rsp), %r12
movq %rax, %rbx
leal 0x1(%rax), %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x8abc
movsd (%rax), %xmm0
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x8e60
movl %ebp, %r13d
cmpl %r14d, %r13d
jge 0x5d40
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x8abc
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
incl %r13d
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x2f5c
movsd (%rax), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0x10(%rsp), %rdi
movl %r13d, %esi
callq 0x8abc
movsd 0x28(%rsp), %xmm1
mulsd (%rax), %xmm1
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x8e60
jmp 0x5cdc
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x8abc
movsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq %r12, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x2f5c
movsd 0x8(%rsp), %xmm0
divsd (%rax), %xmm0
movq 0x10(%rsp), %rdi
movl %ebp, %esi
callq 0x8e60
leal -0x1(%rbx), %eax
testl %ebx, %ebx
jg 0x5cb9
leaq 0x118(%rsp), %rdi
callq 0x2f1c
leaq 0xa0(%rsp), %rdi
callq 0x827e
leaq 0xb0(%rsp), %rdi
callq 0x2f1c
movq 0x10(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3552(%rip), %rdi      # 0x931a
leaq 0x3382(%rip), %rsi      # 0x9151
leaq 0x35b7(%rip), %rcx      # 0x938d
movl $0x248, %edx            # imm = 0x248
callq 0x20b0
jmp 0x5e6c
movq %rax, %r14
jmp 0x5f1b
movq %rax, %r14
jmp 0x5f28
jmp 0x5e5a
jmp 0x5e0c
jmp 0x5e98
jmp 0x5e89
jmp 0x5e89
jmp 0x5e0c
jmp 0x5e89
movq %rax, %r14
leaq 0xf0(%rsp), %rdi
callq 0x827e
jmp 0x5e8c
jmp 0x5e89
jmp 0x5eb4
jmp 0x5e40
jmp 0x5e7f
movq %rax, %r14
jmp 0x5ed1
jmp 0x5eea
movq %rax, %r14
jmp 0x5ec4
jmp 0x5eb4
movq %rax, %r14
leaq 0x80(%rsp), %rdi
callq 0x2f1c
jmp 0x5eb7
jmp 0x5eb4
jmp 0x5e76
jmp 0x5e84
jmp 0x5e76
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x827e
jmp 0x5ef7
movq %rax, %r14
jmp 0x5f0e
jmp 0x5e76
movq %rax, %r14
jmp 0x5ef7
jmp 0x5eaa
jmp 0x5e89
movq %rax, %r14
jmp 0x5ede
movq %rax, %r14
jmp 0x5f01
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x827e
jmp 0x5e9b
movq %rax, %r14
leaq 0x80(%rsp), %rdi
callq 0x827e
jmp 0x5eb7
movq %rax, %r14
movq 0x10(%rsp), %rdi
jmp 0x5f09
movq %rax, %r14
leaq 0x108(%rsp), %rdi
callq 0x2f1c
leaq 0x128(%rsp), %rdi
callq 0x2f1c
leaq 0x138(%rsp), %rdi
callq 0x2f1c
leaq 0x60(%rsp), %rdi
callq 0x2f1c
jmp 0x5eed
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x2f1c
leaq 0x48(%rsp), %rdi
callq 0x827e
leaq 0x90(%rsp), %rdi
callq 0x827e
leaq 0x118(%rsp), %rdi
callq 0x2f1c
leaq 0xa0(%rsp), %rdi
callq 0x827e
leaq 0xb0(%rsp), %rdi
callq 0x2f1c
movq %r14, %rdi
callq 0x21f0