// File: /workspace/github_cpp_makefile_star2_O1/toxaart[P]hierarchical_block_sparse_lib/source/HierarchicalBlockSparseMatrix.h
// Function: hbsm::HierarchicalBlockSparseMatrix<double>::remove_dummy_levels(hbsm::HierarchicalBlockSparseMatrix<double>&, int)
void HierarchicalBlockSparseMatrix<Treal>::remove_dummy_levels(HierarchicalBlockSparseMatrix<Treal> & C, int n_dummy_levels){

			if(n_dummy_levels == 0) throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::remove_dummy_levels(): n_dummy_levels = 0!");

			HierarchicalBlockSparseMatrix<Treal> *ptr = &C;
			if(!C.children_exist() && !C.lowest_level()){
				int nRows = C.nRows;
				for(int i = 0; i < n_dummy_levels; ++i){
					nRows = nRows / 2;
				}
				C.nRows = nRows;
				C.nCols = nRows;
				return;
			}


			for(int i = 0; i < n_dummy_levels; ++i){
				if(ptr->children[0] != NULL) ptr = ptr->children[0].get();
				else throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::remove_dummy_levels(): error when squeezing matrix!");
			}

			// ok, we have found a child which is the "correct matrix", ptr is pointing to it

			// "replace" C with this "correct" matrix

			C.nRows = ptr->nRows;
			C.nCols = ptr->nCols;

			if(ptr->lowest_level()){
				C.submatrix.clear();
				C.submatrix.resize(C.blocksize*C.blocksize);
				std::memcpy(&C.submatrix[0], &ptr->submatrix[0], C.submatrix.size() * sizeof(Treal));
				for(int i = 0; i < 4; ++i) C.children[0] = nullptr;
			}
			else{
				for(int i = 0; i < 4; ++i) C.children[i] = ptr->children[i];
			}

			ptr->parent = &C;

	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %esi, %esi
je 0x1c658
movl %esi, %ebp
movq %rdi, %rbx
cmpq $0x0, 0x28(%rdi)
jne 0x1c540
cmpq $0x0, 0x38(%rbx)
jne 0x1c540
cmpq $0x0, 0x48(%rbx)
jne 0x1c540
cmpq $0x0, 0x58(%rbx)
jne 0x1c540
movq %rbx, %rdi
callq 0x1aed4
testb %al, %al
je 0x1c5f9
movq %rbx, %r14
testl %ebp, %ebp
jle 0x1c55b
movq %rbx, %r14
movq 0x28(%r14), %r14
testq %r14, %r14
je 0x1c626
decl %ebp
jne 0x1c54a
movl (%r14), %eax
movl %eax, (%rbx)
movl 0x4(%r14), %eax
movl %eax, 0x4(%rbx)
movq %r14, %rdi
callq 0x1aed4
testb %al, %al
je 0x1c5c4
leaq 0x70(%rbx), %rdi
movq 0x70(%rbx), %rax
cmpq %rax, 0x78(%rbx)
je 0x1c585
movq %rax, 0x78(%rbx)
movl 0x10(%rbx), %esi
imull %esi, %esi
callq 0x1aea2
movq 0x70(%r14), %rsi
movq 0x70(%rbx), %rdi
movq 0x78(%rbx), %rdx
subq %rdi, %rdx
callq 0x2180
movl $0x4, %ebp
movq 0x30(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rbx)
testq %rdi, %rdi
je 0x1c5be
callq 0x1af0e
decl %ebp
jne 0x1c5a9
jmp 0x1c5f3
leaq 0x30(%rbx), %r15
leaq 0x30(%r14), %r12
movl $0x4, %r13d
movq -0x8(%r12), %rax
movq %rax, -0x8(%r15)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1c38c
addq $0x10, %r15
addq $0x10, %r12
decq %r13
jne 0x1c5d2
movq %rbx, 0x68(%r14)
jmp 0x1c617
movl (%rbx), %ecx
testl %ebp, %ebp
jle 0x1c610
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movl %eax, %ecx
decl %ebp
jne 0x1c601
jmp 0x1c612
movl %ecx, %eax
movl %eax, (%rbx)
movl %eax, 0x4(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20c0
movq %rax, %rbx
leaq 0x7960(%rip), %rsi      # 0x23f9a
movq %rax, %rdi
callq 0x20a0
movq 0xe9a7(%rip), %rsi      # 0x2aff0
movq 0xe970(%rip), %rdx      # 0x2afc0
movq %rbx, %rdi
callq 0x2290
movl $0x10, %edi
callq 0x20c0
movq %rax, %rbx
leaq 0x78db(%rip), %rsi      # 0x23f47
movq %rax, %rdi
callq 0x20a0
jmp 0x1c642
jmp 0x1c678
movq %rax, %r14
movq %rbx, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x22b0
nop