// File: /workspace/github_cpp_makefile_star2_O3/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 0x1cbb0
movl %esi, %ebp
movq %rdi, %rbx
movq 0x58(%rdi), %xmm0
movq 0x48(%rdi), %xmm1
punpcklqdq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0]
movq 0x38(%rdi), %xmm0
movq 0x28(%rdi), %xmm2
punpcklqdq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0]
por %xmm1, %xmm2
pxor %xmm0, %xmm0
pcmpeqd %xmm2, %xmm0
movmskps %xmm0, %eax
xorl $0xf, %eax
jne 0x1ca9e
movq %rbx, %rdi
callq 0x1b448
testb %al, %al
je 0x1cb5e
movq %rbx, %r14
testl %ebp, %ebp
jle 0x1cab9
movq %rbx, %r14
movq 0x28(%r14), %r14
testq %r14, %r14
je 0x1cb7e
decl %ebp
jne 0x1caa8
movq (%r14), %rax
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x1b448
testb %al, %al
je 0x1cb1c
leaq 0x70(%rbx), %rdi
movq 0x70(%rbx), %rax
cmpq %rax, 0x78(%rbx)
je 0x1cadd
movq %rax, 0x78(%rbx)
movl 0x10(%rbx), %esi
imull %esi, %esi
callq 0x1b416
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 0x1cb16
callq 0x1b482
decl %ebp
jne 0x1cb01
jmp 0x1cb4b
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 0x1c8e8
addq $0x10, %r15
addq $0x10, %r12
decq %r13
jne 0x1cb2a
movq %rbx, 0x68(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %ecx
testl %ebp, %ebp
jle 0x1cb75
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
movl %eax, %ecx
decl %ebp
jne 0x1cb66
jmp 0x1cb77
movl %ecx, %eax
movl %eax, (%rbx)
movl %eax, 0x4(%rbx)
jmp 0x1cb4f
movl $0x10, %edi
callq 0x20c0
movq %rax, %rbx
leaq 0x8468(%rip), %rsi      # 0x24ffa
movq %rax, %rdi
callq 0x20a0
movq 0xf44f(%rip), %rsi      # 0x2bff0
movq 0xf418(%rip), %rdx      # 0x2bfc0
movq %rbx, %rdi
callq 0x2290
movl $0x10, %edi
callq 0x20c0
movq %rax, %rbx
leaq 0x83e3(%rip), %rsi      # 0x24fa7
movq %rax, %rdi
callq 0x20a0
jmp 0x1cb9a
jmp 0x1cbd0
movq %rax, %r14
movq %rbx, %rdi
callq 0x2140
movq %r14, %rdi
callq 0x22b0
nop