// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
testl %esi, %esi
je 0x165f6
movl %esi, %ebp
movq %rdi, %rbx
callq 0x14e62
testb %al, %al
jne 0x164e6
movq %rbx, %rdi
callq 0x14f94
testb %al, %al
je 0x165cc
xorl %eax, %eax
testl %ebp, %ebp
cmovgl %ebp, %eax
incl %eax
movq %rbx, %r14
decl %eax
je 0x1652f
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x164f2
pushq $0x10
popq %rdi
callq 0x20d0
movq %rax, %rbx
leaq 0x6a99(%rip), %rsi      # 0x1cfaa
movq %rax, %rdi
callq 0x2080
movq 0xfad0(%rip), %rsi      # 0x25ff0
movq 0xfa99(%rip), %rdx      # 0x25fc0
movq %rbx, %rdi
callq 0x2270
movq (%r14), %rax
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x14f94
testb %al, %al
je 0x165a2
leaq 0x70(%rbx), %rdi
movq 0x70(%rbx), %rax
cmpq %rax, 0x78(%rbx)
je 0x16553
movq %rax, 0x78(%rbx)
movl 0x10(%rbx), %esi
imull %esi, %esi
callq 0x14f62
movq 0x70(%r14), %rsi
movq 0x70(%rbx), %rdi
movq 0x78(%rbx), %rdx
subq %rdi, %rdx
callq 0x2170
leaq 0x28(%rbx), %r15
pushq $0x4
popq %rbp
leaq 0x8(%rsp), %r12
movq %rsp, %r13
subl $0x1, %ebp
jb 0x165c6
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x14fba
movq %r12, %rdi
callq 0x14fe8
jmp 0x16581
leaq 0x28(%r14), %r15
leaq 0x28(%rbx), %r12
xorl %r13d, %r13d
cmpq $0x40, %r13
je 0x165c6
leaq (%r15,%r13), %rsi
leaq (%r12,%r13), %rdi
callq 0x162fc
addq $0x10, %r13
jmp 0x165ad
movq %rbx, 0x68(%r14)
jmp 0x165e7
movl (%rbx), %eax
xorl %ecx, %ecx
testl %ebp, %ebp
cmovgl %ebp, %ecx
pushq $0x2
popq %rsi
subl $0x1, %ecx
jb 0x165e2
cltd
idivl %esi
jmp 0x165d8
movl %eax, (%rbx)
movl %eax, 0x4(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x20d0
movq %rax, %rbx
leaq 0x694f(%rip), %rsi      # 0x1cf57
movq %rax, %rdi
callq 0x2080
jmp 0x16519
jmp 0x16617
movq %rax, %r14
movq %rbx, %rdi
callq 0x2130
movq %r14, %rdi
callq 0x2290