// File: toxaart[P]hierarchical_block_sparse_lib/source/HierarchicalBlockSparseMatrix.h
// Function: hbsm::HierarchicalBlockSparseMatrix<double>::get_upper_triangle(hbsm::HierarchicalBlockSparseMatrix<double>&) const
void HierarchicalBlockSparseMatrix<Treal>::get_upper_triangle(HierarchicalBlockSparseMatrix<Treal> & A) const {

			if(get_n_rows() != get_n_cols()) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::get_upper_triangle(): call for non-square matrix!");

			if(!A.empty())A.clear();

			A.set_params(get_params());
			A.resize(nRows_orig,nCols_orig);

			if(lowest_level()){

				int blocksize = A.nRows;
				int M = A.nRows;
				if(A.on_bottom_boundary()) M = A.get_n_rows() % A.blocksize; // fill only necessary elements

				for (int col = 0; col < M; col++){
					for (int row = 0; row <= col; row++) {
						 A.submatrix[col * nRows + row] = submatrix[col * nRows + row];
					}
			   }

			   return;
			}

			// children 0 and 3 are recursive, child 2 is just a copy
			if(children[0] != NULL){
				A.children[0] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				A.children[0]->parent = &A;
				children[0]->get_upper_triangle(*A.children[0]);
			}

			// child2
			if(children[2] != NULL){
				A.children[2] = children[2];
				A.children[2]->parent = &A;
			}

			if(children[3] != NULL){
				A.children[3] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				A.children[3]->parent = &A;
				children[3]->get_upper_triangle(*A.children[3]);
			}

			return;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x60(%rbp)
callq 0x24470
movq -0x60(%rbp), %rdi
movl %eax, -0x54(%rbp)
callq 0x24540
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
je 0x2cd68
movl $0x10, %edi
callq 0x20d0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x68(%rbp)
leaq 0xabe5(%rip), %rsi      # 0x37915
callq 0x20a0
jmp 0x2cd37
movq -0x68(%rbp), %rdi
movq 0x142ae(%rip), %rsi     # 0x40ff0
movq 0x14277(%rip), %rdx     # 0x40fc0
callq 0x2320
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x2150
jmp 0x2d018
movq -0x10(%rbp), %rdi
callq 0x230a0
testb $0x1, %al
jne 0x2cd7e
movq -0x10(%rbp), %rdi
callq 0x23300
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x243e0
movq -0x70(%rbp), %rdi
movl %eax, -0x20(%rbp)
leaq -0x20(%rbp), %rsi
callq 0x8570
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x8600
movq -0x60(%rbp), %rdi
callq 0x23500
testb $0x1, %al
jne 0x2cdc8
jmp 0x2ce83
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24400
testb $0x1, %al
jne 0x2cde9
jmp 0x2cdfd
movq -0x10(%rbp), %rdi
callq 0x24470
movq -0x10(%rbp), %rcx
cltd
idivl 0x10(%rcx)
movl %edx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x2ce7e
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x2ce71
movq -0x60(%rbp), %rcx
movq %rcx, %rdi
addq $0x70, %rdi
movl -0x2c(%rbp), %eax
imull (%rcx), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x245a0
movq -0x60(%rbp), %rcx
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
movl -0x2c(%rbp), %eax
imull (%rcx), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x22b60
movsd -0x78(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x2ce13
jmp 0x2ce73
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2ce04
jmp 0x2d00f
movq -0x60(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x232b0
testb $0x1, %al
jne 0x2ce9a
jmp 0x2cf0a
leaq -0x40(%rbp), %rdi
callq 0x245c0
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
leaq -0x40(%rbp), %rsi
callq 0x235b0
leaq -0x40(%rbp), %rdi
callq 0x235e0
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x23570
movq -0x88(%rbp), %rcx
movq -0x60(%rbp), %rdi
movq %rcx, 0x68(%rax)
addq $0x28, %rdi
callq 0x23570
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
callq 0x24630
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x2cce0
movq -0x60(%rbp), %rdi
addq $0x28, %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x232b0
testb $0x1, %al
jne 0x2cf25
jmp 0x2cf69
movq -0x60(%rbp), %rsi
addq $0x28, %rsi
addq $0x20, %rsi
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
addq $0x20, %rdi
callq 0x273b0
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
addq $0x20, %rdi
callq 0x23570
movq -0x90(%rbp), %rcx
movq %rcx, 0x68(%rax)
movq -0x60(%rbp), %rdi
addq $0x28, %rdi
addq $0x30, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x232b0
testb $0x1, %al
jne 0x2cf87
jmp 0x2d00d
leaq -0x50(%rbp), %rdi
callq 0x245c0
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
addq $0x30, %rdi
leaq -0x50(%rbp), %rsi
callq 0x235b0
leaq -0x50(%rbp), %rdi
callq 0x235e0
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
addq $0x30, %rdi
callq 0x23570
movq -0xa0(%rbp), %rcx
movq -0x60(%rbp), %rdi
movq %rcx, 0x68(%rax)
addq $0x28, %rdi
addq $0x30, %rdi
callq 0x23570
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
addq $0x28, %rdi
addq $0x30, %rdi
callq 0x24630
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x2cce0
jmp 0x2d00f
addq $0xa0, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)